Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 07 · From Scratch · Database · with code: Go · about 27 min to read

Play it as a journeyTutor comes with a plan

Capstone: Database, Everything

Everything
Everything · Open board

The finale of the small database this series built, tying together every earlier piece with the project lesson Build Your Own Database, From Scratch.

Before you start. This series has been building a small database of our own: a program that stores rows on disk, finds one fast, and survives a crash without losing or corrupting a row. By now our small database can do all of this:

  • Write every change to the end of a file, and never edit a line already there.
  • Jump straight to a key instead of reading the whole file, using a small lookup kept apart from it.
  • Pack rows into fixed-size chunks called pages, so one trip to the disk always moves a whole chunk at once.
  • Walk down a small number of signposts to find any key among hundreds of thousands, instead of checking each one.
  • Write down a change before touching the real data, so a crash mid-write can be undone or finished cleanly.
  • Keep an old and a new copy of a changed row side by side, so two readers can see two different, both-correct answers.
  • Read a question typed in plain words, like a front desk reading a request slip, and work out which rooms to send it through.

Lesson 53 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1986: the database that refused to keep a log
  • The moment it clicked: seven rooms, one building
  • The front desk decides: walk straight there, or check every room
  • The shortcut turns out to be a tree of signposts
  • The address points at a box, not a shelf of loose paper
  • Nothing in the box gets crossed out
  • But first, the office writes it down
  • And the logbook is the plainest thing in the building
  • Seven views of one program
  • Four ideas, compressed
  • What a symptom tells you
  • What a real engine adds
  • Run the whole thing
  • Check every stage
  • Where next

Terms it explains: index, B-tree, page, write-ahead log, CRASH, CMU 15-445 / 15-721, file format, PostgreSQL docs.

Review From Scratch