Skip to main content

5.6 Equivalence of Functional Dependency Sets

📚Module 05: Functional Dependencies (FDs)Topic 5.6⏱️8 min read
🎯High-Yield For:University Semester Exams • Technical Interviews • Schema Verification & Refactoring

💡 Core Intuition​

Imagine a legal agreement written in English and the same agreement translated into French:

  • The sentence phrasing, grammar, and paragraph divisions look completely different.
  • However, two contracts are legally equivalent if and only if:
    1. Every single right guaranteed by the English contract can be legally enforced under the French contract.
    2. Every single right guaranteed by the French contract can be legally enforced under the English contract.
  • If either contract provides an extra loophole or misses a restriction, they are not equivalent.

💻 Bridging to Computer Science​

In database design, two different database engineers or automated schema migration tools may express the business constraints of a table using completely different sets of functional dependencies (FF and GG). We say FF and GG are Equivalent (F≡GF \equiv G) if both sets enforce the exact same logical constraints on data.



📚 Core Deep-Dive & Concepts​

1. Formal Mathematical Definition of Equivalence​

Two sets of functional dependencies FF and GG defined on a relation schema RR are Equivalent (denoted F≡GF \equiv G) if and only if their closures are strictly identical:

F+=G+F^+ = G^+

Because calculating the full closures F+F^+ and G+G^+ is exponentially expensive (O(2n)O(2^n)), we use the Mutual Containment Theorem:

F≡G  ⟺  (F⊆G)∧(G⊆F)F \equiv G \iff (F \subseteq G) \land (G \subseteq F)

What Does F⊆GF \subseteq G Mean Operationally?​

  • F⊆GF \subseteq G (read: "G covers F"): Every functional dependency α→β∈F\alpha \to \beta \in F can be logically derived using the dependencies in GG.
  • G⊆FG \subseteq F (read: "F covers G"): Every functional dependency γ→δ∈G\gamma \to \delta \in G can be logically derived using the dependencies in FF.

2. The 2-Phase Verification Algorithm​


3. Fully Solved Step-by-Step Numerical Problem​

Consider two functional dependency sets FF and GG defined on relation schema R(A,C,D,E,H)R(A, C, D, E, H):

Set FFSet GG
A→CA \to CA→CDA \to CD
AC→DAC \to DE→AHE \to AH
E→ADE \to AD
E→HE \to H

Goal: Determine whether FF and GG are mathematically equivalent (F≡GF \equiv G).


Phase 1: Test if F⊆GF \subseteq G (Does GG cover FF?)​

We must prove that every dependency in FF can be derived using only the rules of GG:

  1. Test A→CA \to C from FF:
    Compute A+A^+ with respect to GG:
    A→CD∈G  ⟹  A+={A,C,D}A \to CD \in G \implies A^+ = \{A, C, D\}
    Since C∈A+C \in A^+, A→CA \to C is satisfied by GG.

  2. Test AC→DAC \to D from FF:
    Compute (AC)+(AC)^+ with respect to GG:
    A→CD∈G  ⟹  (AC)+={A,C,D}A \to CD \in G \implies (AC)^+ = \{A, C, D\}
    Since D∈(AC)+D \in (AC)^+, AC→DAC \to D is satisfied by GG.

  3. Test E→ADE \to AD from FF:
    Compute E+E^+ with respect to GG:
    E→AH∈G  ⟹  E+={E,A,H}E \to AH \in G \implies E^+ = \{E, A, H\}
    A→CD∈G  ⟹  E+={E,A,H,C,D}A \to CD \in G \implies E^+ = \{E, A, H, C, D\}
    Since {A,D}⊆E+\{A, D\} \subseteq E^+, E→ADE \to AD is satisfied by GG.

  4. Test E→HE \to H from FF:
    From step 3, H∈E+H \in E^+ under GG.
    Since H∈E+H \in E^+, E→HE \to H is satisfied by GG.

Phase 1 Result: Every functional dependency in FF is derivable from GG.

F⊆G(Confirmed)\mathbf{F \subseteq G \quad \text{(Confirmed)}}

Phase 2: Test if G⊆FG \subseteq F (Does FF cover GG?)​

We must prove that every dependency in GG can be derived using only the rules of FF:

  1. Test A→CDA \to CD from GG:
    Compute A+A^+ with respect to FF:

    • A+={A}A^+ = \{A\}
    • A→C∈F  ⟹  {A,C}A \to C \in F \implies \{A, C\}
    • AC→D∈F  ⟹  {A,C,D}AC \to D \in F \implies \{A, C, D\}
      A+={A,C,D}A^+ = \{A, C, D\}
      Since {C,D}⊆A+\{C, D\} \subseteq A^+, A→CDA \to CD is satisfied by FF.
  2. Test E→AHE \to AH from GG:
    Compute E+E^+ with respect to FF:

    • E+={E}E^+ = \{E\}
    • E→AD∈F  ⟹  {E,A,D}E \to AD \in F \implies \{E, A, D\}
    • E→H∈F  ⟹  {E,A,D,H}E \to H \in F \implies \{E, A, D, H\}
      E+={E,A,D,H}E^+ = \{E, A, D, H\}
      Since {A,H}⊆E+\{A, H\} \subseteq E^+, E→AHE \to AH is satisfied by FF.

Phase 2 Result: Every functional dependency in GG is derivable from FF.

G⊆F(Confirmed)\mathbf{G \subseteq F \quad \text{(Confirmed)}}

Final Conclusion​

Because F⊆GF \subseteq G and G⊆FG \subseteq F:

F≡G(The sets are 100% Equivalent)\mathbf{F \equiv G \quad \text{(The sets are 100\% Equivalent)}}

📐 Architecture / Visual Blueprint​


🏭 In The Real World: Production Case Study​

Automated Database Refactoring Gates at Stripe & Meta​

When software teams maintain petabyte-scale data models across thousands of microservices:

  • The Risk: A team rewrites their database ORM schema to simplify relationships, changing the underlying table constraints from set FF to set GG.
  • The Disaster: If GG cannot enforce all dependencies of FF (F⊈GF \not\subseteq G), subtle data corruptions enter the ledger undetected.
  • The Automated Production CI/CD Gate: Build pipelines run formal relational equivalence checkers. If a pull request modifies database constraints, the pipeline extracts the FDs, runs the 2-phase mutual containment algorithm, and automatically blocks the PR if F+≠G+F^+ \neq G^+, ensuring zero regression in enterprise business invariants.

🎯 Exam & Interview Pitfall Check​

Core Conceptual Questions

Question 1: If ∣F∣=4|F| = 4 and ∣G∣=2|G| = 2, can FF and GG still be mathematically equivalent?
Answer:
Yes! The number of dependencies (cardinality of the set) has no bearing on equivalence. A set of 4 dependencies may contain redundant rules or split attributes (e.g. A→B,A→C,B→C,A→DA \to B, A \to C, B \to C, A \to D), while GG might express the exact same semantics compactly in just 2 dependencies (e.g. A→BD,B→CA \to BD, B \to C). If their closures are identical, they are equivalent.

Question 2: If Phase 1 reveals that F⊆GF \subseteq G, is it safe to immediately conclude that F≡GF \equiv G?
Answer:
No! F⊆GF \subseteq G only proves that GG can derive everything in FF. It does not prove that FF can derive everything in GG. GG might contain additional strict constraints that FF lacks (meaning GG is strictly more powerful than FF). You must complete Phase 2 to verify that G⊆FG \subseteq F.

Common Interview Traps

Trap 1: "To test F ⊆ G, do we compute closures under F or under G?"
Answer: Under G! To prove that GG covers FF, you must test whether the rules of GG have the power to derive the dependencies of FF. Hence, for each X→Y∈FX \to Y \in F, you compute X+X^+ using the dependencies in GG.

Trap 2: "Can two sets of FDs have different Candidate Keys and still be equivalent?"
Answer: Mathematically impossible. Candidate keys are derived directly from the attribute closures of the relation schema. If F≡GF \equiv G, then for every attribute set XX, its closure under FF (XF+X_F^+) is identical to its closure under GG (XG+X_G^+). Consequently, all candidate keys, superkeys, and prime attributes must be 100% identical.


💬

Discussion & Doubts