Back to Home
Tutorials · Databases

Database Instructions

Three databases, three very different ideas of what a database is. SQLite is a single file your program opens directly. PostgreSQL is a server that many programs talk to at once, in SQL. MongoDB is a server too, but it stores JSON-like documents instead of rows. Each guide below takes you from nothing installed to your own data stored and queried, on Linux, macOS, or Windows, and every command block has a copy button.

The finish line — the three prompts you'll be typing at
SQLitesqlite> SELECT 1 + 1; 2
PostgreSQLyou=> SELECT 1 + 1; ?column? ---------- 2
MongoDBtest> 1 + 1 2
Guides 3
THE GUIDES

Pick a database, or do all three in order.

The order below goes from least to most setup. SQLite has no server, so you're writing SQL within a minute. PostgreSQL adds a server and a login system, called roles, that you need to understand before it will let you in. MongoDB adds a different data model on top of a server. The SQL you learn in the SQLite guide carries straight over to PostgreSQL.

1

SQLite3 Complete Guide

Start here if you're new to SQL. Install SQLite, then learn it level by level: beginner, intermediate, and advanced SQL, with a textbook explanation on every step and a quiz at the end.

2

Install PostgreSQL 18

Install PostgreSQL on Linux, macOS, or Windows, work out why psql says role does not exist and fix it, create your own role and database, then build a table and run your first queries.

3

Install MongoDB 8.3

Install MongoDB Community on Linux, macOS, or Windows, connect with mongosh, and insert, find, update, and delete your first documents. There's no schema to write first.

WHICH ONE

Three tools, three different jobs.

SQLitePostgreSQLMongoDB
Where the data livesOne file on diskA server process that owns a data directoryA server process that owns a data directory
Shape of the dataTables of rowsTables of rows, plus JSON columnsCollections of JSON-like documents
Query languageSQLSQLJavaScript-style method calls
Shellsqlite3psqlmongosh
Default portnone, no network543227017
Good first useA desktop app, a small website, a script's scratch dataA web app with many users writing at onceRecords whose fields vary from one to the next
This site runs on SQLite

All of bozcode.com's data, including the stock terminal's 2,900 companies, lives in SQLite files. It's a good default for one server, and the reason to move to PostgreSQL is when many processes need to write at the same moment, not because the data got big.

A file, a server that speaks SQL, and a server that stores documents. Choosing between them is choosing a shape for your data.