Type `SELECT ... JOIN ... GROUP BY ...` and a database answers in milliseconds — but *how*? Build the engine yourself, in TypeScript, from a SQL parser to a B+Tree to hash joins. Over 16 milestones, the black box becomes glass.
You write SQL every day. SELECT, JOIN, GROUP BY, ORDER BY — you add an index when a query is slow, you puzzle over why a NULL row vanished from your results. But the engine that turns that text into answers is a black box. This project pries it open: over 16 test-driven milestones you build a real relational database from scratch in TypeScript — and never read EXPLAIN the same way again.
You start at the front door: a hand-written lexer that scans SQL into tokens, a Pratt parser that climbs operator precedence so 1 + 2 * 3 groups correctly, and a recursive-descent statement parser that turns the whole grammar into an AST. Then you build storage — and meet the idea that humbles every database engineer: SQL's three-valued logic, where NULL = NULL is not true but unknown. You build a typed value system, a catalog, a heap row store with stable rowids, and a tree-walking evaluator that runs an expression against a single row.
Next the engine comes alive. Using the Volcano iterator model — the same open/next/close operators PostgreSQL uses — you assemble scans, filters, and projection into a tree and drain real SELECTs through it. Then you make it fast: a real B+Tree with node splitting and linked leaves, range scans, and a planner smart enough to pick an index over a full scan. The final stretch is the hard tail of SQL — a pipeline-breaking Sort, a hash-aggregate for GROUP BY, nested-loop and hash joins, and UPDATE/DELETE that keep every index in sync — capped by an end-to-end capstone.
Every milestone is graded by real test suites and composes into one engine that runs SELECT users.name, SUM(orders.amount) FROM users INNER JOIN orders ON users.id = orders.user_id GROUP BY users.name ORDER BY 2 DESC. By the end you won't just use a database — you'll know, layer by layer, exactly how one parses, plans, indexes, and executes a query.