Skip to content

Build a Database from Scratch

Build a fully functional relational database engine from the ground up. You'll implement a SQL parser, B-tree index, page-based storage, write-ahead log, ACID transactions, and a query planner — the same architecture used by SQLite, PostgreSQL, and MySQL. By the end, you'll understand exactly how every database you've ever used works internally.

advanced34 lessons9 chapters34 graded exercisesPython

No sign-up needed for lesson 1 · certificate on completion · sign up to save progress

What you’ll have built

Chapter by chapter. Every step is a graded exercise.

  • SQL Tokenizer & Parser
  • In-Memory Storage
  • B-Tree Index
  • Page-Based Storage
  • Write-Ahead Log
  • Transactions & ACID
  • Query Planner & Indexing
  • Advanced SQL
  • Join Algorithms
Starts in Python — solve in the language you choose in the editor, same tests either way.

Curriculum

9 chapters, 34 lessons. Each lesson is a short read, one graded exercise, and a quiz.

  1. 1SQL Tokenizer — Breaking SQL into TokensRead · exercise · quiz
  2. 2CREATE TABLE — Defining SchemaRead · exercise · quiz
  3. 3INSERT INTO — Adding RowsRead · exercise · quiz
  4. 4SELECT with WHERE — Querying DataRead · exercise · quiz
Loading reference solution…
Build a Database from Scratch