17 - BCNF & Higher Normal Forms
1872 words
9 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# 17 - BCNF & Higher Normal Forms ## 🎯 Learning Objectives After reading this topic, you will be able to: - Define BCNF and check if a relation satisfies it - Decompose a relation into BCNF - Identify multivalued dependencies (MVDs) and 4NF violations - Understand 5NF (PJNF) and join dependencies - Explain temporal...

17 - BCNF & Higher Normal Forms
🎯 Learning Objectives
After reading this topic, you will be able to:
- Define BCNF and check if a relation satisfies it
- Decompose a relation into BCNF
- Identify multivalued dependencies (MVDs) and 4NF violations
- Understand 5NF (PJNF) and join dependencies
- Explain temporal databases (valid time vs. transaction time)
📋 Prerequisites
- 16 - Normalization (1NF-3NF) — 3NF, candidate keys, FDs
📖 Core Content
17.1 Intuition: 3NF Isn't Good Enough
3NF still allows some redundancy. Consider:
CKs = {A,B} and {A,C}. This is in 3NF (all attributes are prime). But if C→B and C isn't a superkey, the same B value repeats for every A associated with C — redundancy!
BCNF (Boyce-Codd Normal Form) tightens the rule: every LHS must be a superkey.
Why This Matters: BCNF is the gold standard for most practical schemas. While 3NF preserves all FDs, BCNF may not — but it eliminates virtually all redundancy from FDs.
17.2 BCNF Definition
Definition: A relation R is in BCNF if for every non-trivial FD X→A:
Comparison:
| Normal Form | Condition for FD X→A |
|---|---|
| 3NF | X is a superkey OR A is prime |
| BCNF | X is a superkey (strict!) |
BCNF = remove the "or A is prime" exception from 3NF.
17.3 BCNF Decomposition Algorithm
pseudoInput: R (relation), F (FD set) Output: Decomposition of R into BCNF relations 1. Compute closure F⁺ 2. Find an FD X → Y in F that violates BCNF (X is not a superkey) 3. Compute X⁺ 4. Decompose R into: - R₁ = X⁺ (contains the violating FD) - R₂ = R - (X⁺ - X) ∪ X (remaining attributes + X) 5. Repeat on R₁ and R₂ until all relations are in BCNF
Worked Example
R(A,B,C) with F={AB→C,C→B}
Step 1: Find violating FD.
- CKs = {A,B} and {A,C}
- Check C→B: C⁺ = {B,C} ≠ R. C is NOT a superkey. Violation! Step 2: Compute C⁺ = {B, C} Step 3: Decompose:
- R1=C+={B,C} (covers C→B)
- R2=R−(C+−C)∪C={A,B,C}−{B}∪{C}={A,C} Step 4: Check BCNF for R1(B,C):
- FDs: C→B
- CK of R₁: {C}. C is a superkey for R₁. ✓
- R₁ is in BCNF. Step 5: Check BCNF for R2(A,C):
- No non-trivial FDs (A and C have no FD between them)
- CK = {A, C}. R₂ is in BCNF. Result: BCNF decomposition = R1(B,C), R2(A,C) Note: AB→C is NOT preserved (we lost the connection between A and B). BCNF guarantees lossless join but NOT dependency preservation.
17.4 Multivalued Dependencies (MVDs)
An MVD X→→Y means that knowing X determines a SET of Y values, independent of other attributes.
Example: An employee can have multiple dependents AND multiple projects:
| emp_id | dependent | project |
|---|---|---|
| 1 | Alice | Alpha |
| 1 | Alice | Beta |
| 1 | Bob | Alpha |
| 1 | Bob | Beta |
This isn't an FD (emp_id doesn't determine a single dependent or project). But there's an MVD: empid→→dependent (and empid→→project).
MVD Definition: X→→Y holds if, for every pair of tuples t1 and t2 with t1[X]=t2[X], there exists a tuple t3 such that:
- t3[X]=t1[X]
- t3[Y]=t1[Y]
- t3[R−XY]=t2[R−XY]
17.5 Fourth Normal Form (4NF)
Definition: A relation is in 4NF if:
- It is in BCNF
- For every non-trivial MVD X→→Y, X is a superkey Worked Example: The employee-dependent-project table above:
- emp_id is NOT a superkey (emp_id alone doesn't determine a unique row)
- MVDs exist: empid→→dependent, empid→→project
- This violates 4NF Fix: Decompose into R1(empid,dependent) and R2(empid,project).
17.6 Fifth Normal Form (5NF / PJNF)
5NF (also called Project-Join Normal Form) deals with join dependencies. A join dependency means a relation can be reconstructed by joining its projections.
Definition: A relation is in 5NF if for every non-trivial join dependency, every component of the join is a superkey.
Practical note: 5NF is rarely violated in practice. If you've reached 4NF, you're usually in 5NF as well.
17.7 Comparison of Normal Forms
| NF | Condition | Redundancy Removed | FD/MVD Preserved? |
|---|---|---|---|
| 1NF | Atomic attributes | Multi-valued attrs | N/A |
| 2NF | No partial dependency | Redundancy from partial FDs | Yes |
| 3NF | No transitive dependency | Redundancy from transitive FDs | Yes |
| BCNF | Every LHS is a superkey | All FD redundancy | Not always |
| 4NF | Every MVD has superkey LHS | MVD redundancy | Not always |
| 5NF | Every JD has superkey components | JD redundancy | Not always |
17.8 Temporal Databases
Temporal databases store time-varying data with associated timestamps.
| Time Type | Meaning | Example |
|---|---|---|
| Valid time | When the fact was true in the real world | "Alice was a CS student from 2020-2024" |
| Transaction time | When the fact was stored in the database | "The record was inserted at 2024-01-15 10:30:00" |
| Bitemporal | Both valid and transaction time | Complete historical tracking |
Temporal relation: Each tuple has associated time intervals.
- Valid time allows historical queries ("Show me the department structure as of Jan 2020")
- Transaction time supports rollback queries ("Show me what the database looked like yesterday")
📐 Key Formulas / Concepts
| Form | Test | Decomposition |
|---|---|---|
| BCNF | For every FD X→A , X is a superkey | Split on violating FD: (X+) and (R−X+∪X) |
| 4NF | For every MVD X→→Y , X is a superkey | Split on violating MVD: (X,Y) and (X,R−Y) |
| 5NF | For every JD, all components are superkeys | Complex; rarely needed |
⚠️ Common Pitfalls
Pitfall 1: Thinking BCNF is Always Better Than 3NF
The Mistake: Always trying to achieve BCNF at all costs.
Why It's Wrong: BCNF may not preserve all FDs. Sometimes 3NF is the practical choice because it guarantees dependency preservation while BCNF doesn't.
Trade-off: 3NF = All FDs preserved + some redundancy; BCNF = No FD redundancy + possible FD loss.
Pitfall 2: Confusing MVDs with FDs
The Mistake: Treating X→→Y like X→Y.
Why It's Wrong: FDs map X to a SINGLE Y value; MVDs map X to a SET of Y values independent of other attributes.
Memory Aid: FD = "one value"; MVD = "a set of values."
Pitfall 3: Decomposing Without Checking BCNF First
The Mistake: Jumping to 4NF/5NF decomposition when the issue is really a BCNF violation.
Fix: Check BCNF first, then 4NF (for MVDs), then 5NF (for JDs). Most real-world schemas only need BCNF.
📝 Practice Questions
Q1. Is R(A,B,C) with F={A→B,C→B} in BCNF?
AnswerCandidate key: {A, C} ({A,C}+ = {A,B,C} = R).Check FDs:
- A→B: A is NOT a superkey (A+ = {A,B} ≠ R). Violation!
- C→B: C is NOT a superkey (C+ = {B,C} ≠ R). Violation!
R is NOT in BCNF (but is in 3NF — check: A→B, A is not a superkey but B? B is non-prime... Actually wait — CK = {A,C}, so prime = {A,C}, B is non-prime. 3NF requires X superkey or A prime. Neither holds. So it's NOT in 3NF either.)
Q2. Check BCNF for R(A,B,C,D) with F={A→B,AC→D}.
AnswerCandidate key: {A, C} ({A,C}+ = {A,B,C,D} = R).Check FDs:
- A→B: A is NOT a superkey (A+ = {A,B} ≠ R). BCNF violation!
- AC→D: {A,C} is a superkey. ✓
Decompose on A→B:
- A+ = {A, B}
- R1(A,B), R2(A,C,D)
Check R2: CK = {A, C}. FD AC→D: AC is a superkey. ✓. R₂ is in BCNF.BCNF decomposition: R1(A,B), R2(A,C,D)
Q3. What is a multivalued dependency? How does it differ from an FD?
Answer
- FD (X→Y): Each X value maps to exactly ONE Y value
- MVD (X→→Y): Each X value maps to a SET of Y values, independent of other attributes
MVDs arise when a relation has two or more independent multi-valued attributes. Example: An employee has multiple dependents AND multiple projects — these are independent.
Q4. What is 4NF? Give an example of a 4NF violation.
AnswerA relation is in 4NF if it's in BCNF and for every non-trivial MVD X→→Y, X is a superkey.Violation example:
| emp_id | skill | dependent |
|---|---|---|
| 1 | Python | Alice |
| 1 | Java | Alice |
| 1 | Python | Bob |
| 1 | Java | Bob |
MVDs: empid→→skill,empid→→dependent emp_id is not a superkey (many rows per emp_id).Fix: Decompose into R1(empid,skill) and R2(empid,dependent).
Q5. Compare 3NF and BCNF. When would you choose 3NF over BCNF?
Answer
| Aspect | 3NF | BCNF |
|---|---|---|
| Condition | Superkey OR prime RHS | Superkey always |
| FD preservation | Always | Not always |
| Redundancy | Some possible | Minimal |
| Decomposition | Always dependency-preserving | May lose FDs |
Choose 3NF when you need all FDs preserved and the redundancy from the "prime RHS exception" is acceptable. Choose BCNF when eliminating all FD redundancy is critical.
Q6. What is a join dependency? How does it relate to 5NF?
AnswerA join dependency (JD) means a relation can be reconstructed by joining its projections.A relation is in 5NF (PJNF) if for every non-trivial JD, every component of the JD is a superkey.In practice, if a relation is in 4NF and has no composite keys, it's almost certainly in 5NF. 5NF violations usually require specific constraints involving overlapping composite keys.
Q7. Explain valid time vs. transaction time in temporal databases.
Answer
- Valid time: When the fact was true in the real world (e.g., "Alice was employed from Jan 2020 to Dec 2023"). Useful for historical queries.
- Transaction time: When the fact was stored in the database (e.g., "this record was inserted at 10:30 AM on Jan 15"). Useful for audit and rollback queries.
A bitemporal relation stores both — allowing questions like "Show me the database state as of yesterday that reflects the real-world state in 2020."
Q8. Decompose R(A,B,C,D) with F={A→B,B→C} into BCNF.
AnswerCandidate key: {A, D} ({A,D}+ = {A,B,C,D}).Violation: A→B (A not a superkey). Also B→C (B not a superkey).Decompose on A→B:
- A+ = {A, B, C}
- R1(A,B,C) with FDs: A→B,B→C. CK = {A}.
Check R1: B→C — B is NOT a superkey for R₁ (B+ = {B,C} ≠ {A,B,C}). Violation!
- Decompose R₁ on B→C: R11(B,C), R12(A,B)
Result: R11(B,C), R12(A,B), R2(A,D)All in BCNF.
🔗 Cross-References
- Next Topic: 18 - Decomposition
- Previous Topic: 16 - Normalization (1NF-3NF)
- Related: 14 - Functional Dependencies (FD theory underpinning BCNF)
- Textbook: Silberschatz, Korth, Sudarshan — Chapter 8 (Relational Database Design) Join Discord Previous16 - Normalization (1NF-3NF)Next18 - Decomposition