Code a Database in 45 Steps

firephox2 pts0 comments

Code a database in 45 steps (Go)

Trial of Code<br>advanced coding puzzles

◄ prev<br>contents<br>next ►

Code a database in 45 steps (Go)

This series of test-driven small coding puzzles lets you code a database from scratch (no dependencies).

There are 45 puzzles, most puzzles are fewer than 50 lines of code, covering ALL major aspects of databases, including KV storage engines, LSM-Tree indexes, SQL, concurrent transactions, ACID , etc.

An accompanying book with detailed explanations and background info is available to aid your journey, allow you to dive deeper, or help you learn the subject without committing to the full project.

My goal is to transform advanced, complex topics into an accessible form so beginner or intermediate can advance to the next level. You can buy the book to fund my efforts.

This is the 1st Trial of Code project (2025). I plan to release more next year. Subscribe to get updates.

Table of contents

Database in 45 steps

Golang quick start

01: Log-based KV

0101: KV interfaces

0102: Serialization

0103: Log storage

0104: fsync

0105: Checksum

02: Tables

0201: Datatypes

0202: Schemas

0203: Update modes

0204: CRUD

03: Simple SQL

0301: Tokenizer

0302: Values

0303: SELECT

0304: Statements

0305: Execute SQL

04: Range query

0401: Sort & search

0402: Iterators

0403: Sort order

0404: Row iterator

0405: Range query

05: More SQL

0501: Infix ops

0502: Expr eval

0503: Precedence

0504: Expr parser

0505: Select expr

0506: WHERE

0507: SQL range

06: Log + data

0600: Atomic update

0601: Build SSTable

0602: Query SSTable

0603: Refactor code

0604: Merge sort

0605: Log + SSTable

07: LSM-Tree

0700: LSM-Tree intro

0701: Atomic store

0702: Store metadata

0703: Multi-levels

0704: Merge levels

08: Index

See the full book

09: Concurrency

See the full book

### 09: Concurrency

- 0901: Snapshot<br>- 0902: Conflicts<br>- 0903: Mutexes<br>- 0904: Channels -->

◄ prev<br>contents<br>next ►

Puzzles<br>Contact<br>About

© 2025 [email protected]>

code database puzzles steps next book

Related Articles