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.

Your path through Database Engineering

0 of 22 Foundation lessons done
0 of 78 lessons done overall
Start: What a Database Actually Is →

Then follow the stages in order

Each stage builds on the ones before it. Labs and simulators sit right after the lessons they exercise. Open a stage to see its lessons. Full roadmap with goals →

  1. Foundations0 of 1 lessons done
    1. What a Database Actually IsFoundation≈ 10 min
  2. SQL0 of 5 lessons done
    1. SELECT, FROM, WHERE, ORDER BY, LIMITFoundation≈ 10 min
    2. Aggregation: COUNT, SUM, AVG, GROUP BY, HAVINGFoundation≈ 5 min
    3. Joins: INNER, LEFT, RIGHT, FULL, CROSS, SELFFoundation≈ 5 min
    4. Subqueries, CTEs, EXISTS, UNION, CASEFoundation≈ 5 min
    5. Window FunctionsFoundation≈ 5 min
  3. Data Modeling0 of 4 lessons done
    1. From Requirements to TablesFoundation≈ 5 min
    2. Relationships, Keys and ConstraintsFoundation≈ 5 min
    3. Normalization: 1NF to BCNFFoundation≈ 5 min
    4. Denormalization on PurposeFoundation≈ 5 min
  4. Indexes0 of 4 lessons done
    1. Why Is This Query Slow? IndexesFoundation≈ 5 min
    2. Composite Indexes and the Leftmost-Prefix RuleFoundation≈ 5 min
    3. Index Types: B-tree, Hash, Partial, Expression, Covering, Full-TextFoundation≈ 5 min
    4. Should I Add an Index?Foundation≈ 5 min
  5. Query Execution & Optimization0 of 3 lessons done
    1. How a Query Executes: Planner and ExecutorFoundation≈ 5 min
    2. Reading EXPLAIN ANALYZEFoundation≈ 5 min
    3. Query Optimization: Finding the Actual BottleneckFoundation≈ 5 min
  6. Transactions & Concurrency0 of 5 lessons done
    1. Transactions and ACIDFoundation≈ 5 min
    2. Concurrency AnomaliesFoundation≈ 5 min
    3. Isolation LevelsFoundation≈ 5 min
    4. MVCC: Multi-Version Concurrency ControlFoundation≈ 5 min
    5. Locks and DeadlocksFoundation≈ 5 min
  7. PostgreSQL0 of 3 lessons done
    1. PostgreSQL: Tables, Types and the CatalogIntermediate≈ 5 min
    2. JSONB, Full-Text Search and ExtensionsIntermediate≈ 5 min
    3. PostgreSQL in Production: Connections, VACUUM, Partitioning, ReplicationIntermediate≈ 5 min
  8. Caching, Redis & NoSQL0 of 6 lessons done
    1. Redis: Data Structures, Not a CacheIntermediate≈ 5 min
    2. Caching PatternsIntermediate≈ 5 min
    3. Cache Invalidation, Stampedes and Hot KeysIntermediate≈ 5 min
    4. SQL vs NoSQL: Choosing a Data ModelIntermediate≈ 5 min
    5. Document Databases: Embed or ReferenceIntermediate≈ 5 min
    6. Wide-Column, Graph, Search and Time-SeriesIntermediate≈ 5 min
  9. Vector Databases0 of 1 lessons done
    1. Vector Search: Embeddings, Similarity and ANNIntermediate≈ 5 min
  10. Scaling & Distributed Databases0 of 4 lessons done
    1. Scaling from One User to MillionsIntermediate≈ 5 min
    2. Replication and Read ScalingIntermediate≈ 5 min
    3. Partitioning and ShardingIntermediate≈ 5 min
    4. Distributed Consistency: CAP, Quorums, ConsensusIntermediate≈ 5 min
  11. Internals · Storage & Pages0 of 4 lessons done
    1. How Is Database Data Physically Stored?Intermediate≈ 15 min
    2. Records on DiskIntermediate≈ 15 min
    3. Pages: The Unit of EverythingIntermediate≈ 15 min
    4. Slotted PagesIntermediate≈ 20 min
  12. Internals · B+ Trees0 of 5 lessons done
    1. Sequential Scan, Page by PageIntermediate≈ 10 min
    2. The Index, Derived from First PrinciplesIntermediate≈ 10 min
    3. B+ Tree Internals: Pages, Splits, MergesIntermediate≈ 20 min
    4. Why B+ Trees: Fanout, Not Big-OIntermediate≈ 15 min
    5. Hash Index InternalsIntermediate≈ 15 min
  13. Internals · Buffer Pool, WAL & Recovery0 of 6 lessons done
    1. The Buffer PoolAdvanced≈ 20 min
    2. Buffer Replacement: LRU, Clock and Scan ResistanceAdvanced≈ 20 min
    3. Follow a Read Through the EngineAdvanced≈ 15 min
    4. Follow a Write Through the EngineAdvanced≈ 15 min
    5. Write-Ahead LoggingAdvanced≈ 20 min
    6. Crash RecoveryAdvanced≈ 15 min
  14. Internals · Transactions & MVCC0 of 7 lessons done
    1. A Transaction, Inside the EngineAdvanced≈ 15 min
    2. Concurrency Control: Schedules and SerializabilityAdvanced≈ 15 min
    3. The Lock ManagerAdvanced≈ 15 min
    4. Deadlock Detection: The Waits-For GraphAdvanced≈ 15 min
    5. MVCC Internals: Version Chains and SnapshotsAdvanced≈ 15 min
    6. UPDATE, DELETE and Dead TuplesAdvanced≈ 20 min
    7. Isolation Levels: The Mechanism Behind EachAdvanced≈ 20 min
  15. Internals · Query Engine0 of 6 lessons done
    1. Inside the Query EngineAdvanced≈ 15 min
    2. Tokens, Parse Tree, ASTAdvanced≈ 15 min
    3. The Planner: Enumerating Ways to AnswerAdvanced≈ 15 min
    4. Cost-Based OptimizationAdvanced≈ 15 min
    5. Join Algorithms: Nested Loop, Hash, MergeAdvanced≈ 15 min
    6. Follow the QueryAdvanced≈ 15 min
  16. Internals · LSM Trees0 of 6 lessons done
    1. LSM Trees: Why Some Engines Favour WritesAdvanced≈ 15 min
    2. SSTables: The Immutable Sorted FileAdvanced≈ 15 min
    3. Bloom Filters: Skipping Files That Cannot Contain the KeyAdvanced≈ 15 min
    4. Compaction: The Merge That Pays for Cheap WritesAdvanced≈ 15 min
    5. Write, Read and Space AmplificationAdvanced≈ 15 min
    6. Storage Engine Comparison: B+ Tree vs LSM TreeAdvanced≈ 15 min
  17. Internals · PostgreSQL & InnoDB0 of 3 lessons done
    1. PostgreSQL Internals: Heap, Tuples, Shared Buffers, WAL, VACUUMAdvanced≈ 20 min
    2. InnoDB Internals: Clustered Index, Buffer Pool, Redo, Undo, LocksAdvanced≈ 20 min
    3. Physical Layouts Compared: Heap + Secondary Index vs Clustered IndexAdvanced≈ 15 min
  18. Internals · Distributed & Performance0 of 5 lessons done
    1. Replication Internals: WAL Shipping, LSNs, Lag and FailoverAdvanced≈ 20 min
    2. Partitioning Internals: Key → Partition Function → NodeAdvanced≈ 20 min
    3. Distributed Fundamentals: Partial Failure, Quorums, Consensus, RecoveryAdvanced≈ 20 min
    4. Performance Internals: Why the Slow Node Is SlowAdvanced≈ 15 min
    5. The Database Internals PlaygroundAdvanced≈ 15 min

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.