What is Normalization/Denormalization?
Normalization and denormalization, told as a story about writing shared info on just one warehouse shelf.
The same customer address is written on three receipts.If the customer moves, all three receipts need fixing.
Fixing only one receipt leaves the addresses disagreeing.This mismatch in one address is called an anomaly.
Normalization = write shared info on one shelf once.So when the customer moves, fixing that one address shelf is enough.
Normalization is easy to update; denormalization is fast to read.If tables get so fine-grained that joins pile up, merge them back.
Denormalization makes reads fast, but copies can drift apart.So copies need a rule that keeps them in step, plus concurrency control so simultaneous edits don't collide.
Normalization writes shared data in one place and links to it by key, removing duplication and anomalies. Denormalization deliberately re-merges frequently-read data for speed.
Normalization decomposes tables stepwise (1NF/2NF/3NF/BCNF) based on functional dependency analysis to remove insertion/update/deletion anomalies. Denormalization intentionally re-merges normalized tables for read performance. Real systems use both together.
When grown-ups say it
- Normalization
- Splitting shelves to remove duplication. Goes deeper from 1NF to 2NF to 3NF.
- Denormalization
- Re-merging frequently-viewed shelves. Faster reads, but duplication returns.
- Anomaly
- Receipts ending up with different addresses. Comes in insertion, update, and deletion kinds.
- Functional Dependency
- The rule that one tag fixes one shelf slot. The yardstick for each normal form.
- NoSQL Modeling
- A warehouse that freely changes shelf shape. Stores data to fit query patterns instead of normalizing. → the free-shelf warehouse
- Concurrency Control
- Rules that stop simultaneous receipt edits from colliding. Needed when copies are edited at the same time. → the no-collision rule
- Transaction
- One receipt's unit of work. Keeps four ACID promises. → the four promises a receipt keeps
- Sharding/Partitioning
- Splitting the warehouse into zones. A different kind of splitting from normalization. → the warehouse split into zones