Databases•18 min read•Beginner
What a Database Is (and What It Isn't)
Why we don't just dump everything in a JSON file. Durability, concurrency, queries.
What a database really gives you
Once a project has more than one user, has data you can't afford to lose, or has tables you want to query in interesting ways, a database starts paying for itself. The four things a real database gives you that a JSON file doesn't:
- Durability — data survives crashes, power loss, even disk corruption (with replication).
- Concurrency — many clients can read and write at once without stepping on each other.
- Query language — instead of writing custom code, you describe what you want and the engine figures out how to fetch it efficiently.
- Indexes — find rows in O(log n) instead of scanning everything.
📚
Real-life analogy — Database = library; file = your desk
A file is your desk. Quick to grab from, easy to lose. A library is a database: catalog system, librarians who handle simultaneous requests, alarms if something goes missing, and indexes that help you find any book in seconds.
Two big families
- RELATIONAL (SQL) — Postgres, MySQL, SQLite. Tables, rows, schemas, joins, transactions. The default for most apps.
- NoSQL — covers four sub-families: document (MongoDB), key-value (Redis, DynamoDB), wide-column (Cassandra), graph (Neo4j). Each is good for specific workloads.
💡 Tip
Default to Postgres unless you have a SPECIFIC reason not to. It's reliable, fast, has every feature, and works on your laptop. 'We need MongoDB for scale' is almost always premature.