Unbundling the Database

The idea of treating a whole data platform as one database taken apart: an ordered log of writes at the center, and each index, cache and warehouse built from it as derived data.

Overview

A database is several tools in one box

A single relational database does many jobs. It stores rows durably, keeps secondary indexes, answers full-text search, maintains materialized views, replicates to followers and runs triggers. Inside the box, one piece of machinery keeps all of those in step: every change goes into the database's log first, and everything else is derived from that log.

Once a system outgrows one box, teams add specialized tools: a search engine, a cache, a warehouse, a stream processor. Each one does its job better than the general database, but now the machinery that keeps everything in step is gone. Unbundling the database means rebuilding that machinery across the tools: an ordered log of changes in the middle, and each tool built from it.

Each feature inside the box has an unbundled equivalent outside it.

  • Write-ahead log: becomes a durable, ordered event log, for example Kafka.
  • Secondary index: becomes a search engine or key-value store built from the log.
  • Materialized view: becomes a table kept up to date by a stream processor.
  • Replication to followers: becomes consumers that each keep their own copy.
  • Trigger: becomes a consumer that reacts to each change.
  • The query planner choosing an index: becomes your code choosing which store to read.

Key concepts

  • Unbundled database
  • System of record
  • Derived data
  • Ordered log
  • Materialized view
  • Federation
  • Write path and read path

Interview questions

  • How would you design the data layer for a social app that needs profiles, a feed, search and analytics?
  • Why keep derived stores in step through a log instead of writing to each one from the application?
  • When is a single database the better choice?

Sign up free to read the full topic

More DDIA topics

Start free on Cariara · Coding problems · System design studio