Database Engineering

What database, data model, index, query strategy and consistency model should I use — and why? Two layers: the practical layer teaches how to use databases correctly; the internals layer underneath derives why they behave that way — against a real SQL engine running in your browser.

The judgment we teach

Mirror of the DSA and Agentic chains: the skill is choosing how to store and reach the data, not memorising syntax.

  1. Data→
  2. Access Pattern→
  3. Data Model→
  4. Schema→
  5. Index→
  6. Query→
  7. Transaction→
  8. Consistency→
  9. Scale
The rule that matters most
Design from access patterns, not nouns; reach for the simplest thing that meets a measured requirement. Index → pool → replica → cache → partition → shard, and the first wall is almost always a missing index, not missing hardware.
Everything here runs
The playground, EXPLAIN reader, index labs and optimization scenarios execute against an in-browser SQL engine over 7 seeded databases. Add an index and watch the plan change — the numbers are real.

Start here

Two layers

Practical lessons answer how do I build with databases; internals lessons answer why do databases behave this way. They link to each other constantly — a learner can start at “why is this query slow?” and descend to storage reads.

Practical layer
SQL · Modeling · Indexes · Transactions · Query Optimization · PostgreSQL · Redis · NoSQL · Scaling

Every lesson here ends with “See how this works internally →”.

Internals layer
Records · Pages · B+ Trees · Buffer Pool · WAL · MVCC · Recovery · LSM Trees · Query Engine · Replication

Problem → naive solution → why it breaks → mechanism → trade-offs → real database. Includes Build AtlasDB and a crash button. →

Modules

0/78 lessons mastered
Database Fundamentals0/1
What a database actually is, what the engine does with your query, and where the data physically lives.
SQL0/5
From SELECT to window functions: filtering, aggregation, every join, subqueries, CTEs and the NULL rules that trip everyone up.
Relational Modeling0/2
Turning requirements into tables: entities, relationships, keys, constraints — and the access patterns that decide all of it.
Normalization & Denormalization0/2
1NF to BCNF as a cure for anomalies, then when duplicating data on purpose is the right answer.
Indexes0/4
B-trees, hash, composite, partial, covering, expression, full-text — what each can answer, and what an index costs.
Query Execution & Optimization0/3
Parser, planner, executor; scans and joins; reading EXPLAIN ANALYZE; finding the actual bottleneck.
Transactions0/1
ACID as four separate guarantees, what a rollback really undoes, and why the write-ahead log exists.
Concurrency & Isolation0/4
Lost updates, dirty reads, phantoms, write skew; isolation levels; MVCC; locks and deadlocks.
PostgreSQL0/3
The concrete implementation: types, JSONB, full-text search, extensions, partitioning, VACUUM, connection management.
Redis0/1
Not "a cache": strings, hashes, lists, sets, sorted sets, streams, TTL, pub/sub, atomic operations — and when not to use it.
NoSQL & Data Models0/3
Document, key-value, wide-column, graph, search, time-series, vector: what each model is actually good at.
Vector Databases & Retrieval0/1
Embeddings, cosine similarity, ANN and HNSW, metadata filtering, hybrid search — the storage layer under RAG.
Scaling0/1
One user to millions: connection pooling, read replicas, caching, partitioning, sharding — in that order.
Distributed Databases0/3
Replication, CAP without the slogans, quorums, consensus, leader election, and what a partition really costs you.
Caching0/2
Cache-aside, read-through, write-through, write-behind; TTL, eviction, invalidation, stampedes and hot keys.
internalsStorage, Records & Pages0/4
Bytes, records, fixed-size pages, slotted layouts: how a table physically exists on disk, and why the page is the unit of everything.
internalsIndex Internals0/5
From "read every page" to a page-oriented B+ tree: derive the index, watch splits and merges, and see why fanout beats Big-O.
internalsBuffer Management0/4
The page exists but reading it again is expensive: the buffer pool, hits and misses, dirty pages, pinning, LRU and Clock — then follow one read and one write through it.
internalsWAL & Recovery0/2
What survives if the machine dies after COMMIT: the write-ahead log, checkpoints, redo, undo and the restart sequence — with a crash button.
internalsTransactions & MVCC Internals0/7
What a transaction is inside the engine: lock tables, waits-for graphs, version chains, snapshots, dead tuples and the same workload under three isolation levels.
internalsLSM Trees0/6
The write-optimised alternative: memtables, SSTables, bloom filters, compaction, the three amplifications — and an honest B+ tree vs LSM comparison.
internalsQuery Engine0/6
Parser, AST, planner, cost model, join algorithms and the executor: follow one SQL statement from text to result through the real in-browser engine.
internalsPostgreSQL & InnoDB Internals0/3
The general mechanisms as two real engines implement them: heap tuples, xmin/xmax, shared buffers and VACUUM versus clustered primary keys, redo and undo logs.
internalsDistributed Internals0/3
How changes actually propagate: the replication stream, partition functions, quorums, leader election — and a failure simulator you can break.
internalsPerformance Internals0/2
Why is it slow, one layer down: page reads, buffer misses, scan choice, index maintenance, WAL, compaction — and one central simulator to turn the knobs.

Connected to the other domains

The same structures and systems, seen from the database side.