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: empiโdโโdependent (and empiโdโโ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: empiโdโโdependent, empiโdโโproject
- This violates 4NF Fix: Decompose into R1โ(empiโd,dependent) and R2โ(empiโd,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: empiโdโโskill,empiโdโโdependent emp_id is not a superkey (many rows per emp_id).Fix: Decompose into R1โ(empiโd,skill) and R2โ(empiโd,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