Menu

Earn Premium with Referrals

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

See how it works and start inviting friends.

Normalization & Functional Dependency
DBMS

Normalization & Functional Dependency

Master the art of reducing data redundancy using 1NF, 2NF, and 3NF.

Normalization & Functional Dependency

Normalization is the process of organizing data in a database to reduce redundancy and eliminate anomalies (Insertion, Update, Deletion). It is one of the most frequently asked topics in DBMS interviews.


Learning Objectives

After completing this chapter, you will be able to:

  • Define normalization and its purpose.
  • Understand the three types of data anomalies.
  • Explain Functional Dependency (FD).
  • Classify FDs as trivial/non-trivial.
  • Understand closures and Armstrong’s Axioms.
  • Apply 1NF, 2NF, and 3NF rules.
  • Answer normalization interview questions.

What is Normalization?

Normalization is a systematic approach to decompose larger tables into smaller, related tables to:

GoalDescription
Eliminate redundancyStore each fact exactly once
Remove anomaliesPrevent data inconsistencies
Improve integrityMake constraints easier to enforce
Simplify maintenanceChanges affect minimal tables

The Three Anomalies

Consider an unnormalized table storing student-course data:

Student_IDStudent_NameCourse_IDCourse_NameInstructor
101RahulC01DBMSDr. Sharma
101RahulC02OSDr. Verma
102PriyaC01DBMSDr. Sharma
103AmitC02OSDr. Verma

1. Insertion Anomaly

Cannot add a new course (C03, Networks, Dr. Gupta) until a student enrolls in it. The Student_ID field would be NULL, violating the primary key.

2. Update Anomaly

If Dr. Sharma changes their name, you must update every row where they teach. Miss one — data becomes inconsistent.

3. Deletion Anomaly

If Amit (the only student in OS) drops out, deleting his enrollment also deletes the fact that Dr. Verma teaches OS.

Normalization splits this into Students, Courses, and Enrollments tables — each fact stored exactly once.


Functional Dependency (FD)

A Functional Dependency describes the relationship between attributes. If attribute A uniquely determines attribute B, we write:

A → B (read as “A determines B”)

Example

In a Students table:

  • Student_ID → Name (knowing the ID tells you the name)
  • Student_ID → Email (knowing the ID tells you the email)

Trivial vs Non-Trivial

TypeDefinitionExample
Trivial FDB is a subset of A{ID, Name} → {ID}
Non-Trivial FDB is not a subset of A{ID} → {Name}
Completely Non-TrivialA and B have no attributes in common{ID} → {Name}

Rules for FDs (Armstrong’s Axioms)

RuleMeaningExample
ReflexivityIf Y ⊆ X, then X → Y{A,B} → {A}
AugmentationIf X → Y, then XZ → YZA → B implies AC → BC
TransitivityIf X → Y and Y → Z, then X → ZA → B and B → C implies A → C

Closure of an Attribute Set (X⁺)

The Closure of attribute set X (written X⁺) is the set of all attributes that can be functionally determined by X.

Example

Given: R(A, B, C, D) with FDs: A → B, B → C, A → D

Calculate A⁺:

  1. Start: A⁺ = {A}
  2. Using A → B: A⁺ = {A, B}
  3. Using B → C: A⁺ = {A, B, C}
  4. Using A → D: A⁺ = {A, B, C, D}

Since A⁺ contains all attributes of R, A is a candidate key.

Why Closure Matters

PurposeUse
Find candidate keysIf X⁺ = all attributes, X is a super key
Check normal formsDetermine if non-key attributes depend on the full key
Validate decompositionsEnsure lossless joins and dependency preservation

First Normal Form (1NF)

Rule: Every column must contain atomic (indivisible) values. No repeating groups.

Before 1NF

StudentCourses
RahulDBMS, OS
PriyaDBMS

After 1NF

StudentCourse
RahulDBMS
RahulOS
PriyaDBMS

Every cell contains exactly one value. The primary key changes to {Student, Course} (composite).


Second Normal Form (2NF)

Rule: Must be in 1NF AND no partial dependency — every non-key attribute must depend on the ENTIRE primary key.

Partial Dependency Example

In 1NF table with PK {Student_ID, Course_ID}:

  • Student_Name depends only on Student_ID (partial dependency)
  • Course_Name depends only on Course_ID (partial dependency)

Fix: Split into three tables

StudentsCourse_ID → Course_Name
EnrollmentsStudent_ID → Student_Name, Course_ID

Now every non-key attribute depends on the full primary key of its table.


Third Normal Form (3NF)

Rule: Must be in 2NF AND no transitive dependency — a non-key attribute must not depend on another non-key attribute.

Transitive Dependency Example

In a Courses table with Course_ID → Instructor, Instructor → Office:

Course_ID → Instructor → Office

Office depends on Instructor, not directly on Course_ID. This is transitive.

Fix: Split

CoursesCourse_ID → Course_Name, Instructor
InstructorsInstructor → Office

Now every non-key attribute depends on nothing but the key.


Normal Forms Quick Reference

Normal FormRuleFix
1NFAtomic values, no repeating groupsSplit multi-valued cells into rows
2NFNo partial dependencyRemove dependencies on part of composite PK
3NFNo transitive dependencyMove inter-non-key dependencies to separate tables

Interview Deep Dive

Q: What is an Insertion Anomaly?

A: When you cannot insert data because some other data is missing. Example: In a combined Student-Department table, you can’t add a new Department unless you have at least one Student enrolled in it. Normalization solves this by separating entities into their own tables.

Q: Does Normalization always improve performance?

A: No. While normalization reduces redundancy and ensures data integrity, it often splits data into many tables. This requires Joins during retrieval, which can slow down read-heavy applications. For analytical systems, denormalization is sometimes preferred.

Q: What level of normalization is typically used in production?

A: Most production databases are normalized to 3NF. BCNF and 4NF are used for more specialized scenarios that require handling overlapping candidate keys or multi-valued dependencies.

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 Course_ID). A transitive dependency occurs when a non-key attribute depends on another non-key attribute (e.g., Instructor_Office depends on Instructor, not directly on the key).


Key Takeaways

  • Normalization reduces redundancy and eliminates insertion, update, and deletion anomalies.
  • Functional Dependency (FD): A → B means A determines B.
  • Armstrong’s Axioms: Reflexivity, Augmentation, Transitivity — used to derive all FDs.
  • Closure (X⁺): Set of all attributes determined by X. Used to find candidate keys.
  • 1NF: Atomic values only.
  • 2NF: No partial dependencies (remove dependencies on part of composite PK).
  • 3NF: No transitive dependencies (no non-key → non-key).
  • Normalization is not always about performance — it’s about integrity. Denormalize only when read performance is critical.

My Private Notes

Notes are auto-saved locally to this device.