Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

NF, 2NF, 3NF, and BCNF
DBMS

NF, 2NF, 3NF, and BCNF

Master the first four normal forms — 1NF, 2NF, 3NF, BCNF — with detailed examples showing how to identify and fix violations in any schema.

1NF, 2NF, 3NF, and BCNF

Normalization is the process of organizing data to reduce redundancy and eliminate anomalies. Each normal form is a level of refinement.

  • 1NF: Atomic columns (no repeating groups).
  • 2NF: 1NF + no partial dependencies.
  • 3NF: 2NF + no transitive dependencies.
  • BCNF: 3NF + every determinant is a candidate key.

This chapter walks through each normal form with clear examples.


Learning Objectives

After completing this chapter, you will be able to:

  • Identify which normal form a table is in.
  • Convert a table from unnormalized to 1NF, 2NF, 3NF, and BCNF.
  • Recognize partial, transitive, and non-key determinant dependencies.
  • Understand when BCNF differs from 3NF.
  • Apply normalization to real-world schemas.
  • Answer normalization interview questions.

Sample Unnormalized Table

Consider this table storing student-course data.

StudentCourses (Unnormalized)

Student_IDStudent_NameCourse_IDCourse_NameInstructorInstructor_Office
101RahulC01, C02DBMS, OSDr. Sharma, Dr. VermaA101, B202
102PriyaC01DBMSDr. SharmaA101
103AmitC02, C03OS, NetworksDr. Verma, Dr. GuptaB202, C303

Problems:

  • Multiple values in one cell (violates atomicity).
  • Repeating groups.
  • Updating a course name requires scanning multiple rows.

First Normal Form (1NF)

Rule

  • Every column must contain atomic (indivisible) values.
  • There should be no repeating groups of columns.
  • Each row must be uniquely identifiable.

Fixing 1NF

Split the multi-valued columns into separate rows.

StudentCourses (1NF)

Student_IDStudent_NameCourse_IDCourse_NameInstructorInstructor_Office
101RahulC01DBMSDr. SharmaA101
101RahulC02OSDr. VermaB202
102PriyaC01DBMSDr. SharmaA101
103AmitC02OSDr. VermaB202
103AmitC03NetworksDr. GuptaC303

Result

  • Every cell has a single value.
  • No more repeating groups.
  • The primary key must now be {Student_ID, Course_ID} (composite).

Remaining Problems

  • Redundancy: Student_Name repeats for each course a student takes.
  • Anomalies:
    • Update: If Rahul changes his name, you must update multiple rows.
    • Insert: Cannot add a course if no student is enrolled (NULL in Student_ID).
    • Delete: Deleting Amit’s last enrollment loses his student info.

Second Normal Form (2NF)

Rule

  • Must be in 1NF.
  • No partial dependency: Every non-key attribute must be fully functionally dependent on the entire primary key (not just part of it).

Analyzing 1NF Table

Primary key: {Student_ID, Course_ID}

Dependencies

  • Student_ID → Student_Name (partial dependency: Name depends only on Student_ID, not on Course_ID)
  • Course_ID → Course_Name, Instructor, Instructor_Office (partial dependency: Course info depends only on Course_ID)

Fixing 2NF

Remove partial dependencies by splitting into separate tables.

Students (2NF)

Student_IDStudent_Name
101Rahul
102Priya
103Amit

Courses (2NF)

Course_IDCourse_NameInstructorInstructor_Office
C01DBMSDr. SharmaA101
C02OSDr. VermaB202
C03NetworksDr. GuptaC303

Enrollments (2NF)

Student_IDCourse_ID
101C01
101C02
102C01
103C02
103C03

Result

  • No partial dependencies.
  • Each fact is stored exactly once.

Remaining Problems

Courses table: Course_ID → Instructor → Instructor_Office

Instructor_Office depends on Instructor, not directly on Course_ID.

This is a transitive dependency.


Third Normal Form (3NF)

Rule

  • Must be in 2NF.
  • No transitive dependency: A non-key attribute must not depend on another non-key attribute.

Analyzing 2NF Courses Table

Course_IDCourse_NameInstructorInstructor_Office
C01DBMSDr. SharmaA101
C02OSDr. VermaB202

Dependency

Course_ID → Instructor → Instructor_Office

Instructor_Office depends on Instructor, not directly on Course_ID.

Problems

  • Update: If Dr. Sharma changes office, you must update every course they teach.
  • Insert: Cannot add a new instructor’s office without assigning them a course.
  • Delete: Deleting the last course by Dr. Verma loses their office information.

Fixing 3NF

Remove transitive dependencies by splitting again.

Courses (3NF)

Course_IDCourse_NameInstructor
C01DBMSDr. Sharma
C02OSDr. Verma
C03NetworksDr. Gupta

Instructors (3NF)

InstructorOffice
Dr. SharmaA101
Dr. VermaB202
Dr. GuptaC303

Result

  • Every non-key attribute depends on nothing but the key.
  • Course_ID determines Instructor.
  • Instructor determines Office.
  • Both tables are now in 3NF.

Boyce-Codd Normal Form (BCNF)

Rule

  • Must be in 3NF.
  • Every determinant must be a candidate key.

A determinant is any attribute (or set of attributes) that determines another attribute.

BCNF is a stricter version of 3NF. A table in 3NF is not automatically in BCNF.

Example Where 3NF ≠ BCNF

Consider a table tracking student advisors:

StudentMajorAdvisor
RahulCSDr. A
PriyaCSDr. A
AmitEEDr. B
SnehaEEDr. C

Assumptions

  • A student has one major and one advisor.
  • Each major has multiple advisors.
  • An advisor advises only one major (Dr. A advises only CS).

Candidate Keys

  • {Student, Major} — a student-major pair is unique.
  • {Student, Advisor} — a student-advisor pair is unique.

Dependencies

  • Student → Major (a student has one major).
  • Advisor → Major (an advisor advises only one major).

Is this 3NF?

Yes. All non-key attributes depend on the key.

But Advisor → Major — Advisor is not a candidate key (Advisor alone is not unique across the table — Dr. A appears twice).

Violation

Advisor is a determinant but not a candidate key.

Problems

  • Update: If Dr. A moves to EE, you must update both rows.
  • Redundancy: Dr. A teaches CS, and this is stored twice.

Fixing BCNF

Split the table.

Students (BCNF)

StudentAdvisor
RahulDr. A
PriyaDr. A
AmitDr. B
SnehaDr. C

Advisors (BCNF)

AdvisorMajor
Dr. ACS
Dr. BEE
Dr. CEE

Now:

  • Students: {Student} is the candidate key. Student → Advisor.
  • Advisors: {Advisor} is the candidate key. Advisor → Major.

Every determinant is a candidate key. Both tables are in BCNF.


Summary Table

Normal FormRuleHow to Fix
1NFAtomic columns, no repeating groupsSplit multi-valued cells into separate rows
2NF1NF + No partial dependency (all non-key attributes depend on the full PK)Split tables so each non-key attribute depends on the entire PK
3NF2NF + No transitive dependency (no non-key attribute depends on another non-key attribute)Move transitive dependencies to separate tables
BCNF3NF + Every determinant is a candidate keySplit tables where non-key attributes determine other attributes

Quick Check: Which Normal Form?

ScenarioCurrent NFProblem
Column has comma-separated valuesNot 1NFNon-atomic data
Student_Name depends only on Student_ID (part of composite PK)1NFPartial dependency → go to 2NF
Instructor_Office depends on Instructor (non-key)2NFTransitive dependency → go to 3NF
Advisor → Major, but Advisor is not a candidate key3NFDeterminant is not a key → go to BCNF

Interview Deep Dive

Q: What is the difference between a partial dependency and a transitive dependency?

A: A partial dependency occurs when a non-key attribute depends on only part of a composite primary key (e.g., Student_Name depends on Student_ID but not on Course_ID in a {Student_ID, Course_ID} key). A transitive dependency occurs when a non-key attribute depends on another non-key attribute (e.g., Instructor_Office depends on Instructor, which depends on Course_ID).

Q: When would a table be in 3NF but not in BCNF?

A: When a non-key attribute determines another non-key attribute, and this determinant is not a candidate key. Example: In a Student-Advisor-Major table, Advisor → Major holds, but Advisor is not a candidate key (multiple students share the same advisor). The table is in 3NF but violates BCNF.

Q: Is it always good to normalize to BCNF?

A: Not always. Normalization reduces redundancy but increases joins. In a data warehouse with heavy read workloads, you may intentionally denormalize to 2NF to avoid joins and improve query performance. Always normalize for OLTP systems (where write integrity matters). Denormalize for OLAP/analytical systems (where read speed matters).

Q: What problems does normalization solve?

A: Three types of anomalies: (1) Update anomaly — changing a value in one row requires changing it in many places. (2) Insert anomaly — cannot add data without adding unrelated data. (3) Delete anomaly — deleting data accidentally removes unrelated data. Normalization ensures each fact is stored in exactly one place, eliminating all three anomalies.


Key Takeaways

  • 1NF requires atomic values and no repeating groups.
  • 2NF removes partial dependencies (every attribute depends on the full key).
  • 3NF removes transitive dependencies (every attribute depends on the key, nothing but the key).
  • BCNF requires every determinant to be a candidate key (stricter than 3NF).
  • Normalization eliminates update, insert, and delete anomalies.
  • Each normal form is a refinement of the previous one.
  • Denormalization is acceptable for read-heavy analytical systems.

My Private Notes

Notes are auto-saved locally to this device.