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 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.
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.
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.
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.
| SQLite | PostgreSQL | MongoDB | |
|---|---|---|---|
| Where the data lives | One file on disk | A server process that owns a data directory | A server process that owns a data directory |
| Shape of the data | Tables of rows | Tables of rows, plus JSON columns | Collections of JSON-like documents |
| Query language | SQL | SQL | JavaScript-style method calls |
| Shell | sqlite3 | psql | mongosh |
| Default port | none, no network | 5432 | 27017 |
| Good first use | A desktop app, a small website, a script's scratch data | A web app with many users writing at once | Records whose fields vary from one to the next |
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.