Skip to content

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 ​

  1. Read the chapters in order; each one assumes the ones before it.
  2. Open the Everything in one minute tables first, then the concept blocks, then the lab.
  3. Run the lab. Every chapter has one; most need only psql or mysql in two terminals.
  4. Finish with Self-check. If you cannot answer a question, the answer links back to the section.
  5. The Cheatsheets section is the quick reference once you know the concepts.

Legend ​

BadgeMeaning
Must-knowasked in almost every interview; you meet it at work constantly
Importantfrequent; expected at senior level
Good to knowextra depth that sets you apart
WIP / Todoshown 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 ​

ChapterLevelWhat you learn
SQL Querying FundamentalsMust-knowSQL 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 TodoImportantto be written.
Database InternalsImportanthow 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 & TransactionsMust-knowA 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 LevelsMust-knowIsolation 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 PostgreSQLMust-knowPostgreSQL 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 ControlMust-knowevery database lets many transactions run at once, and locks are the main tool it uses to stop them corrupting each other's work.
DeadlocksImportantA deadlock is a cycle of transactions that each wait for a lock the next one holds.
Optimistic vs Pessimistic LockingMust-knowTwo 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 ​

ChapterLevelWhat you learn
IndexingMust-knowAn 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 DatabasesImportantwhy 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 EnginesImportantA storage engine decides how bytes sit on disk.
Query Planning, EXPLAIN & Join AlgorithmsMust-knowThe 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 StructuresGood to knowA 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…
PaginationMust-knowOFFSET 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 ResultsImportantA 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 TablesImportantA 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 ​

ChapterLevelWhat you learn
Partitioning & Sharding in PostgreSQLMust-knowPartitioning splits one big table into smaller tables on the same server; sharding splits the data across servers.
Consistent HashingImportantConsistent 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 ScalingMust-knowScaling 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 & 2PCGood to knowAtomic 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 StorageImportantTransactions 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 ​

ChapterLevelWhat you learn
Replication, Read Replicas & FailoverMust-knowReplication 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 RecoveryImportantA 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 RecoveryImportantA 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 SystemsImportantAs 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 ​

ChapterLevelWhat you learn
Database System DesignMust-knowDatabase 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 TypesMust-knowA 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 MigrationsMust-knowA 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 PoolingMust-knowA 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 PitfallsMust-knowAn 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 StrategiesImportantMulti-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 ScaleImportantAn 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 ObservabilityImportantDatabase observability is three signals (metrics, logs, traces) read from two sides (the server's own statistics and the application's view)…
Database SecurityImportantA 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 knowEncryption 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 TodoImportantto be written.
PostgreSQL Configuration & Tuning TodoImportantto be written.
PostgreSQL Installation & Upgrades TodoImportantto be written.

Engines & Products ​

ChapterLevelWhat you learn
PostgreSQL & Database FundamentalsMust-knowPostgreSQL 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 EnginesImportantMySQL 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 DepthGood to knowSQLite 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…
NoSQLMust-knowNoSQL 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.
RedisMust-knowRedis 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 DepthImportantMongoDB 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 ScaleGood to knowWide-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 DepthGood to knowCassandra 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 DatabasesGood to knowA 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 SearchImportantFull-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 & pgvectorGood to knowVector 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 TodoGood to knowto be written.

Built by Morteza Negahi