4.4.21Databases

Normalization — 1NF, 2NF, 3NF, BCNF — anomalies each resolves

2,052 words9 min readdifficulty · medium5 backlinks

WHY do we normalize at all?

WHAT is an anomaly? A situation where the structure of the table forces bad behaviour:

  • Insert anomaly — you can't record fact A without also knowing unrelated fact B.
  • Update anomaly — to change one real-world fact you must edit many rows; miss one → inconsistency.
  • Delete anomaly — deleting one row accidentally destroys an unrelated fact.

WHY do these happen? Because we crammed two independent facts into one row. The fix is always the same recipe: find the dependency that doesn't belong, and split it into its own table. The normal forms just tell you which dependency is the offender.


Functional dependencies: the language of the whole topic

HOW do you read a table's FDs? List the real-world rules ("a student has one advisor", "an advisor belongs to one department") — those are the FDs.


The four forms — each kills the next-worse dependency

Form Forbids (the offending FD XAX \to A) Plain meaning
1NF non-atomic / repeating values every cell holds one value
2NF AA non-prime, XX a proper part of a key no partial dependency
3NF XX not a superkey and AA non-prime no transitive dependency
BCNF XX not a superkey (period) every determinant is a superkey

1NF — atomic values


2NF — no partial dependency

WHY it only bites composite keys: a partial dependency needs a key with ≥2 columns so a "part" exists. If your key is a single column, you're automatically in 2NF.


3NF — no transitive dependency


BCNF — every determinant is a superkey

WHY stronger than 3NF: 3NF allows a determinant that isn't a superkey as long as the dependent attribute is prime. BCNF removes that loophole.

Figure — Normalization — 1NF, 2NF, 3NF, BCNF — anomalies each resolves


Recall Feynman: explain to a 12-year-old

Imagine a notebook where, every time a friend visits, you rewrite their full phone number, home address, and birthday on a new line. If your friend moves house, you must hunt down every line and fix the address — miss one and your notebook now disagrees with itself. Normalization says: write each fact in its own little table once. Friends' addresses live in an "Address book", visits live in a "Visit log" that just points to the friend by name. Change an address in one place — done. Each normal form (1, 2, 3, BCNF) is just a stricter rule for "is this fact written in the right book?"


Active recall

What does XYX \to Y (functional dependency) mean?
If two rows agree on XX they must agree on YY; XX determines YY.
What is a prime attribute?
An attribute that belongs to at least one candidate key.
1NF requires what?
Every attribute value is atomic — no repeating groups, lists, or nested relations.
A relation with a single-attribute candidate key is automatically in which form?
2NF (partial dependency needs a proper subset of a composite key).
Define a partial dependency.
A non-prime attribute depending on a proper subset of a candidate key (violates 2NF).
Define a transitive dependency.
A non-prime attribute depending on another non-prime attribute (violates 3NF).
State the 3NF condition for FD XAX\to A, AA non-prime.
XX is a superkey OR AA is prime.
State the BCNF condition.
For every non-trivial FD XAX\to A, XX must be a superkey (no "prime" exception).
Why can 3NF ⊄ BCNF?
3NF allows a non-superkey determinant if the dependent attribute is prime; BCNF forbids it.
Which form may sacrifice dependency preservation?
BCNF — its decomposition can fail to keep all FDs; 3NF always can be made dependency-preserving.
Name the three anomaly types normalization fixes.
Insert, Update (modification), and Delete anomalies.
In Teach(Student,Subject,Teacher) with Teacher→Subject, why is it 3NF but not BCNF?
Subject is prime (3NF loophole satisfied), but Teacher is not a superkey (BCNF violated).
What is the inclusion ordering of the forms?
BCNF ⊂ 3NF ⊂ 2NF ⊂ 1NF (BCNF is strictest).

Connections

  • Functional Dependencies — the algebra underneath every normal form.
  • Candidate Keys and Superkeys — needed to test 2NF/3NF/BCNF.
  • Decomposition — Lossless Join and Dependency Preservation — the quality of a split.
  • Denormalization for Performance — the deliberate reverse trade-off.
  • ER Modeling — good ER designs are often already in 3NF.
  • Indexes and Joins — why over-normalizing can hurt read speed.

Concept Map

causes

includes

includes

includes

defines

attributes are

removes

uses language of

step 1

forbids partial dep

forbids transitive dep

every determinant a superkey

checks

Duplicated facts in one row

Anomalies

Insert anomaly

Update anomaly

Delete anomaly

Functional dependency X to Y

Candidate key

Prime vs non-prime

Normalization

1NF atomic values

2NF

3NF

BCNF

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, normalization ka pura funda ek hi line me hai: har fact database me sirf ek baar store hona chahiye. Jab ek hi fact do jagah likha ho — jaise har enrollment row me student ka naam dobara-dobara — to problem aati hai. Naam change karna ho to saari rows edit karni padti hain (update anomaly), aakhri row delete kar do to naam hi gayab (delete anomaly), aur bina course liye student add hi nahi kar sakte (insert anomaly). Yeh teen anomalies hi sab gadbad ki jadd hain.

Har normal form ek khaas type ki duplication ko maarta hai. 1NF kehta hai cell me ek hi value rakho, list/array nahi. 2NF kehta hai koi non-prime attribute composite key ke part pe depend na kare (partial dependency hatao) — yaad rakho, agar key single column hai to 2NF automatic mil jaata hai. 3NF kehta hai non-prime attribute kisi doosre non-prime attribute pe depend na kare (transitive dependency hatao, jaise EmpID → DeptID → DeptCity). BCNF sabse strict: har determinant ek superkey hona chahiye, koi "prime ho to chhoot" wala loophole nahi.

Yaad rakhne ka simple mantra: "The Key, the Whole Key, and Nothing but the Key." Aur ordering: BCNF ⊂ 3NF ⊂ 2NF ⊂ 1NF — BCNF sabse tight hai. Par ek practical baat: zaroorat se zyada normalize karoge to bahut saare JOIN lagenge aur read slow ho jayega; kabhi-kabhi BCNF dependency-preservation tod deta hai, isliye 3NF aksar real-world ka sweet spot hota hai. Exam me ek classic trap: Teach(Student, Subject, Teacher) with Teacher → Subject — yeh 3NF me hai (kyunki Subject prime hai) par BCNF me nahi (Teacher superkey nahi). Is example ko ratt lo, har jagah poochha jaata hai.

Go deeper — visual, from zero

Test yourself — Databases

Connections