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

Normalization in DBMS – 1NF, 2NF, 3NF with Example

In this lesson: Normalization in DBMS made easy — why we normalize and how 1NF, 2NF, 3NF remove redundancy using one student table.

What normalization actually solves

Normalization is the process of organizing a database so that the same piece of information is not repeated in many places. It sounds abstract, but the pain it removes is very real. When data repeats, three ugly problems appear: you waste space, updates become dangerous, and your data slowly drifts out of sync.

Imagine a single big table where every student row also stores their course name and course fee. If two hundred students take "Python", the text "Python" and its fee sit in the table two hundred times. Now the fee changes. You must update all two hundred rows perfectly. Miss even one, and your database now claims two different fees for the same course. Normalization prevents this by making sure each fact lives in exactly one place.

💡 Note

We reach normalization in stages called normal forms: 1NF, 2NF and 3NF. Each stage removes one specific kind of repetition. You apply them in order, and for most projects 3NF is the goal.

The problem: an unnormalized table

Here is a messy table that stores everything together. Watch how much repeats.

student_idnamecoursescourse_fee
1AaravPython, MySQL2000, 1500
2DiyaPython2000

Two things are wrong. First, the courses cell holds a list ("Python, MySQL") instead of a single value — that alone makes searching and joining painful. Second, the fee "2000" for Python is written again and again for every student who takes it. We will fix these step by step.

First Normal Form (1NF)

Rule: every cell must hold a single, atomic value. No lists, no comma-separated groups. We split the multi-value rows so each row holds exactly one course.

student_idnamecoursecourse_fee
1AaravPython2000
1AaravMySQL1500
2DiyaPython2000

Now every cell is a single value — the table is in 1NF. Searching for "who takes MySQL" is now a simple query. But notice the fee 2000 for Python still repeats, and the name "Aarav" repeats too. 1NF fixed the list problem, not the repetition problem.

Second Normal Form (2NF)

Rule: be in 1NF, and every non-key column must depend on the whole primary key. Here the natural key is the pair (student_id, course). But course_fee depends only on course, not on the student — that is a partial dependency. We move course facts into their own table.

MySQL
-- courses table (fee stored ONCE per course)
CREATE TABLE courses (
    course      VARCHAR(30) PRIMARY KEY,
    course_fee  DECIMAL(8,2)
);

-- enrollment table (who takes what)
CREATE TABLE enrollment (
    student_id INT,
    course     VARCHAR(30),
    PRIMARY KEY (student_id, course),
    FOREIGN KEY (course) REFERENCES courses(course)
);

Now the Python fee is stored one single time in courses. Change it there, and every student instantly sees the new fee. The partial dependency is gone — the table is in 2NF.

Third Normal Form (3NF)

Rule: be in 2NF, and no non-key column may depend on another non-key column. Suppose our student table also had city and pincode. The pincode determines the city, so city depends on pincode — a non-key column — not directly on the student id. This is a transitive dependency.

MySQL
-- pincode -> city moved to its own table
CREATE TABLE areas (
    pincode CHAR(6) PRIMARY KEY,
    city    VARCHAR(40)
);

CREATE TABLE students (
    student_id INT PRIMARY KEY,
    name       VARCHAR(50),
    pincode    CHAR(6),
    FOREIGN KEY (pincode) REFERENCES areas(pincode)
);

Now the city for each pincode is written once in areas. The students table only keeps the pincode. The transitive dependency is removed — the design is in 3NF, clean and safe to update.

🏋️ Practice

Take a table with columns order_id, product, product_price, customer_name, customer_city. Walk it to 3NF: which column causes a partial dependency, and which pair causes a transitive one? Draw the final set of tables before writing any SQL.

Quick recap of the three forms

FormRule in one lineRemoves
1NFOne value per cellRepeating groups / lists
2NFFull-key dependencyPartial dependency
3NFNo non-key to non-key linkTransitive dependency

A handy way to remember it: 1NF fixes the shape of a row, 2NF fixes dependence on part of the key, and 3NF fixes dependence between non-key columns.

Common mistakes

  • Skipping straight to 3NF. The forms build on each other. Check 1NF and 2NF first, or you will miss a hidden partial dependency.
  • Storing lists in one cell. "Python, MySQL" in a single field breaks 1NF and makes every query harder. One value per cell.
  • Over-normalizing tiny tables. Splitting a two-column lookup into more tables just adds joins with no benefit. Normalize where repetition actually hurts.
  • Confusing normalization with performance tuning. Normalization is about correctness and no redundancy; speed tuning (indexes, denormalization) is a separate, later concern.

Summary

  • Normalization stores each fact once, preventing wasted space and update errors.
  • 1NF: every cell holds a single atomic value.
  • 2NF: in 1NF, and every column depends on the whole key (no partial dependency).
  • 3NF: in 2NF, and no non-key column depends on another non-key column (no transitive dependency).
  • 3NF is the safe default for most applications.

Next, see worked examples in 1NF, 2NF and 3NF with examples, or learn the rules that protect these tables in constraints in MySQL.

Frequently Asked Questions

Why do we need normalization in a database?
Normalization removes repeated data so that each fact is stored in exactly one place. This saves space, and more importantly it prevents update problems - if a course fee is stored in fifty rows and it changes, you would have to update all fifty, and one missed row means inconsistent data. Normalization stops that by design.
What is the simple difference between 1NF, 2NF and 3NF?
1NF means every cell holds one single value (no lists in a cell). 2NF means, on top of 1NF, that every non-key column depends on the whole primary key, not just part of it. 3NF means, on top of 2NF, that no non-key column depends on another non-key column. Each form fixes one specific kind of redundancy.
Is 3NF always the best choice?
For most everyday applications, yes - 3NF is a good, safe target. But in reporting or analytics systems, teams sometimes deliberately break 3NF (denormalize) to make reads faster. So 3NF is the sensible default, not an absolute rule for every situation.
What is a partial dependency in 2NF?
A partial dependency is when a column depends on only part of a composite (multi-column) primary key instead of the whole key. For example, if the key is (student_id, course_id) and course_name depends only on course_id, that is a partial dependency, and 2NF requires you to move it to its own table.
What is a transitive dependency in 3NF?
A transitive dependency is when a non-key column depends on another non-key column rather than directly on the key. For example, if a table has student_id, city and pincode, and pincode determines city, then city depends on pincode (a non-key column). 3NF says split that out so city lives with pincode.
🔗

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 topicNormalization Examples in DBMS Your progress: 26 / 151 (17%) · Lesson 27 / 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