Normalization
Key points
- Normalization is a design approach that splits tables into appropriate units to prevent duplicate and inconsistent data.
- Cramming too much information into a single table makes missed updates and inconsistencies more likely.
- In a normalized design, each piece of information is basically held in exactly one place.
What is normalization?
Normalization is a design technique for organizing a database's tables so that the same information isn't repeated over and over. The goal is to reduce data duplication and avoid inconsistencies whenever data is updated or deleted.
Teacher Pochi's hintPicture keeping the class roster and each student's personal details on separate sheets — a "class roster (list of students)" and a "student register (addresses, contact details, and other specifics)" — instead of cramming them onto a single page.
Problems before normalization
For example, if you cram a customer's name and address directly into the "orders" table, the following problems arise.
These problems arise from cramming too many unrelated kinds of information into a single table.
The idea behind normalization: splitting tables apart
Normalization splits data of different kinds — like "information about the customer" and "information about the order" — into separate tables.
one giant table
role
table
table
Customer information is recorded exactly once in the customers table, and the orders table references it via a foreign key (customer_id). This means an address change only requires updating a single place in the customers table.
A concrete example: splitting up order data
Before normalization, every order recorded the customer's name, address, and product name all together in a single row. After normalization, the data is split into tables by role, as follows.
customersCustomer name and addressordersOrder date and customer IDproductsProduct name and priceBecause each table is linked by foreign keys, you can join the tables back together whenever you need the original combined information.
Teacher Pochi's hintThis is the same idea as a library keeping separate ledgers for a "patron register," a "book catalog," and "checkout records." You can find out who borrowed what by cross-referencing the ledgers using their reference numbers.
Benefits and cautions of normalization
Normalization offers many benefits, but taking it too far introduces its own challenges. Striking a balance matters.
In practice, teams generally normalize by default, but sometimes deliberately duplicate some data anyway — a choice called "denormalization" — when search speed is the priority.
The stages of normalization: 1st through 3rd normal form
Normalization happens in stages, tidying things up step by step. What's been covered so far mainly corresponds to the following three stages.
In practice, it's more useful to develop a feel for "is the same information scattered across multiple places?" than to memorize these definitions precisely.
Summary
Normalization is a design approach that splits data of different kinds into tables at an appropriate level of granularity, preventing duplication, missed updates, and inconsistencies. It's a foundational perspective in table design.
Related topics: