databases/why-databases-split-your-data-into-two-tables-and-link-them-by-id.md

Why databases split your data into two tables (and link them by id)

Databases · 10 min read ·

A database table looks like a spreadsheet: columns for each kind of information, one row per thing. But it comes with rules. Every column has a data type, and every row gets a primary key, an id that is never empty and never repeated.

The real trick is splitting data. Keep customers and orders in one big sheet and the same email ends up copied everywhere, so one missed edit makes the table contradict itself. Store each fact once, link tables with a foreign key, and change an email in exactly one place.