Databases — learning path
A chapter-by-chapter path through database engineering: from how a page is laid out on disk to running a sharded, replicated, multi-tenant system. Every chapter is a complete reference in its own right (definitions, two-session timelines, per-engine behaviour, Go and Laravel code, a lab, a glossary), but the order below is the order the ideas build on each other.
How to use
- Read the chapters in order; each one assumes the ones before it.
- Open the Everything in one minute tables first, then the concept blocks, then the lab.
- Run the lab. Every chapter has one; most need only
psqlormysqlin two terminals. - Finish with Self-check. If you cannot answer a question, the answer links back to the section.
- The Cheatsheets section is the quick reference once you know the concepts.
Legend
| Badge | Meaning |
|---|---|
| Must-know | asked in almost every interview; you meet it at work constantly |
| Important | frequent; expected at senior level |
| Good to know | extra depth that sets you apart |
| WIP / Todo | shown next to a chapter only while it is still being written |
How to read this page. Groups are in reading order and each one builds on the previous; short on time, take the Must-know chapters of every group first. The last column says in one line what the chapter gives you. Every chapter ends with a Self-check: questions & answers block (open/close all, filter by level); all questions are collected in the Interview Q&A hub.
Chapters
51 chapters · 46 complete · 5 not written yet
Foundations
| Chapter | Level | What you learn |
|---|---|---|
| SQL Querying Fundamentals | Must-know | SQL describes the rows you want, not the steps to get them; it works on relations (sets of rows) with three-valued logic, and most "SQL bugs" are a NULL… |
| Advanced SQL Todo | Important | to be written. |
| Database Internals | Important | how a row really sits on disk and in memory: pages, the heap, tuple headers, ctid, TOAST, the free space and visibility maps, and why the database always moves whole pages. |
| ACID & Transactions | Must-know | A transaction is a group of operations that the database treats as one unit; ACID names the four promises that unit makes (all-or-nothing, rule-respecting, unseen-while-running, survives-a-crash). |
| Isolation Levels | Must-know | Isolation levels are the dial between correctness and throughput: each level forbids a set of anomalies, and each engine implements the names differently. |
| MVCC, VACUUM & Bloat in PostgreSQL | Must-know | PostgreSQL never overwrites a row; it writes a new tuple version and leaves the old one for VACUUM, so transaction length becomes disk space… |
| Locks & Concurrency Control | Must-know | every database lets many transactions run at once, and locks are the main tool it uses to stop them corrupting each other's work. |
| Deadlocks | Important | A deadlock is a cycle of transactions that each wait for a lock the next one holds. |
| Optimistic vs Pessimistic Locking | Must-know | Two answers to "two writers want one row": lock first and make the others wait (pessimistic), or let everyone run, check at write time that nothing moved, and retry the loser (optimistic). |
Indexing & Storage
| Chapter | Level | What you learn |
|---|---|---|
| Indexing | Must-know | An index is a second, sorted (or hashed, or inverted) copy of some columns with pointers back to the rows; it makes some reads cheap and every write more expensive. |
| B-Tree vs B+Tree in Production Databases | Important | why databases index with page-sized, high-fan-out trees, how the original B-tree differs from the B+tree every major engine actually ships, and what page splits… |
| Storage Engines | Important | A storage engine decides how bytes sit on disk. |
| Query Planning, EXPLAIN & Join Algorithms | Must-know | The planner turns declarative SQL into a tree of physical operators by estimating row counts from statistics and ranking candidate plans by cost; almost every slow query is a wrong estimate… |
| Bloom Filters & Probabilistic Structures | Good to know | A Bloom filter answers "is this key in the set?" with "definitely not" or "probably yes", in about ten bits per key; its relatives count distinct items (HyperLogLog), frequencies… |
| Pagination | Must-know | OFFSET n makes the database produce and discard n rows, and a position-based page moves when rows are inserted; keyset (seek) pagination remembers the last row's sort key and asks for rows after it… |
| Cursors & Streaming Results | Important | A big result set must never be "loaded"; it must flow through the application in small pieces, and a cursor (or a driver's streaming mode) is the mechanism that makes it flow. |
| Working with Billion-Row Tables | Important | A table with a billion rows is not a different kind of table, it is the same table with every cost multiplied: a full scan, an index build, a VACUUM… |
Partitioning, Sharding & Scale
| Chapter | Level | What you learn |
|---|---|---|
| Partitioning & Sharding in PostgreSQL | Must-know | Partitioning splits one big table into smaller tables on the same server; sharding splits the data across servers. |
| Consistent Hashing | Important | Consistent hashing places keys and nodes on the same circle of hash values so that adding or removing a node moves only the keys next to it… |
| Storage & Data Scaling | Must-know | Scaling a data layer is a ladder of nine steps ordered by cost and reversibility; you climb one rung only when a measurement says the current rung is out of room. |
| Distributed SQL, Consensus & 2PC | Good to know | Atomic commit (2PC) makes several machines agree on one transaction; consensus (Paxos, Raft, Zab) makes several copies agree on every write; distributed SQL (Spanner, CockroachDB, TiDB… |
| OLTP vs OLAP & Columnar Storage | Important | Transactions and analytics are two different workload shapes; row stores serve the first, column stores the second, and most real systems need both with a pipe between them. |
Replication & Durability
| Chapter | Level | What you learn |
|---|---|---|
| Replication, Read Replicas & Failover | Must-know | Replication copies every committed change from one server to others; the copies give you read capacity and a standby to fail over to, at the price of lag, stale reads and a hard decision about who is primary. |
| Durability, WAL & Crash Recovery | Important | A commit is durable when its log record is on stable media, not when the table changes are; everything else (checkpoints, full-page writes, checksums, replicas) exists to make that log usable after a crash. |
| Backup, PITR & Disaster Recovery | Important | A backup is only real once you have restored it; point-in-time recovery turns a base backup plus an unbroken WAL archive into any minute you choose, and disaster recovery adds distance… |
| Eventual Consistency in Database Systems | Important | As soon as a database keeps more than one copy of your data, a read can return an older value than the last write; consistency models name exactly how old, for whom, and in what order. |
Design & Operations
| Chapter | Level | What you learn |
|---|---|---|
| Database System Design | Must-know | Database design is a method, not a favourite product: requirements become access patterns, access patterns become numbers, and the numbers pick the model, the scale rung and the consistency level. |
| Schema Design, Normalization & Data Types | Must-know | A schema is a set of promises the database enforces against every writer: each fact stored once (normalization), each value of the right type, each rule a constraint. |
| Zero-Downtime Schema Migrations | Must-know | A migration is a lock request first and a change second; zero downtime comes from short, bounded, individually compatible steps, not from a clever single statement. |
| Connection Pooling | Must-know | A database connection is an expensive, scarce resource; pooling lends a small, fixed set of them to many callers, and the right number is far smaller than people expect. |
| ORM Pitfalls | Must-know | An ORM turns relationships into properties and writes into method calls, and every one of those hides SQL: the pitfalls are the statements you did not know were sent, the rows you did not know were loaded… |
| Multi-Tenancy Strategies | Important | Multi-tenancy is the decision about how much of the stack each customer gets: a row, a schema, a database or a whole pod, and every step trades cost against isolation. |
| ID Generation at Scale | Important | An ID generator is a choice between four things that pull against each other: uniqueness without coordination, size, order, and what the value reveals when it leaves your system. |
| Database Observability | Important | Database observability is three signals (metrics, logs, traces) read from two sides (the server's own statistics and the application's view)… |
| Database Security | Important | A database is attacked from four directions (the internet, your own application, your own staff, and copies of its files), and each direction has its own control: network and authentication… |
| Encryption at Rest, in Transit & in Use (TDE,… | Good to know | Encryption protects data in three states (at rest, in transit, in use), and every layer defeats a different attacker: a stolen disk, a sniffed network, a curious DBA, a memory dump or the cloud provider itself. |
| Functions, Procedures & Triggers Todo | Important | to be written. |
| PostgreSQL Configuration & Tuning Todo | Important | to be written. |
| PostgreSQL Installation & Upgrades Todo | Important | to be written. |
Engines & Products
| Chapter | Level | What you learn |
|---|---|---|
| PostgreSQL & Database Fundamentals | Must-know | PostgreSQL is one supervisor process that forks a worker process per connection, shares one memory segment and one data directory, and describes itself in ordinary catalog tables. |
| MySQL Storage Engines | Important | MySQL separates the SQL layer from pluggable storage engines; InnoDB is the transactional default (clustered index, buffer pool, redo and undo, doublewrite, row locks) while MyISAM… |
| SQLite in Depth | Good to know | SQLite is a real, fully transactional SQL database that lives inside your process as a library and stores everything in one file; it gives up client/server networking and concurrent writers… |
| NoSQL | Must-know | NoSQL is not one technology but a set of families, each trading part of what a relational database promises for a data model shaped around one access pattern. |
| Redis | Must-know | Redis is an in-memory data structure server that runs every command one at a time on one main thread; that single fact explains its speed, its atomicity and almost every production incident it causes. |
| MongoDB in Depth | Important | MongoDB stores BSON documents, scales reads with replica sets and writes with sharding, and gives you per-operation dials for durability and consistency… |
| Wide-Column & Key-Value at Scale | Good to know | Wide-column and key-value stores give up joins and ad-hoc queries so that every request names its partition, which lets data, writes and availability scale past one machine. |
| Cassandra & ScyllaDB in Depth | Good to know | Cassandra and ScyllaDB are masterless, partitioned, replicated wide-column databases that trade joins and multi-row transactions for writes that never stop and a data model built around the query. |
| Graph Databases | Good to know | A graph database stores things and the typed, directed connections between them as first-class data, so "who is connected to whom, through what… |
| Full-Text Search | Important | Full-text search finds documents by the words they contain, ranks them, and tolerates inflection and (in some engines) typos, by looking words up in an inverted index instead of scanning text. |
| Vector Search & pgvector | Good to know | Vector search finds the rows whose embeddings are nearest to a query embedding; exact search is always right and slow, approximate indexes (HNSW, IVFFlat, DiskANN) are fast and can miss a neighbour… |
| Time-Series Databases Todo | Good to know | to be written. |