DEV Community

krithik
krithik

Posted on

NORMALISATION

Understanding Normalization with SQL – 1NF, 2NF, 3NF
When working with databases, we often face redundancy, inconsistency, and anomalies. Normalization helps solve these issues by organizing data into well-structured tables.

πŸ“Œ Base Table (Unnormalized Data)

πŸ”Ž Anomalies Identified
Insertion: Cannot add a new course unless a student registers.
Update: Changing instructor name requires multiple updates.
Deletion: Deleting a student may remove course data too.

βœ… First Normal Form (1NF)
We ensure atomic values and primary keys.

βœ… Second Normal Form (2NF)
We remove partial dependencies by separating Students and Courses.

βœ… Third Normal Form (3NF)
We remove transitive dependencies by separating Instructors.

πŸ“₯ Sample Data Insertions

πŸ”— Query with JOINs

🎯 Conclusion
By applying 1NF β†’ 2NF β†’ 3NF, we eliminated redundancy, prevented anomalies, and achieved a clean database design. This structured design makes querying and maintenance much easier.

Top comments (0)