MySQL + SQL · Lesson 27
1NF, 2NF and 3NF with Examples
First Normal Form (1NF)
A table is in 1NF if every cell holds a single (atomic) value and there are no repeating groups.
Bad: a "subjects" column holding "Math, Science". Fix: one row per subject.
Second Normal Form (2NF)
2NF = 1NF + no partial dependency (a non-key column must depend on the whole composite key, not part).
In marks(roll, subject, student_name): student_name depends only on roll (part of key) → move it out.
Third Normal Form (3NF)
3NF = 2NF + no transitive dependency (non-key column must not depend on another non-key column).
In student(roll, city, pincode): pincode depends on city → separate city/pincode.
Summary
- 1NF: atomic values.
- 2NF: no partial dependency.
- 3NF: no transitive dependency.
💻 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ें.