Normalization
Normalization
Importance of Normalization
- Prevents data anomalies like:
- Insertion anomalies: Problems with adding new data.
- Deletion anomalies: Problems with deleting data that results in unintended
data loss.
- Update anomalies: Changes in data cause inconsistencies.
- Reduces storage space
- Improves query performance
Scenario:
We have a table that stores information about students, courses, and their
respective instructors. Initially, the table might look like this:
Unnormalized Table:
1NF requires that each table cell contains atomic (indivisible) values and that
there are no repeating groups. In our table, the data is already atomic, so we
are in 1NF. However, the table still has redundancies (like repeating instructor
names and course names).
1NF Table:
Step 2: Second Normal Form (2NF)
2NF Tables:
Students Table:
StudentCourses Table:
Courses Table:
Students Table:
StudentCourses Table:
Courses Table:
Instructors Table:
Final Result:
The database is now normalized to 3NF, with all data dependencies properly
organized. This removes redundancy (e.g., instructor names only appear once
per course) and ensures data integrity.