Databases, from the ground up#

This is the guide I wish someone had handed me before my first “design the schema” interview question. It goes from “what even is a database” to why your production Postgres instance falls over at 3am, and it tries not to skip the boring-but-important parts in between.

Each topic below is its own page. Use the menu on the left, or browse by section here.

Start here#

What’s a database, really

Strip away the buzzwords and a database is just an organized pile of information kept somewhere it won’t…

what-is-a-database
What a DBMS is actually doing all day

A DBMS earns its keep by doing a handful of unglamorous jobs, constantly, without you noticing. When you…

what-is-a-dbms
Why not just use files?

You genuinely can build a system on flat files, CSVs, JSON blobs, whatever. Plenty of small tools do…

files-vs-dbms

Data models#

The five shapes data can take

Picking a data model is picking which questions will be easy to ask later and which will be painful…

data-models
“SQL vs. NoSQL” isn’t really the question

This gets framed as a rivalry, but it’s closer to comparing a screwdriver to a whole toolbox labeled “not”…

data-models

Under the hood#

ACID, unpacked

ACID gets recited like a magic word in interviews, but each letter is answering a specific, concrete fear…

under-the-hood
Normal forms, without the textbook language

Normalization is really just “don’t write the same fact in two places.” If a customer’s address changes,…

under-the-hood
Indexes: the whole reason queries aren’t slow

Without an index, finding a row means the database checks every single one, a full table scan. On a table…

under-the-hood
Transactions and what happens when two writes collide

A transaction is a group of operations that either all succeed or all fail together, you saw the “A” in…

under-the-hood
The CAP theorem, in one paragraph

Once a database is spread across more than one machine, the network between those machines will eventually…

under-the-hood

At scale#

Replication: copies for safety and speed

A replica is a second copy of your database that stays in sync with the original, usually by streaming the…

at-scale
Sharding: when one machine isn’t enough, period

Replication copies the same data everywhere. Sharding does the opposite, it splits the data itself across…

at-scale

Reference#

Popular systems, and where they actually shine

None of these “win” outright, each was built with a specific set of trade-offs in mind, and the honest…

reference
Glossary

Key terms used throughout this guide.

reference