# Database normalization

> Organizing tables so each fact is stored in exactly one place.

- Level: Intermediate
- Topics: Data
- URL: https://tidbit.legios.com.ar/database-normalization/
- In Spanish: [Normalización de bases de datos](https://tidbit.legios.com.ar/es/database-normalization/)

**Database normalization** is a way of designing the tables of a relational database so that each piece of information lives in one place only. Imagine an orders table where every row repeats the customer's name, email and address. If the customer moves, you must update fifty rows, and if you miss one, the database now disagrees with itself.

Normalizing splits that table in two: a customers table with each customer once, and an orders table that only stores the customer's id, a foreign key pointing to the customers table. To see orders with addresses, you join them back in a query. The rules for how far to split are called **normal forms**; in practice most designs aim for the **third normal form** (3NF), which roughly means every column depends on the row's key and nothing else.

Normalization suits systems that write a lot, like a shop's order system, because each update touches one row and data stays consistent. Analytics goes the other way: data warehouses often **denormalize** on purpose, repeating data into wide tables or a star schema so reports need fewer joins and run faster. Both are deliberate choices, not right and wrong.

## An analogy

Like keeping a friend's address in your phone's contacts instead of writing it on every birthday reminder. When they move, you change it once and every reminder is right.

## Keep in mind

- Each fact is stored once; other tables point to it with keys.
- Avoids contradictions when data is updated.
- Most designs aim for third normal form (3NF).
- Analytics often denormalizes on purpose for faster reads.

## Go deeper

- [Database normalization on Wikipedia](https://en.wikipedia.org/wiki/Database_normalization)

## Related terms

- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
- [Primary and foreign keys](https://tidbit.legios.com.ar/primary-and-foreign-keys/): A primary key names each row uniquely; a foreign key points to a row in another table.
- [Data warehouse](https://tidbit.legios.com.ar/data-warehouse/): A database built for analysis: years of history, from many sources, in one place.
- [Star schema](https://tidbit.legios.com.ar/star-schema/): A data warehouse layout: one table of events in the middle, descriptive tables around it.
