Build Your Own Database From Scratch PDF·EPUB·Paperback
⟵ prev Contents next ⟶

🆕 This chapter is part of the WIP book:
Build Your Own Database From Scratch

Subscribe to get notified of new chapters and the book's release.
🔥 My other Book: Build Your Own Redis

Build Your Own Database From Scratch

Persistence, Indexing, Concurrency

James Smith


Databases are not black boxes. Understand them by building your own from scratch!

This book contains a walk-through of a minimal persistent database implementation. The implementation is incremental. We start with a B-Tree, then add a new concept with each chapter, and eventually go from a simple KV to a mini relational DB.

Although the book is short and the implementation is minimal, it aims to cover three important topics:

  1. Persistence. How not to lose or corrupt your data. Recovering from a crash.
  2. Indexing. Efficiently querying and manipulating your data. (B-tree).
  3. Concurrency. How to handle multiple (large number of) clients. And transactions.


Part I: Simple KV Store (Completed)

  1. Introduction
  2. Files vs Databases
  3. Indexing
  4. B-Tree: The Ideas
  5. B-Tree: The Practice (Part I)
  6. B-Tree: The Practice (Part II)
  7. Persist to Disk
  8. Free List: Reusing Pages

Part II: Mini Relational DB (Work in Progress)

  1. Rows and Columns
  2. Range Query
  3. Secondary Index
  4. Transactions
  5. Concurrent Readers and Writers
  6. Query Language

Work in Progress…

Subscribe to be notified of new chapters and print releases.
[🔔 Subscribe]

Pre-order the ebook via Leanpub.
[🙂 Pre-Order]

Book Cover
See also: offers “Build Your Own X” courses in many programming languages.
Including Redis, Git, SQLite, Docker, and more.
Check it out

⟵ prev Contents next ⟶