Equivalence of Functional Dependencies



Functional dependencies are quite useful while making databases and designing proper table relations. Functional dependencies define relationships between attributes in a table; they help in normalizing the tables and ensuring data consistency as well.

A common question in this domain is how to compare two sets of functional dependencies and determine if they are equivalent. Read this chapter to get a good understanding of the concept of equivalence of functional dependencies and explain how to determine if one set is a subset of another, or if both sets are the same.

What is Equivalence of Functional Dependencies?

Consider there are two sets of functional dependencies, F and G. They are considered equivalent if −

  • Every dependency in F can be derived from G.
  • Every dependency in G can be derived from F.

In other words, F ⊆ G and G ⊆ F. If both conditions hold, then F and G are equal.

The Importance of Equivalence

It is important to have a good understanding of the concept of "equivalence" while designing databases or while performing normalization and query optimization. It ensures that dependencies are not repeated and helps to compare alternative dependency sets to see if they represent the same relationship.

How to Compare Two Sets of Functional Dependencies?

To check whether two Functional Dependencies are equivalent, we can use the "closure of attributes". The closure of an attribute set is the set of attributes that can be determined using the given functional dependencies.

The process involves −

  • Calculating closures for attributes using one set of dependencies.
  • Verifying if these closures match when computed using the other set.
  • Repeating the process with the roles reversed to ensure equivalence.

Step-by-Step Example

Let us see one example for a relational schema R with attributes and two sets of functional dependencies F and G

Set F Set G
  • A → C
  • AC → D
  • E → AH
  • A → CD
  • E → AH

We will check if F and G are equivalent or not.

Step 1: Compute Closures Using G

We start by computing the closure of each attribute or attribute combination from F. Here we calculate them using the functional dependencies in G.

Closure of A Using G

  • A is in the closure by itself
  • A → CD (from G): Add C and D to the closure
  • Closure of A is: {A, C, D}

Closure of AC Using G

  • Start with AC
  • A → CD (from G): Add C and D to the closure
  • Closure of AC: {A, C, D}

Closure of E Using G

  • E is in the closure by itself
  • E → AH (from G): Add A and H
  • A → CD (from G): Add C and D using A

Closure of E: {E, A, H, C, D}

At this point, we have computed closures for A, AC, and E using G.

Step 2: Verify F ⊆ G

Now, we check if F’s dependencies are covered by G −

Dependency A → C from F

  • Closure of A using G: {A, C, D}
  • C is in the closure, so A → C is valid in G

Dependency AC → D from F

  • Closure of AC using G: {A, C, D}
  • D is in the closure, so AC → D is valid in G

Dependency E → A, H from F

  • Closure of E using G: {E, A, H, C, D}
  • A and H are in the closure, so E → A, H is valid in G

Since all dependencies in F can be derived from G, F ⊆ G is true.

Step 3: Compute Closures Using F

Next, we compute closures for attributes in G, but this time using F.

Closure of A Using F

  • A is in the closure by itself
  • A → C (from F): Add C to the closure
  • AC → D (from F): Add D using AC
  • Closure of A: {A, C, D}

Closure of E Using F

  • E is in the closure by itself
  • E → A, H (from F): Add A and H
  • A → C (from F): Add C
  • AC → D (from F): Add D using AC

Closure of E: {E, A, H, C, D}

Step 4: Verify G ⊆ F

Finally, we check if G’s dependencies are covered by F −

Dependency A → CD from G

  • Closure of A using F: {A, C, D}
  • C and D are in the closure, so A → CD is valid in F

Dependency E → AH from G

  • Closure of E using F: {E, A, H, C, D}
  • A and H are in the closure, so E → AH is valid in F

Since all dependencies in G can be derived from F, G ⊆ F is true.

Conclusion: F and G Are Equivalent

From the above steps, we conclude that F ⊆ G and G ⊆ F. It means F and G are equivalent functional dependency sets.

Key Points to Note

Take a note of the following key points –

  • Use Closures for Comparison − To compare two sets of dependencies, we must compute closures for each attribute or attribute set.
  • Check Both Directions − Verify the subsets like F ⊆ G and G ⊆ F to ensure equivalence.
  • Simplify Where Possible − Minimize the dependency sets before comparison to avoid unnecessary computations.

Conclusion

In this chapter, we understood how to determine the equivalence of functional dependencies. We started the discussion by understanding the concept and importance of equivalence, followed by a step-by-step process to compare two sets of dependencies.

Using closures, we verified that both sets could derive the same attributes, proving their equivalence. This process is needed in database design; it helps in identifying redundant dependencies and in performing schema normalization.

Advertisements