Database
Normalization
Learn how to organize database tables to eliminate redundancy, prevent update anomalies, and ensure data integrity using 1NF, 2NF, and 3NF.
What Is Normalization?
Normalization is a systematic process of organizing columns and tables in a relational database to minimize data redundancy and improve data integrity. It was first proposed by Edgar F. Codd in 1970.
Normalization breaks large, complex tables into smaller, related tables connected by foreign keys. Each level of normalization is called a normal form.
Why Normalize Your Database?
The Three Anomalies
Poorly designed tables cause three types of data anomalies. Normalization is specifically designed to prevent all three.
Key Terminology
The Path to Normal Forms
First Normal Form: 1NF
A table is in 1NF if every column contains only atomic (indivisible) values and each row is uniquely identifiable. No repeating groups or arrays inside a single cell.
1NF Example
Second Normal Form: 2NF
A table is in 2NF if it is already in 1NF and every non-key column depends on the entire primary key, not just part of it. This rule only matters when the primary key is composite (multiple columns).
2NF Example
Third Normal Form: 3NF
A table is in 3NF if it is in 2NF and no non-key column depends on another non-key column. In other words: eliminate all transitive dependencies.
3NF Example
Partial vs Transitive Dependencies
| Partial Dependency | Transitive Dependency | |
|---|---|---|
| Eliminated in | 2NF | 3NF |
| Requires | Composite primary key | Any primary key |
| Pattern | Non-key depends on part of PK | Non-key depends on another non-key |
| Example | PK(A,B): C depends on A only | PK(A): \( A \rightarrow B \rightarrow C \) |
| Fix | Move C to table with PK = A | Move C to table with PK = B |
How to Normalize a Table
Worked Example: Library Database
Consider an unnormalized table tracking library checkouts:
Library Example: Normalized Result
One row per member. No redundancy.
Each book stored once with its author.
Junction table linking members to books.
Common Mistakes
Summary: Normal Forms at a Glance
| 1NF | 2NF | 3NF | |
|---|---|---|---|
| Requires | Atomic values, unique rows | 1NF + no partial deps | 2NF + no transitive deps |
| Eliminates | Repeating groups, multi-values | Partial dependencies | Transitive dependencies |
| Key concern | Cell-level atomicity | Full key dependency | Non-key independence |
| When to apply | Always: first step | Composite PK tables | All tables |
| Common fix | Split multi-value cells into rows | Extract to new table | Extract to new table + FK |
Question 1 of 5
A table has a column called PhoneNumbers that stores values like "555-1234, 555-5678". Which normal form does this violate?
Question 2 of 5
A table has composite PK (StudentID, CourseID) and a column StudentName that depends only on StudentID. This is an example of a:
Question 3 of 5
An Orders table has PK OrderID and columns CustID, CustName, and CustCity. CustName and CustCity depend on CustID (not OrderID directly). What normal form is violated?
Question 4 of 5
If a table has a single-column primary key and all values are atomic, which of the following is always true?
Question 5 of 5
Which of the following best describes the goal of database normalization?