hacker tutorialscourse catalogue

Courses / Course 01 · Databases

Build a database

You end up withA durable key-value store you wrote, with a B+tree, crash recovery and transactions, a small SQL layer on top, and enough knowledge of PostgreSQL's internals to read its source.

  • 21 sources
  • 130 HN threads
  • 14,681 points
  • 2010–2026
  • 3–5 months part-time

Data pulled 2026-11-08 · time estimates are editorial

Why build one when an agent can write it for you? Because the next time your agent says “just add an index” or “wrap it in a transaction”, you’ll know what it’s really asking the disk to do. Hacker News has voted these tutorials up again and again for over a decade. Every step below shows its HN score and quotes what HN said.

How to read the receipts.

  • Points are summed across every HN submission of the same URL.
  • “Submitted N×” means HN rediscovered it N times.
  • Quotes come from the highest-ranked top-level comments in those threads, and a quote is sometimes a criticism.
  • Steps are ordered for learning, not by points.
  • Times are our estimates, not the authors’. They assume evenings and weekends, and a reader who already programs comfortably in at least one language. Expect to be faster or slower.

Stage 11–2 eveningsSee the shape

1.

Build your own database (interactive) (nan.fyi) · Nan Yu

547 points, submitted 1× (2025) · Free · ~1 hour

An animated walk from “append to a file” to indexes to log-structured merge trees. Do it first: it gives you the vocabulary for everything after.

HN skeptrune, 2025 · thread

“It’s a real test of how much you know to start anything from scratch.”

2.

How does a relational database work? (coding-geek.com) · Christophe Kalenzaga

575 points, submitted 2× (2015, 2019) · Free · ~3 hours

One long article covering the whole relational engine: query parser, optimizer, joins, buffer pool, locks, logging. Read it once, now, without trying to remember everything. You’ll come back to it.

HN jandrewrogers, 2015 · thread

“As complicated as they look from the article, it is just scratching the surface… there is probably more hardcore computer science per line of code than any other software system of similar scope.”

Stage 22–4 weekendsBuild a toy

3.

CaskDB: build a Bitcask-style key-value store (github.com) · Avinash Sajjanshetty

175 points, submitted 1× (2022) · Free · Python · ~1 weekend

The simplest durable database worth building: an append-only log on disk with an index in memory. The project comes with tests that guide each stage.

HN dandanua, 2022 · thread

“In short, keys are stored in a hash table in RAM, k/v pairs are written to log files. Dead simple, but powerful enough.”

HN pandemicsyn, 2022, on writing his first Bitcask in Go

“That whole experiment sent me on a different career trajectory.”

4.

Let’s Build a Simple Database (a SQLite clone in C) (cstack.github.io) · Connor Stack

2,017 points, submitted 18× (2017–2023) · Free · C · ~2 weekends

The most-resubmitted database tutorial on HN. You build a REPL, a pager, then an on-disk B-tree with node splitting.

HN lmilcin, 2019 · thread

“Writing a database is a good exercise I could recommend to everybody.”

Editor’s note: the series ends at Part 14, “Splitting Internal Nodes”. It has no deletes, no transactions and no crash recovery, and the author marks it “no longer under active development”. Part 15 points readers to CodeCrafters through a referral link. Step 6 picks up where it stops: deletes, crash recovery and the free list are all in the free part of that book. (Checked 2026-11-08.)

5.

Compare your toy with the real thing: SQLite internals

Free · ~1 evening each. Read them with your step-4 code open.

HN acqq, 2014

“I really appreciate how Julia Evans enjoys experimenting in programming… compared to so many practitioners who just read the books and often uncritically ‘believe’ the written texts.”

Also recommended in the Fly.io thread: SQLite’s own design documents, especially “Atomic Commit In SQLite” and “How To Corrupt An SQLite Database File”.

HN eis, 2022 · comment

“I recommend the excellent articles by the SQLite authors themselves … They go into the details of challenges SQLite faces due to how hardware and OSs work or not work and how they solve them.”

Stage 36–10 weeksBuild a real one

6.

Build Your Own Database From Scratch (build-your-own.org) · James Smith

1,144 points, submitted 7× (2023–2025) · Part I free online; Part II paid (ebook via Leanpub, or paperback) · Go · ~4–6 weeks

The core of the track. It comes in two parts:

  • Part I, free on the web: a copy-on-write B+tree with insertion and deletion, crash recovery with fsync, an append-only key-value store and a free list.
  • Part II, only in the paid editions: tables, range queries, secondary indexes, atomic transactions, concurrency control, and a SQL-like parser and executor.

The whole book comes to about 3,000 lines with no dependencies, according to the 2025 edition’s announcement (422 points on its own).

Free route to the endpoint: do Part I. Step 7 then gives you the SQL layer, and the concurrency-control part of step 11 covers transactions. Part II is the paid shortcut that does both in one codebase. (Terms checked 2026-11-08.)

HN myth_drannon, 2025, in the nan.fyi thread

“I also recommend this free online book to build a database.”

Alternatives HN suggested in these threads:

  • PingCAP’s talent-plan project 1, a Bitcask in Rust (vrnvu, 2025).
  • Sciore, Database Design and Implementation, described as the only book with “actual examples of building a system that processes SQL” (ccleve, 2019). It has never been submitted to HN as a story.
  • Mini-LSM · Alex Chi Z · https://skyzh.github.io/mini-lsm/ · 121 points, submitted 2× (2024) · Free · Rust. Take this one for the log-structured (LSM) route instead of a B+tree. “…these tutorials he’s been putting out are fantastic.” (moab, 2024 · thread). The caveat in the same thread: “the language is a bit stilted and has many small grammar errors” (jiggawatts).
7.

Writing a SQL database from scratch in Go (notes.eatonphil.com) · Phil Eaton

452 points, submitted 7× · Free · Go · ~2 weeks

A lexer, a parser, and an executor for CREATE, INSERT and SELECT … WHERE. This is the query-evaluation half that the storage tutorials skip.

HN zoom6628, 2020 · thread

“Probably the first article Ive ever read about lexical parsing with code that i have actually understood - and I dont even program in golang.”

8.

Side quest: Build Your Own Redis with C/C++ (build-your-own.org) · James Smith

802 points, submitted 3× · Free: the whole book is on the web; ebook and paperback optional (checked 2026-11-08) · C/C++ · ~2–3 weeks

This one covers networking rather than storage: sockets, an event loop, a hash table, sorted sets, TTLs.

HN rcarmo, 2023, who builds a mini-Redis in every new language · thread

”…Redis is the quintessential network service: By implementing it, you learn about socket handling, event loop for a specific runtime, threading models, data representation, concurrency…”

In Rust instead: Tokio’s mini-redis tutorial (https://tokio.rs/tokio/tutorial; 72 points, submitted 4×). One warning from its thread: “Rust async programming is a bad way to learn about Rust, and also is a bad way to learn about async programming.” (sanxiyn, 2020 · comment)

Stage 44–6 weeksRead a production engine

Warm-up (one evening): Following a Select Statement Through Postgres Internals (patshaughnessy.net) · Pat Shaughnessy

594 points, submitted 4× (2014–2019) · Free

One query traced through Postgres’s parser, analyzer, rewriter, planner and executor, all in the C source. Read it before step 9 so the big book has a skeleton to hang on.

HN codehusker, 2016 · thread

“He does a great job of combining high level explanations, visual aids, and gritty details.”

9.

The Internals of PostgreSQL (interdb.jp) · Hironobu Suzuki

2,367 points, submitted 17× (2017–2026) · Free · ~3–4 weeks

The highest-scoring database resource in the dataset. It covers how a real engine handles the things your toy skipped: heap pages, MVCC, vacuum, the planner, the WAL, replication.

HN chris_wot, 2019 · thread

“This is the thing I love about PostgreSQL, you can find out everything about the database.”

10.

How Postgres Makes Transactions Atomic (brandur.org) · Brandur Leach

658 points, submitted 4× · Free · ~1 evening

Follows a single transaction through the Postgres source, with diagrams.

HN pselbert, 2017 · thread

“This is precisely the kind of article I hope for when I browse the front page… It is clearly the product of a lot of effort and craft.”

11.

CMU 15-445/645: Intro to Database Systems (15445.courses.cs.cmu.edu) · Andy Pavlo

500 points, submitted 13× · Free lectures on YouTube · ~one semester, ~2 lectures a week

The university course that ties steps 3–10 together. It has projects (buffer pool, B+tree index, query execution) on the BusTub teaching database.

HN polskibus, 2018 · thread

“Andy Pavlo’s lectures are one of the best database internals resources available for free on the web.”

Stage 53–6 weeksGo distributed

12.

Implementing a distributed key-value store on top of Raft in Go (notes.eatonphil.com) · Phil Eaton

294 points, submitted 2× · Free · Go · ~2–3 weeks
HN Xeoncross, 2023 · thread

“These kinds of posts are my favorite part of HN… miles above the basic posts around the internet you get with searching – but not quite a full book yet.”

Next steps HN recommended in the same thread:

  • MIT 6.824’s Raft labs, free (bonobocop, 2025).
  • David Beazley’s “Rafting Trip”, a paid five-day course: “I have no financial or personal interest here; I just loved the course.” (cheeseprocedure, 2023)

The theory shelf (read alongside, not in sequence)

Book HN signal Cost Read it during
Designing Data-Intensive Applications · Martin Kleppmann 610 points over 6 submissions; named in 680 comments Paid book Stages 3–5
Database Internals · Alex Petrov 308 points over 2 submissions; named in 343 comments Paid book Stages 3–4
Readings in Database Systems (“Red Book”) · Bailis, Hellerstein, Stonebraker · http://www.redbook.io/ 857 points over 14 submissions (2015–2025) Free After Stage 4
Architecture of a Database System · Hellerstein, Stonebraker, Hamilton (2007) · https://dsf.berkeley.edu/papers/fntdb07-architecture.pdf 241 points over 14 submissions Free paper Stage 4
HN wenc, 2017, on DDIA

“It will not appeal to the absolute novice to be sure. But for anyone else who has worked on systems for moving data… this book will show you how things (probably stuff you’ve done bits of pieces of) fit together…”

HN chrisseaton, 2019, on Database Internals

“The depth of a text book with the approachability of a typical working programmer’s book.”

HN makmanalp, 2017, on the Red Book · comment

“I definitely wouldn’t approach this like I would approach a textbook: it’s definitely not meant to be friendly introductory material. That said, once you have a bit of background, it’s a goldmine of a survey.”

HN filereaper, 2016, in the Shaughnessy thread · comment

“I found this paper ‘Architecture of a Database System’ [1] to be an excellent starting point…”

Before you ship one

Never Write Your Own Database (medium.com) · Terry Crowley

445 points · Free · 15 minutes

Build one to learn. Don’t put one into production unless the database is the project.

HN tlb, 2018, adapting Akin’s laws of spacecraft design · comment

“…any software project that includes writing a database is, de facto, a database project.”

Editorial backlog

Checked against HN on 2026-11-08 (backlog_receipts.json). Not promoted:

  • Comer, “The Ubiquitous B-Tree” (1979): 6 points over 2 submissions. It’s a classic, but HN hasn’t voted for it. Add it only on editorial merit.
  • Sciore, Database Design and Implementation (SimpleDB): never submitted as a story, so it stays a comment-sourced alternative under step 6.

Promoted: the Red Book and “Architecture of a Database System” (theory shelf), Shaughnessy (Stage 4 warm-up), Mini-LSM (step 6 alternative) and Tokio mini-redis (step 8 alternative).

Method

  • Candidates came from 4,140 HN stories above 100 points matching tutorial-style title patterns, plus a database-specific topic pull: 332 database candidates in all.
  • Selection. The 21 resources here (16 core, plus 5 promoted from the backlog) were chosen by hand for followability and sequence. Points were then totalled across every submission of each URL.
  • Comment mentions are Algolia counts of comments containing the book title or domain.
  • Quotes come from the top five top-level comments of the two best-scoring threads per resource, in HN’s ranked order via the Firebase API. Some quotes are trimmed; links go to the full comment or thread.
  • Costs were checked on each site on 2026-11-08. Time estimates are editorial, not measured.
  • Data: tracks/databases/receipts.json (all resources cited above) and backlog_receipts.json (the backlog check). Scripts are in phase1-stories/scripts/.