Database Normalization Overview
Database Normalization
The Purpose of Normalization
Database normalization is the process of arranging tables, columns, and relationships between tables to avoid data redundancy and attain data integrity. Normalization means putting correct data in correct tables to avoid CUD anomalies — issues that arise during Create, Update, and Delete operations.
Normalization: Organizing a database to minimize redundancy and dependency, ensuring data is stored logically.
The Denormalized Table: FilmAgents Example
Consider an initial denormalized table called FilmAgents:
agent_id | agent_name | agency_name | agency_location | office_contact | customer1 | customer2 | customer3 |
|---|---|---|---|---|---|---|---|
A1 | Ari Gold | New Cine | LA | 111-222-333 | Bread Pith | Fakira Tori | — |
A2 | Tori Bronze | New Cine | LA | 111-222-333 | Nedd Stark | CNolan | Solman Kan |
A3 | — | Free Folks | LA | 555-666-777 | Morgage Freeman | — | — |
A4 | Gori Diamond | FireFolks Pvt | Mumbai | 444-555-666 | Rajini Sir | Saruk Kan | — |
(Adapted from the lecture)
Issues with this denormalized design:
Data redundancy: Agency name, location, and contact are repeated for each agent belonging to the same agency.
Multiple customer columns (customer1, customer2, customer3) represent the same kind of information (non-atomic, repeated group).
Types of Anomalies (Why Normalize?)
Normalization aims to eliminate these anomalies:
Insert (Create) Anomaly
If a new agency exists but has no agent yet (e.g., Free Folks with client Morgage Freeman but no agent), we cannot insert the agency's information because the primary key (agent_id) would be null. Since the primary key must uniquely identify each row and cannot be null, the new agency cannot be stored — an insert anomaly.
Update Anomaly
When data is repeated (e.g., agency contact details for New Cine appears in multiple rows), updating that information (e.g., moving from LA to San Diego with new phone) requires updating every row containing that agency. If some rows are missed, the data becomes inconsistent — an update anomaly.
Delete Anomaly
If an agent (e.g., Gori Diamond) is removed, and that was the only agent for the agency (FireFolks Pvt), deleting the row also deletes the agency's information and its clients (Rajini Sir, Saruk Kan). This is a delete anomaly — loss of independent agency data.
Read/Query Issues (Though Not Formal Anomalies)
Finding all customers for a given client requires querying multiple columns (customer1, customer2, customer3) with
ORconditions. Adding more customer columns would force modification of every query.Sorting by customer name is ambiguous — which column to sort on? customer1, customer2, or customer3?
Normal Forms Overview
Normalization is achieved in stages called normal forms. The most commonly required forms up to 3NF are sufficient for most databases:
1NF (First Normal Form)
2NF (Second Normal Form)
3NF (Third Normal Form)
Additional forms exist: BCNF (Boyce-Codd, ≈3.5NF), 4NF, 5NF, 6NF — but 3NF is generally considered sufficiently normalized.
First Normal Form (1NF)
Rules for 1NF
Each column must be atomic: No multiple values in a single column; each cell holds exactly one value.
No repeating groups of columns: Do not use multiple columns (e.g., customer1, customer2, customer3) to store similar data.
Every table must have a primary key: A column or combination of columns that uniquely identifies each row.
The original FilmAgents table violates 1NF because it has three customer columns (repeating group). To achieve 1NF, we split the table into two:
AgentInfo:
agent_id(PK),agent_name,agency_name,agency_location,office_contactCustomerInfo:
customer_id(PK),customer_name,customer_city,customer_pin,agent_id(foreign key referencing AgentInfo)
Now the database is in 1NF:
All columns are atomic (single values).
No repeated groups of columns.
Each table has a primary key (
agent_id,customer_id).
What 1NF Solves
Unlimited customers per agent (just add more rows in CustomerInfo).
Sorting by customer name works on a single column.
Delete anomaly on customers: removing a customer row does not affect agent information.
However, insert and update anomalies still remain (e.g., can't insert a new agency without an agent).
Second Normal Form (2NF)
Rules for 2NF
Must already be in 1NF.
All non-key columns must be fully functionally dependent on the primary key. In other words: each non-key column should describe what the primary key uniquely identifies. If a column describes something else, it belongs in a different table.
Applying 2NF to Our Design
In the AgentInfo table from 1NF:
Primary key:
agent_idNon-key columns:
agent_name,agency_name,agency_location,office_contact
Ask: Does agency_location describe the agent (identified by agent_id)? No — it describes the agency. Therefore, these columns are not dependent on the primary key. They should be moved to a new table.
We split into three tables:
AgentInfo:
agent_id(PK),agent_name,agency_id(foreign key referencing AgencyInfo)AgencyInfo:
agency_id(PK),agency_name,office_location,office_contactCustomerInfo:
customer_id(PK),customer_name,customer_city,customer_pin(and a join table for agent–customer relationship)
Additionally, a join table is created to handle the many-to-many relationship between agents and customers:
AgentCustomer:
agent_id(FK),customer_id(FK) — composite primary key
Now in AgentInfo, all non-key columns (agent_name) describe the agent directly. In AgencyInfo, agency_name, office_location, office_contact describe the agency. In CustomerInfo, customer_name, customer_city, customer_pin describe the customer. So all tables are in 2NF.
What 2NF Solves
Agency data is stored once, eliminating redundancy.
Insert anomaly for agencies without agents is resolved: we can add an agency to
AgencyInfowithout needing an agent.Update anomaly resolved: changing agency details only requires updating one row in
AgencyInfo.
Third Normal Form (3NF)
Rules for 3NF
Must already be in 2NF.
All non-key columns must be non-transitively dependent on the primary key — i.e., no transitive dependency. A transitive dependency occurs when a non-key column depends on another non-key column, which in turn depends on the primary key.
Applying 3NF to Our Design
In the CustomerInfo table (from 2NF):
Primary key:
customer_idNon-key columns:
customer_name,customer_city,customer_pin
Check for transitive dependency:
customer_name→ directly depends oncustomer_id✔customer_city→ directly depends oncustomer_id(city describes the customer) ✔customer_pin→ depends oncustomer_city, andcustomer_citydepends oncustomer_id— thereforecustomer_pinis transitively dependent on the primary key throughcustomer_city. ❌
To remove this transitive dependency, split CustomerInfo into two tables:
CustomerInfo:
customer_id(PK),customer_name,customer_city(and a foreign key for pin — or separate table)CityPin:
pin(PK),city(and maybestate), withpinas foreign key in CustomerInfo (or better, keepcustomer_cityand removecustomer_pin? Actually, the lecture creates a separate tableCustomerPinCodeswithCustPinCodeandCustCity.)
Following the lecture's final design:
CustomerInfo:
customer_id(PK),customer_name,customer_city,customer_pin(as foreign key referencingCustomerPinCodes)CustomerPinCodes:
pin(PK),city(describing the pin directly)
Now all tables are in 3NF:
In
CustomerInfo, non-key columns (customer_name,customer_city) directly depend oncustomer_id.customer_pinis now a foreign key (not a non-key column), so the transitive dependency is eliminated.In
CustomerPinCodes,citydepends directly onpin.
What 3NF Solves
Further reduces redundancy: pin and city mapping stored once instead of repeated for each customer with the same pin.
Prevents update anomalies: if a city's pin code changes, update only one row in
CustomerPinCodes.Ensures data integrity: no inconsistent city–pin pairs.
Final Normalized Schema (3NF)
AgentInfo
- agent_id (PK)
- agent_name
- agency_id (FK -> AgencyInfo)
AgencyInfo
- agency_id (PK)
- agency_name
- office_location
- office_contact
AgentCustomer (Join Table)
- agent_id (FK -> AgentInfo)
- customer_id (FK -> CustomerInfo)
- (Composite PK: agent_id, customer_id)
CustomerInfo
- customer_id (PK)
- customer_name
- customer_city
- pin (FK -> CustomerPinCodes)
CustomerPinCodes
- pin (PK)
- cityThis design avoids all three anomalies, minimizes redundancy, and maintains data integrity. Achieving 3NF is considered a well-normalized relational database.

Ask anything
We've read this whole study set, so questions about it get the best answers.