Skip to content

Normalisation

A functional dependency X→YX \to Y holds on relation RR if for any two tuples t1,t2t_1, t_2 in RR t1[X]=t2[X]t_1[X] = t_2[X] implies t1[Y]=t2[Y]t_1[Y] = t_2[Y].

Armstrong”s axioms:

  1. Reflexivity: If Y⊆XY \subseteq XThen X→YX \to Y.
  2. Augmentation: If X→YX \to YThen XZ→YZXZ \to YZ.
  3. Transitivity: If X→YX \to Y and Y→ZY \to ZThen X→ZX \to Z.

Derived rules:

  1. Union: If X→YX \to Y and X→ZX \to ZThen X→YZX \to YZ.
  2. Decomposition: If X→YZX \to YZThen X→YX \to Y and X→ZX \to Z.
  3. Pseudotransitivity: If X→YX \to Y and YW→ZYW \to ZThen XW→ZXW \to Z.

Attribute closure. X+X^+ is the set of all attributes functionally determined by XX. Computed By starting with XX and repeatedly applying Armstrong’s axioms until no new attributes can be added.

Theorem 4.1. X→YX \to Y holds if and only if Y⊆X+Y \subseteq X^+.

First Normal Form (1NF). All attribute values are atomic (indivisible). No repeating groups or Nested relations.

Second Normal Form (2NF). In 1NF, and no non-prime attribute is partially dependent on any Candidate key. Equivalently: every non-prime attribute is fully functionally dependent on every Candidate key.

A partial dependency is A→BA \to B where AA is a proper subset of a candidate key and BB is Non-prime.

Third Normal Form (3NF). In 2NF, and for every non-trivial FD X→AX \to A in RREither XX is a Superkey or AA is a prime attribute.

A prime attribute is an attribute that belongs to some candidate key.

Boyce-Codd Normal Form (BCNF). For every non-trivial FD X→AX \to A in RR, XX is a superkey.

Theorem 4.2. Every relation in BCNF is in 3NF, but the converse does not hold.

Proof. BCNF requires XX to be a superkey for every non-trivial FD X→AX \to A. 3NF allows XX to be A superkey or AA to be prime. Since the BCNF condition is stricter, every BCNF relation is in 3NF. For the converse, consider R(A,B,C)R(A, B, C) with FDs AB→CAB \to C and C→BC \to B. Candidate keys: AB\\{AB\\}, AC\\{AC\\}. C→BC \to B does not violate 3NF (BB is prime) but violates BCNF (CC is not a Superkey). ■\blacksquare

A decomposition of RR into R1,R2,…,RkR_1, R_2, \ldots, R_k must satisfy:

  1. Lossless-join: R=R1⋈R2⋈⋯⋈RkR = R_1 \bowtie R_2 \bowtie \cdots \bowtie R_k. No information is lost.
  2. Dependency preservation: Every FD in the original schema is implied by the FDs in the decomposed schemas.

Theorem 4.3 (Lossless-join test). A decomposition of RR into R1,R2R_1, R_2 is lossless if and Only if R1∩R2→R1R_1 \cap R_2 \to R_1 or R1∩R2→R2R_1 \cap R_2 \to R_2.

Proof. Let rr be an instance of RR and let r1=πR1(r)r_1 = \pi_{R_1}(r), r2=πR2(r)r_2 = \pi_{R_2}(r). We must Show r=r1⋈r2r = r_1 \bowtie r_2 under the given condition. Since r1r_1 and r2r_2 are projections of rr Every tuple in r1⋈r2r_1 \bowtie r_2 agrees with some tuple of rr on every attribute. It suffices to show That no spurious tuple is produced. Suppose (t1,t2)∈r1⋈r2(t_1, t_2) \in r_1 \bowtie r_2 where t1∈r1t_1 \in r_1 and t2∈r2t_2 \in r_2. Since t1t_1 and t2t_2 agree on R1∩R2R_1 \cap R_2And by the condition R1∩R2→R1R_1 \cap R_2 \to R_1 (WLOG), there exists T′∈rT' \in r with T′[R1∩R2]=t1[R1∩R2]=t2[R1∩R2]T'[R_1 \cap R_2] = t_1[R_1 \cap R_2] = t_2[R_1 \cap R_2]. Since T′[R1∩R2]=t1[R1∩R2]T'[R_1 \cap R_2] = t_1[R_1 \cap R_2] and R1∩R2→R1R_1 \cap R_2 \to R_1, we have t′[R1]=t1[R1]t'[R_1] = t_1[R_1]. Similarly t′[R2]=t2[R2]t'[R_2] = t_2[R_2]. Thus (t1,t2)(t_1, t_2) corresponds to a real tuple t′∈rt' \in rSo no spurious tuple exists. ■\blacksquare

Dependency preservation. Let FF be the set of FDs for RR. The decomposition R1,…,RkR_1, \ldots, R_k Preserves dependencies if the closure of ⋃i=1kFi+\bigcup_{i=1}^{k} F_i^+ (where FiF_i is the restriction Of FF to RiR_i) equals F+F^+. In practice, we check that every FD in a minimal cover of FF can be Tested within a single RiR_i.

Dependency preservation is important for efficient constraint checking: when updating RiR_iThe DBMS can verify relevant FDs locally without joining all decomposed relations.

Example 1. Enrolment(StudentID, CourseID, StudentName, Dept, Grade) with FDs: StudentID→StudentName\mathrm{StudentID} \to \mathrm{StudentName}, StudentID→Dept\mathrm{StudentID} \to \mathrm{Dept} StudentID,CourseID→Grade\\{\mathrm{StudentID}, \mathrm{CourseID}\\} \to \mathrm{Grade}.

  • Candidate key: StudentID,CourseID\\{\mathrm{StudentID}, \mathrm{CourseID}\\}.
  • 1NF: satisfied (atomic values).
  • 2NF violation: StudentID→StudentName\mathrm{StudentID} \to \mathrm{StudentName} is a partial dependency (StudentID is a proper subset of the key).
  • Decompose: Student(StudentID, StudentName, Dept) and Enrolment(StudentID, CourseID, Grade). Both are in 3NF and BCNF.

Example 2 (3NF but not BCNF). CourseOffering(Course, Instructor, Room, Time) with FDs: Course,Time→Instructor,Room\\{\mathrm{Course}, \mathrm{Time}\\} \to \\{\mathrm{Instructor}, \mathrm{Room}\\} Instructor→Room\mathrm{Instructor} \to \mathrm{Room}.

  • Candidate key: Course,Time\\{\mathrm{Course}, \mathrm{Time}\\}.
  • 3NF: Instructor→Room\mathrm{Instructor} \to \mathrm{Room} — Instructor is not a superkey, but Room is not prime. Wait — Room is not prime (not in any candidate key). So this actually violates 3NF too.

Let us correct: CourseOffering(Course, Instructor, Textbook) with FDs: Course→Instructor\mathrm{Course} \to \mathrm{Instructor} Instructor→Textbook\mathrm{Instructor} \to \mathrm{Textbook}.

  • Candidate key: Course\\{\mathrm{Course}\\} (since Course determines everything transitively).
  • 3NF: Instructor→Textbook\mathrm{Instructor} \to \mathrm{Textbook}. Instructor is not a superkey. Textbook is not prime. Violates 3NF.

Better example. Class(Course, Instructor, Student) with FDs: Course,Student→Instructor\\{\mathrm{Course}, \mathrm{Student}\\} \to \mathrm{Instructor} Instructor→Course\mathrm{Instructor} \to \mathrm{Course}.

  • Candidate keys: Course,Student\\{\mathrm{Course}, \mathrm{Student}\\}, Instructor,Student\\{\mathrm{Instructor}, \mathrm{Student}\\}.
  • 3NF check for Instructor→Course\mathrm{Instructor} \to \mathrm{Course}: Instructor is not a superkey. But Course is prime (in candidate key Course,Student\\{\mathrm{Course}, \mathrm{Student}\\}). So 3NF is satisfied.
  • BCNF check: Instructor→Course\mathrm{Instructor} \to \mathrm{Course} violates BCNF (Instructor is not a superkey).

Decompose: Teaches(Instructor, Course) and Attends(Instructor, Student). This is lossless (Instructor\mathrm{Instructor} is common and Instructor→Course\mathrm{Instructor} \to \mathrm{Course} holds in Teaches). But the dependency Course,Student→Instructor\\{\mathrm{Course}, \mathrm{Student}\\} \to \mathrm{Instructor} is Not preserved.

Theorem 4.4. Not every relation can be decomposed into BCNF while preserving dependencies. 3NF Is the strongest normal form guaranteeing dependency-preserving, lossless-join decomposition.

Worked Example 4.1: BCNF Decomposition Algorithm

Relation: R(A,B,C,D,E)R(A, B, C, D, E) with FDs F=A→B,BC→E,ED→AF = \\{A \to B, BC \to E, ED \to A\\}.

Step 1. Find candidate keys. Compute A+=A,BA^+ = \\{A, B\\}. BC+=B,C,E,D,A=A,B,C,D,EBC^+ = \\{B, C, E, D, A\\} = \\{A, B, C, D, E\\}. So BCBC is a candidate key. Check EDED: ED+=E,D,A,B,C=A,B,C,D,EED^+ = \\{E, D, A, B, C\\} = \\{A, B, C, D, E\\}. So EDED is Also a candidate key. Prime attributes: B,C,D,EB, C, D, E.

Step 2. Check BCNF. A→BA \to B: AA is not a superkey (since A+≠RA^+ \neq R). Violates BCNF. Decompose on A→BA \to B: R1=A,BR_1 = \\{A, B\\} and R2=A,C,D,ER_2 = \\{A, C, D, E\\}.

Step 3. R1=A,BR_1 = \\{A, B\\} is in BCNF (FD A→BA \to B with AA as superkey).

For R2=A,C,D,ER_2 = \\{A, C, D, E\\} with FDs restricted to R2R_2: BC→EBC \to E involves BB which is not in R2R_2 So it is dropped. ED→AED \to A holds. Also, A→BA \to B involves BB not in R2R_2So it is dropped. Check for implied FDs: A→BA \to B in RR implies AC→BCAC \to BC (augmentation), so AC→EAC \to E in RR (since BC→EBC \to E). But ACAC is not a superkey of R2R_2… Wait, let us recheck.

Actually, from BC→EBC \to E and the fact that BB is not in R2R_2We cannot directly use BC→EBC \to E In R2R_2. We should compute the projection of FF onto R2R_2: F2=ED→A,A→∅F_2 = \\{ED \to A, A \to \varnothing\\}. So the only non-trivial FD in R2R_2 is ED→AED \to A. Is EDED a superkey of R2R_2? ED+=E,D,A≠A,C,D,EED^+ = \\{E, D, A\\} \neq \\{A, C, D, E\\} (missing CC). So EDED is not a superkey of R2R_2.

Hmm, we need to be more careful. Let us check if CC is determined by EDED in the original RR. ED+ED^+ in R=E,D,A,BR = \\{E, D, A, B\\}Which does not include CC. So CC is not determined.

This means R2=A,C,D,ER_2 = \\{A, C, D, E\\} has no non-trivial FDs that hold (other than keys determining all Attributes). Check: candidate keys of R2R_2 must be superkeys. Since ED→AED \to A holds but EDED does Not determine CCWe need EDCEDC as a key: EDC+=E,D,C,A,B=REDC^+ = \\{E, D, C, A, B\\} = R (all of RR). So in R2R_2, EDCEDC is a candidate key (since it determines all attributes of R2R_2: EDC→AEDC \to A and A→∅A \to \varnothing in R2R_2, so EDC+=A,C,D,EEDC^+ = \\{A, C, D, E\\}). R2R_2 is in BCNF since the only non-trivial FD is ED→AED \to A and we need to check if EDED is a superkey of R2R_2. Since ED+∩R2=A,D,E≠R2ED^+ \cap R_2 = \\{A, D, E\\} \neq R_2, EDED is not a superkey.

But wait — there are no other non-trivial FDs in R2R_2. The only one is ED→AED \to AWhich violates BCNF. Decompose: R2a=E,D,AR_{2a} = \\{E, D, A\\} and R2b=A,C,D,E∖E,D,A=CR_{2b} = \\{A, C, D, E\\} \setminus \\{E, D, A\\} = \\{C\\}.

Hmm, C\\{C\\} alone is a relation with no non-trivial FDs, so it is in BCNF. R2a=E,D,AR_{2a} = \\{E, D, A\\} With ED→AED \to A: EDED is a superkey (it determines all three attributes). BCNF.

Final decomposition: R1=A,BR_1 = \\{A, B\\}, R2a=A,D,ER_{2a} = \\{A, D, E\\}, R2b=CR_{2b} = \\{C\\}.

Lossless check: R1∩R2a=AR_1 \cap R_{2a} = \\{A\\}, A→BA \to B (from FF), so R1⋈R2aR_1 \bowtie R_{2a} is lossless. R2a∩R2b=∅R_{2a} \cap R_{2b} = \varnothing… This is problematic. R2b=CR_{2b} = \\{C\\} shares no attributes with The others.

The issue is that CC is a “dangling” attribute. This is correct — CC appears only in the key BCBC Of the original relation but is not functionally determined by anything except the full key. The Decomposition is technically correct but R2b=CR_{2b} = \\{C\\} by itself cannot be joined losslessly with The others.

This illustrates a limitation of BCNF decomposition: it may produce a relation with no common Attributes, making lossless join impossible to verify with the pairwise test. In practice, the 3NF Synthesis algorithm avoids this issue.

:::caution Common Pitfall Do not confuse partial dependency (2NF violation) with transitive dependency (3NF violation). A Partial dependency involves a proper subset of a candidate key determining a non-prime attribute. A transitive dependency involves a non-key attribute determining another non-prime attribute.

A multivalued dependency (MVD) X↠YX \twoheadrightarrow Y holds on relation RR if for any two Tuples t1,t2∈Rt_1, t_2 \in R with t1[X]=t2[X]t_1[X] = t_2[X]There exists a tuple t3∈Rt_3 \in R such that:

  • t3[X]=t1[X]t_3[X] = t_1[X]
  • t3[Y]=t1[Y]t_3[Y] = t_1[Y]
  • t3[R−X−Y]=t2[R−X−Y]t_3[R - X - Y] = t_2[R - X - Y]

: XX determines YY independently of R−X−YR - X - Y.

Trivial MVDs: X↠YX \twoheadrightarrow Y where Y⊆XY \subseteq X or X∪Y=RX \cup Y = R.

Fourth Normal Form (4NF). RR is in 4NF if for every non-trivial MVD X↠YX \twoheadrightarrow Y That holds on RR, XX is a superkey.

Theorem 4.5. Every relation in 4NF is in BCNF.

Proof. Every FD X→YX \to Y implies the MVD X↠YX \twoheadrightarrow Y. In 4NF, every non-trivial MVD X↠YX \twoheadrightarrow Y requires XX to be a superkey. Therefore, every non-trivial FD X→YX \to Y Also requires XX to be a superkey, which is the BCNF condition. ■\blacksquare

4NF decomposition. Given RR with MVD X↠YX \twoheadrightarrow Y where XX is not a superkey, Decompose into R1=X∪YR_1 = X \cup Y and R2=R−YR_2 = R - Y. The decomposition is lossless-join.

Worked Example 4.2: Decomposition to 4NF

Relation: CourseInstructor(Course, Instructor, Textbook) where each course can have multiple Instructors and multiple textbooks, independently.

MVDs: Course↠Instructor\mathrm{Course} \twoheadrightarrow \mathrm{Instructor} Course↠Textbook\mathrm{Course} \twoheadrightarrow \mathrm{Textbook}.

Sample data:

CourseInstructorTextbook
CS101SmithDB Systems
CS101LeeDB Systems
CS101SmithAlgorithm Design
CS101LeeAlgorithm Design

The redundancy is clear: each instructor-textbook pair is repeated for each course.

4NF check: Course↠Instructor\mathrm{Course} \twoheadrightarrow \mathrm{Instructor} is non-trivial, and Course\mathrm{Course} is not a superkey. Violates 4NF.

Decompose:

  • CI(Course, Instructor) with MVD Course↠Instructor\mathrm{Course} \twoheadrightarrow \mathrm{Instructor}
  • CT(Course, Textbook) with MVD Course↠Textbook\mathrm{Course} \twoheadrightarrow \mathrm{Textbook}

Both are in 4NF (the determining attribute Course is a candidate key in each).

:::