MySQL + SQL · Lesson 1
Normalization In Dbms
Normalization Step by Step
Let us normalize one messy table through 1NF, 2NF and 3NF using a student-course example.
Unnormalized Table
student(roll, name, subjects, teacher, teacher_phone)
1, Aman, "Math,Science", Mr.Rao, 99999Problems: multiple subjects in one cell, repeated teacher info.
1NF — Atomic Values
student(roll, name, subject, teacher, teacher_phone)
1, Aman, Math, Mr.Rao, 99999
1, Aman, Science, Ms.Sen, 88888
2NF — Remove Partial Dependency
Split so non-key columns depend on the whole key:
enrollment(roll, subject)
subject_info(subject, teacher, teacher_phone)
3NF — Remove Transitive Dependency
teacher_phone depends on teacher, not subject — separate it:
subject_info(subject, teacher)
teacher(teacher, teacher_phone)
Summary
- 1NF: atomic values. 2NF: no partial dependency. 3NF: no transitive dependency.
- Each step splits the table to remove a specific problem.
💻 Live Code Editor
Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.