Databases
A database is organized, durable storage you can query. The big choice is how structured your data is.
Any real application needs to keep data around between requests and restarts. A database is software built for exactly that: storing data durably and letting you query it efficiently.
Relational (SQL) databases
Data lives in tables with a fixed schema — defined columns and types. Tables relate to each other by keys, and you query with SQL. Examples: PostgreSQL, MySQL, SQLite.
They shine when:
- your data is structured and the shape is known,
- relationships matter (users have orders, orders have items),
- you need transactions — several changes that must all succeed or all fail.
Non-relational (NoSQL) databases
A family of databases that drop the rigid table model for flexibility or scale:
| Type | Stores | Example |
|---|---|---|
| Document | JSON-like documents | MongoDB |
| Key/value | Simple pairs, very fast | Redis |
| Wide-column | Huge, sparse tables | Cassandra |
| Graph | Nodes and relationships | Neo4j |
ACID transactions
The guarantee that makes relational databases trustworthy. A transaction is Atomic (all or nothing), Consistent, Isolated (concurrent transactions do not corrupt each other), and Durable (once committed, it survives a crash). Moving money between accounts is the classic case.
Indexes
An index is a lookup structure that makes queries on a column fast — the difference between scanning a million rows and jumping straight to the one you want. The trade-off: indexes take space and slow down writes slightly, so you add them where you actually query, not everywhere.