Lecture 7 — Functional Dependencies & Normalization

Functional dependencies, the three anomalies, 1NF → 2NF → 3NF (informal and formal), BCNF including the classic 3NF-but-not-BCNF table, and validation with merits & demerits.

Sections

Quick summary

FD  X → Y : if two rows agree on X they must agree on Y.
   X = determinant, Y = dependent.  X → Y does NOT mean Y → X.
   Student_ID → Name, Program  ✔   ·   Name → Student_ID  ✘ (two students share a name).
   FDs are used to remove redundancy, avoid anomalies, find candidate keys, decompose tables.

ANOMALIES from one big table:  UPDATE (change in many rows) · INSERTION (can't add a course
   with no student) · DELETION (dropping the last row loses the course).

1NF: atomic values · NO repeating groups (Course_1..Course_3) · every row unique (define a PK).
2NF: 1NF + NO PARTIAL dependency (non-key depending on PART of a composite key).
     Single-attribute key ⇒ automatically 2NF.
3NF: 2NF + NO TRANSITIVE dependency (Key → Non-key → Non-key).
     FORMAL: for every X → Y, X is a SUPER KEY or Y is a PRIME attribute.
     Allowed: super→prime · super→non-prime · non-super→PRIME.
     NOT allowed: non-super key → non-prime attribute.
BCNF: for EVERY non-trivial X → Y, X must be a SUPER KEY (stronger than 3NF).
     A table can be in 3NF but NOT in BCNF (non-super key → prime attribute).

VALIDATION: lossless join (R1 ∩ R2 must be a key of R1 or R2) · dependency preservation ·
   normal-form checking.
MERITS: less redundancy · consistency · no update/insert/delete anomalies · integrity.
DEMERITS: more tables · more joins · slower queries · complex design · poor for reporting
   (→ denormalize for analytics).