Build your own Database
A small relational database: a REPL, an on-disk page format, a B+tree index, a SQL subset and crash-safe writes.
- Advanced
- About 30–60 h
- 5 checkpoints
- 4 tutorials · Go, C, Python
Pick a tutorial, then check yourself at each checkpoint. Work in any language you like.
Choose a tutorialWhy build it
Query plans, indexes and isolation levels become concrete once you have stored rows in pages and searched a B+tree yourself.
You will be able to
- Store rows in fixed-size pages and persist them to a file.
- Implement a B+tree for key lookups and range scans.
- Parse and execute a small SQL subset.
- Make writes atomic with a journal or copy-on-write, and state which isolation you provide.
Skills it exercises
- SQL Fundamentals
- Indexing & Query Optimization
- Transactions & Isolation
- File Systems
- Binary Search Trees
- Data Store Selection
Recommended on Backend Engineer and Data Engineer.
How you know you are there
Work in any language. Each checkpoint ends with something you can run or observe, so you can check it yourself.
- Checkpoint 1Self-check
REPL
Done when:
insert 1 ada [email protected]andselectwork in a REPL with errors for bad input, and tests drive the REPL as a subprocess. - Checkpoint 2Self-check
Persistence
Done when: Rows survive closing and reopening the database file, stored in fixed-size pages through a pager.
- Checkpoint 3Self-check
B+tree
Done when: Lookups use a B+tree that splits leaf and internal nodes; a test inserts 10,000 keys in random order and reads them back sorted.
- Checkpoint 4Self-check
SQL subset
Done when: CREATE TABLE, INSERT and SELECT with a WHERE range work, and a log line or EXPLAIN shows when the index is used.
- Checkpoint 5Self-check
Crash safety
Done when: Killing the process mid-write never corrupts the file: a crash test always finds either the old or the new data.
Stretch goals
- Secondary indexes.
- Concurrent readers with one writer.
- A free list that reuses deleted pages.
Step-by-step guides
Pick one in a language you know (tutorial languages: Go, C, Python). They open on the author’s site.
- C
Let's Build a Simple Database(external site)
C: a SQLite clone with a REPL, a pager and a B-tree. It stops before SQL parsing.
- Go
Build Your Own Database from Scratch: From B+Tree To SQL in 3000 Lines(external site)
Go book: B+tree, copy-on-write durability, tables, indexes, a query language and transactions.
- Go
Code a database in 45 steps: a series of test-driven small coding puzzles(external site)
Go: 45 small, test-driven steps.
- Python
DBDB: Dog Bed Database(external site)
Python: an immutable binary tree with atomic commits.
Practice builds are self-paced: Tech Atlas does not track them or count them as evidence. To show a skill, take its knowledge check from the skill page.
Tutorials come from codecrafters-io/build-your-own-x (CC0, snapshot of 2026-07-14, commit aa17439; links checked on 2026-10-19). Each tutorial belongs to its author and keeps its own licence; Tech Atlas links to it and does not host it. Briefs, checkpoints and the mapping to skills are Tech Atlas editorial drafts.