build-your-own.org > Books > Build Your Own Database From Scratch in Go
EBook·Paperback
⟵ prev Contents next ⟶

🔥 My other Book: Build Your Own Redis

Build Your Own Database From Scratch in Go

From B+Tree To SQL

James Smith

Introduction

Understand databases from the bottom up by building your own, in small steps, and with simple Golang code.

  1. Start with a B+tree, the data structure for querying and manipulating the data.
  2. Make it durable, that’s what makes a DB different from a file.
  3. Relational DB with concurrent transactions on top of the copy-on-write B+tree KV.
  4. A SQL-like query language, the finishing touch.

Contents

Part I: Simple KV Store

(Self-contained, free-to-read web version.)

  1. Introduction
  2. From Files To Databases
  3. Indexing Data Structures
  4. B-Tree Principles
  5. Code a B+Tree (Part I)
  6. Code a B+Tree (Part II)
  7. Append-Only KV Store
  8. Free List: Reusing Pages

Part II: Mini Relational DB

(Included in the ebook and paperback editions.)

  1. Rows and Columns
  2. Range Query
  3. Secondary Index
  4. Atomic Transactions
  5. Concurrent Readers and Writers
  6. Query Language: Parser
  7. Query Language: Execution

PDF/EPUB and Paperback Editions

The full book is available for purchase.

I have curated a list of books that will further your understanding.

Database Internals by Alex Petrov.
[Amazon] [Web]
Many database books are either very academic, or talk about topics from a high level, few books go down to the practical side and examine databases in detail. Alex’s brilliant book not only explores the details and different approaches to storage engines, but is also a great introduction to distributed systems.
Designing Data-Intensive Applications by Martin Kleppmann.
[Amazon] [Web]
This classic book is not just about databases, but covers a much broader range of topics, especially about distributed systems. It explains topics using real-world systems and is universally recommended for software developers.
The Go Programming Language by Brian W. Kernighan.
[Amazon] [Web]
While you can follow this project and code your own DB in any language you like. Golang is still a solid choice. Coding something from scratch often involves some low-level stuff and interacting with the OS, which is traditionally done in C/C++. Golang is incredible because of its balance between system and application programming. You can pick up Golang quickly with this book by Brian W. Kernighan, the same “K” who wrote the classic “K&R”.

( Report an Error | Ask a Question) @ build-your-own.org

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

⟵ prev Contents next ⟶