Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
MySQL + SQL · Lesson 28

1NF, 2NF and 3NF with Examples

In this lesson: Learn 1NF, 2NF and 3NF with solved examples, rules, dependency diagrams and exam-style questions. Score full marks.

The one table we will normalize

The best way to learn 1NF, 2NF and 3NF is to take a single messy table and fix it in front of your eyes. Below is a student_marks table exactly as a beginner might first design it — everything crammed together.

student_idstudent_namesubjectsteacherteacher_phone
1AaravMath, ScienceMr. Rao99999-11111
2DiyaMathMr. Rao99999-11111

Three separate problems are hiding here. The subjects cell holds a list. The teacher's phone is repeated for every student the teacher handles. And the phone number really belongs to the teacher, not to the student row. We will clear these one form at a time.

💡 Note

This is a worked companion to the theory in normalization in DBMS. Here we focus purely on doing it, step by step.

Step 1: Convert to 1NF

1NF rule: every cell must hold one single value. The subjects column breaks this, so we split each subject into its own row.

student_idstudent_namesubjectteacherteacher_phone
1AaravMathMr. Rao99999-11111
1AaravScienceMs. Sen99999-22222
2DiyaMathMr. Rao99999-11111

Now no cell contains a list, so the table is in 1NF. The natural key here is the pair (student_id, subject), because that combination identifies one specific mark row. Two problems remain: the student name repeats, and the teacher phone repeats.

Step 2: Convert to 2NF

2NF rule: be in 1NF, and every non-key column must depend on the whole key. Our key is (student_id, subject). But student_name depends only on student_id — that is a partial dependency. We move student facts into their own table.

MySQL
CREATE TABLE students (
    student_id   INT PRIMARY KEY,
    student_name VARCHAR(50)
);

CREATE TABLE marks (
    student_id INT,
    subject    VARCHAR(30),
    teacher    VARCHAR(50),
    teacher_phone VARCHAR(15),
    PRIMARY KEY (student_id, subject),
    FOREIGN KEY (student_id) REFERENCES students(student_id)
);

Now the student name is stored once per student, not once per subject. The partial dependency is gone, so the design is in 2NF. But look at marks: the teacher's phone still repeats, and it depends on the teacher, not on the student-subject key.

Step 3: Convert to 3NF

3NF rule: be in 2NF, and no non-key column may depend on another non-key column. In marks, teacher_phone depends on teacher — both are non-key columns. That is a transitive dependency. We pull teacher facts into their own table.

MySQL
CREATE TABLE teachers (
    teacher       VARCHAR(50) PRIMARY KEY,
    teacher_phone VARCHAR(15)
);

CREATE TABLE marks (
    student_id INT,
    subject    VARCHAR(30),
    teacher    VARCHAR(50),
    PRIMARY KEY (student_id, subject),
    FOREIGN KEY (student_id) REFERENCES students(student_id),
    FOREIGN KEY (teacher)    REFERENCES teachers(teacher)
);

Now a teacher's phone number lives in exactly one place. Change it once in teachers and every mark row instantly reflects it. The transitive dependency is removed — the design is in 3NF.

The final normalized design

We started with one crowded table and ended with three clean ones, each describing a single kind of thing:

  • students — who the student is.
  • teachers — the teacher and their phone.
  • marks — which student takes which subject under which teacher.

Every fact now lives in one place. No student name, no teacher phone, is ever written twice. This is what a 3NF design buys you: safety when you update, and clarity when you read.

🏋️ Practice

Try the same three steps on a library_issue table with columns member_id, member_name, book_ids, author, author_country. Which column forces 1NF? Which causes the partial dependency for 2NF? Which pair is the transitive dependency for 3NF?

Side-by-side comparison

FormWhat we fixed in this example
1NFSplit the "Math, Science" list into separate rows
2NFMoved student_name (depends on student_id only) to a students table
3NFMoved teacher_phone (depends on teacher) to a teachers table

Notice the pattern: at each step we asked "what does this column really depend on?" and moved it next to the thing it belongs to.

Common mistakes

  • Jumping to 3NF without checking 1NF. If a cell still holds a list, no later form is valid. Always fix atomic values first.
  • Thinking a single-column key can break 2NF. Partial dependency needs a composite key. Single-column key tables are already in 2NF once in 1NF.
  • Leaving the foreign keys out. After splitting tables, connect them with foreign keys, or you lose the guarantee that links stay valid.
  • Normalizing data that never repeats. If a column has no redundancy, splitting it just adds joins for nothing.

Summary

  • Apply the forms in order: 1NF, then 2NF, then 3NF.
  • 1NF: we removed the multi-value subjects cell.
  • 2NF: we moved student_name out because it depended on only part of the key.
  • 3NF: we moved teacher_phone out because it depended on another non-key column.
  • The result: three focused tables where every fact is stored once.

Read the underlying theory in normalization in DBMS, or learn the keys that hold these tables together in primary and foreign key.

Frequently Asked Questions

What is the correct order to apply 1NF, 2NF and 3NF?
Always in order: first 1NF, then 2NF, then 3NF. Each form assumes the previous one is already satisfied. You cannot correctly reach 2NF if the table is not yet in 1NF, because 2NF is defined on top of 1NF.
Do I always need a composite key to see 2NF problems?
Partial dependency - the thing 2NF fixes - can only happen when the primary key is made of more than one column. If your key is a single column, the table is automatically in 2NF once it is in 1NF, because there is no "part of the key" for a column to depend on.
How is 3NF different from 2NF in one sentence?
2NF removes columns that depend on only part of the key; 3NF removes columns that depend on another non-key column instead of the key. 2NF is about the key being incomplete, 3NF is about a chain between two ordinary columns.
Will normalization always increase the number of tables?
Usually yes - splitting out repeated facts naturally creates more, smaller tables joined by keys. That is expected and healthy. The trade-off is a few extra joins in queries, which is almost always worth the safety from update errors.
Is BCNF the same as 3NF?
No. BCNF (Boyce-Codd Normal Form) is a slightly stricter version of 3NF that handles some rare cases 3NF misses, involving overlapping candidate keys. For most school and college projects, reaching 3NF is enough, and BCNF is an advanced follow-up.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.
Next topicBCNF in DBMS Your progress: 28 / 151 (19%) · Lesson 29 / 151 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free