Idea · Aug 19, 2026
Build Your Own Database Engine
A structured multi-week assignment where students implement a minimal relational database from scratch: a B-tree storage engine, a SQL parser for a core subset of SQL, and a naive query optimizer. Students finish with a working database they can query from Python.
What it would do
Database textbooks describe B-trees, query planning, and the storage layer abstractly, but students rarely implement them. This assignment scaffolds the work into four weekly milestones: (1) a page-based file storage layer with a B-tree index, (2) a tokenizer and recursive-descent parser for SELECT, INSERT, UPDATE, and DELETE, (3) a table scan + index scan executor, and (4) a simple cost-based query optimizer that chooses between full-table scans and index lookups. Students test each layer with automated unit tests and a final integration test suite that runs real SQL queries. The project is language-agnostic but Python with no external DB libraries is recommended. Students come away having internalized how data actually reaches disk and why indexes matter, rather than treating the database as a black box.
Key features
- Page-based file storage layer with B-tree index implementation
- Recursive-descent SQL parser for SELECT, INSERT, UPDATE, DELETE
- Table scan and index scan query executor
- Naive cost-based query optimizer
- Automated unit + integration test harness students must pass