The “Build Your Own Database” book is finished

James Smith


01. Why Database?

Databases are a fascinating topic. They are a foundation of modern computing. Learning how they work should be an important part of software engineering education.

As many of today’s (2023+) coders do not have a formal CS/SE education, basic things such as databases, compilers, operating systems, etc. are often seen as magical black boxes. That’s why I started the “Build Your Own X” book series. To learn and teach the basics in a “from scratch” approach, through succinct & condensed books.

There are some important topics that we can learn from database systems:

  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.

02. The Book

As with my other books, this book follows the step-by-step approach while covering the 3 topics above. We start from a B-tree, then to a KV store, finally to a mini database with a SQL-like query language.

The book is divided into 2 parts. Part I implements a KV store. Part II implements a mini database and a query language based on the KV store from Part I.

Part I is self-contained and can be used as a standalone book for persistent KV stores, it is also freely available online.

The whole book is available as paperback or ebook.

Welcome to build-your-own.org.

A website for free educational software development materials.


for updates and new books.

Book Cover

Read the book “Build Your Own Redis” online.

Learn network programming and data structures.

By build stuff from scratch.

With straightforward C/C++ code.

Book Cover

Read the book “Build Your Own Database” online.

Learn 3 important database topics:

  • Persistence.
  • Indexing.
  • Concurrency.
Book Cover

New book:
“From Source Code To Machine Code”

Build your own compiler from scatch. Topics covered:

  • Interpreters.
  • Compilers.
  • x64 assembly.