A database is a system that stores data durably and lets programs query and change it safely, even when many users work at once and machines fail. It matters because almost every application is, at heart, a way of keeping state: the hard parts are correctness, speed and not losing anything.
Key concepts
- Data model: tables of rows, documents, key-value pairs or graphs; the model shapes what is easy to ask.
- Transactions: a group of changes that succeeds or fails as one unit, with ACID guarantees.
- Indexes: extra structures, usually B-trees, that turn a full scan into a quick lookup at the cost of slower writes.
- Query planning: the engine chooses how to run a query; reading its plan explains why it is slow.
- Durability and replication: a write-ahead log survives a crash, and copies on other machines survive a lost one.
Vocabulary
- Schema: the declared structure of the data, its names, types and constraints.
- Normalisation: organising tables so each fact is stored once.
- Isolation level: how far concurrent transactions are kept from seeing each other's changes.
- Primary key: the value that uniquely identifies a row.
What to study, in order
- Install a relational database and model a small domain, such as a library, in tables.
- Learn SQL well: selects, joins, grouping, inserts, updates and constraints.
- Create an index, read the query plan before and after, and measure the difference.
- Write two concurrent transactions that conflict and see what each isolation level allows.
- Read how a write-ahead log and a B-tree work, then restore a database from a backup.
- Compare the same problem in a document store and say what you gained and lost.