1
Before to Get Started with Normalization Must to Know
Data Duplication
Definition:
Same data is stored multiple times unnecessarily.
Example:
StudentID StudentName Course Instructor
1 Ali DB Ahmed
1 Ali OS Bilal
“Ali” is repeated again and again.
Problem:
• Wastes space
• Hard to update
Data Inconsistency
Definition:
Same data has different values in different places.
Example:
StudentID StudentName Course
1 Ali DB
1 Alee OS
Same student, different spellings.
Problem:
• Confusion
• Wrong results
2
Data Integrity
Definition:
Data is correct, consistent, and reliable.
Example (Good Data):
StudentID StudentName
1 Ali
2 Sara
No duplication, no mismatch → correct data
Goal of normalization:
Maintain data integrity
Partial Dependency
Definition:
A column depends on only part of a composite key (not full key).
Example:
StudentID Course StudentName
1 DB Ali
1 OS Ali
Primary Key = (StudentID + Course)
But:
• StudentName depends only on StudentID
Problem:
• Repetition of StudentName
3
Fix:
Students Table
StudentID StudentName
1 Ali
Enrollments Table
StudentID Course
1 DB
1 OS
Transitive Dependency
Definition:
A column depends on another non-key column (indirect dependency).
Example:
StudentID Course Instructor
1 DB Ahmed
2 DB Ahmed
Here:
• Course → Instructor
• NOT StudentID → Instructor directly
So:
Instructor depends on Course (not primary key)
4
Problem:
• Redundant data
• If instructor changes → update many rows
Fix:
Courses Table
Course Instructor
DB Ahmed
Enrollments Table
StudentID Course
1 DB
2 DB
Quick Comparison (Easy Memory)
• Data Duplication → Same data repeated
• Data Inconsistency → Same data, different values
• Data Integrity → Data is correct and reliable
• Partial Dependency → Depends on part of key
• Transitive Dependency → Depends on another column
5
Database Normalization
Definition
Normalization is the process of dividing a large table into smaller related tables to
reduce redundancy and improve data consistency.
It helps avoid duplication and maintains accurate data
Introduction
• Problems in unorganized data:
o Data duplication
o Inconsistent updates
o Difficult data handling
• Normalization improves:
o Data integrity
o Data structure
o Efficiency
Unnormalized Table (0NF)
StudentID StudentName Courses Instructor
1 Ali DB, OS Ahmed, Bilal
2 Sara DB Ahmed
Problems:
• Multiple values in one column
• Difficult to query
• Data redundancy
6
First Normal Form (1NF)
Rules:
• No repeating groups
• Each cell contains a single value
Table in 1NF:
StudentID StudentName Course Instructor
1 Ali DB Ahmed
1 Ali OS Bilal
2 Sara DB Ahmed
7
Second Normal Form (2NF)
Rules:
• Must be in 1NF
• No partial dependency
Tables in 2NF:
Students Table
StudentID StudentName
1 Ali
2 Sara
Enrollments Table
StudentID Course Instructor
1 DB Ahmed
1 OS Bilal
2 DB Ahmed
8
Third Normal Form (3NF)
Rules:
• Must be in 2NF
• No transitive dependency
Tables in 3NF:
Students
StudentID StudentName
1 Ali
2 Sara
Courses
Course Instructor
DB Ahmed
OS Bilal
Enrollments
StudentID Course
1 DB
1 OS
2 DB
9
Practice Example
OrderID CustomerName Product Price
1 Ali Laptop 1000
1 Ali Mouse 20
Summary
• 1NF: No multi-values
• 2NF: No partial dependency
• 3NF: No indirect dependency
Exercise
Normalize the following table:
EmpID EmpName Department Manager
1 Ali IT Ahmed
2 Sara HR Bilal
3 Ali IT Ahmed