Normalization organizes databases to reduce redundancy. Learn the normal forms and their importance.
Why Normalize?
- Reduce data redundancy
- Improve data integrity
- Make updates easier
- Save storage space
Normal Forms
First Normal Form (1NF)
- Eliminate repeating groups
- Each cell contains atomic values
- Each record is unique
Before 1NF:
| Student | Courses |
|---------|---------|
| John | Math, Physics |
| Jane | Chemistry |
After 1NF:
| Student | Course |
|---------|---------|
| John | Math |
| John | Physics |
| Jane | Chemistry |
Second Normal Form (2NF)
- Already in 1NF
- No partial dependencies
Third Normal Form (3NF)
- Already in 2NF
- No transitive dependencies
Example Transformation
Unnormalized:
- StudentID, Name, Course1, Course2, Course3
3NF:
- Students: StudentID, Name
- Courses: CourseID, CourseName
- Enrollments: StudentID, CourseID
Benefits of Normalization
- Data consistency
- Flexibility
- Easier maintenance
- Better performance for updates