*67*

# Canonical Cover

In the case of updating the database, the responsibility of the system is to check whether the existing functional dependencies are getting violated during the process of updating. In case of a violation of functional dependencies in the new database state, the rollback of the system must take place.

A canonical cover or irreducible a set of functional dependencies FD is a simplified set of FD that has a similar closure as the original set FD.

### Extraneous attributes

An attribute of an FD is said to be extraneous if we can remove it without changing the closure of the set of FD.

**Example:** Given a relational Schema R( A, B, C, D) and set of Function Dependency FD = { B â†’ A, AD â†’ BC, C â†’ ABD }. Find the canonical cover?

**Solution:** Given FD = { B â†’ A, AD â†’ BC, C â†’ ABD }, now decompose the FD using decomposition rule( Armstrong Axiom ).

- B â†’ A
- AD â†’ B ( using decomposition inference rule on AD â†’ BC)
- AD â†’ C ( using decomposition inference rule on AD â†’ BC)
- C â†’ A ( using decomposition inference rule on C â†’ ABD)
- C â†’ B ( using decomposition inference rule on C â†’ ABD)
- C â†’ D ( using decomposition inference rule on C â†’ ABD)

Now set of FD = { B â†’ A, AD â†’ B, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }

The next step is to find closure of the left side of each of the given FD by including that FD and excluding that FD, if closure in both cases are same then that FD is redundant and we remove that FD from the given set, otherwise if both the closures are different then we do not exclude that FD.

**Calculating closure of all FD { B â†’ A, AD â†’ B, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }**

1a. Closure B+ = BA using FD = { **B â†’ A**, AD â†’ B, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }

1b. Closure B+ = B using FD = { AD â†’ B, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }

From 1 a and 1 b, we found that both the Closure( by including **B â†’ A** and excluding **B â†’ A** ) are not equivalent, hence FD B â†’ A is important and cannot be removed from the set of FD.

2 a. Closure AD+ = ADBC using FD = { B â†’A, **AD â†’ B**, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }

2 b. Closure AD+ = ADCB using FD = { B â†’ A, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }

From 2 a and 2 b, we found that both the Closure (by including **AD â†’ B** and excluding **AD â†’ B**) are equivalent, hence FD **AD â†’ B** is not important and can be removed from the set of FD.

**Hence resultant FD = { B â†’ A, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }**

3 a. Closure AD+ = ADCB using FD = { B â†’A, **AD â†’ C**, C â†’ A, C â†’ B, C â†’ D }

3 b. Closure AD+ = AD using FD = { B â†’ A, C â†’ A, C â†’ B, C â†’ D }

From 3 a and 3 b, we found that both the Closure (by including **AD â†’ C** and excluding **AD â†’ C** ) are not equivalent, hence FD AD â†’ C is important and cannot be removed from the set of FD.

**Hence resultant FD = { B â†’ A, AD â†’ C, C â†’ A, C â†’ B, C â†’ D }**

4 a. Closure C+ = CABD using FD = { B â†’A, AD â†’ C, **C â†’ A**, C â†’ B, C â†’ D }

4 b. Closure C+ = CBDA using FD = { B â†’ A, AD â†’ C, C â†’ B, C â†’ D }

From 4 a and 4 b, we found that both the Closure (by including **C â†’ A** and excluding **C â†’ A**) are equivalent, hence FD **C â†’ A** is not important and can be removed from the set of FD.

**Hence resultant FD = { B â†’ A, AD â†’ C, C â†’ B, C â†’ D }**

5 a. Closure C+ = CBDA using FD = { B â†’A, AD â†’ C, **C â†’ B**, C â†’ D }

5 b. Closure C+ = CD using FD = { B â†’ A, AD â†’ C, C â†’ D }

From 5 a and 5 b, we found that both the Closure (by including **C â†’ B** and excluding **C â†’ B**) are not equivalent, hence FD **C â†’ B** is important and cannot be removed from the set of FD.

**Hence resultant FD = { B â†’ A, AD â†’ C, C â†’ B, C â†’ D }**

6 a. Closure C+ = CDBA using FD = { B â†’A, AD â†’ C, C â†’ B, **C â†’ D** }

6 b. Closure C+ = CBA using FD = { B â†’ A, AD â†’ C, C â†’ B }

From 6 a and 6 b, we found that both the Closure( by including **C â†’ D** and excluding **C â†’ D**) are not equivalent, hence FD **C â†’ D** is important and cannot be removed from the set of FD.

**Hence resultant FD = { B â†’ A, AD â†’ C, C â†’ B, C â†’ D }**

- Since FD = { B â†’ A, AD â†’ C, C â†’ B, C â†’ D } is resultant FD, now we have checked the redundancy of attribute, since the left side of FD AD â†’ C has two attributes, letâ€™s check their importance, i.e. whether they both are important or only one.

Closure AD+ = ADCB using FD = { B â†’A, **AD â†’ C**, C â†’ B, C â†’ D }

Closure A+ = A using FD = { B â†’A, **AD â†’ C**, C â†’ B, C â†’ D }

Closure D+ = D using FD = { B â†’A, **AD â†’ C**, C â†’ B, C â†’ D }

Since the closure of AD+, A+, D+ that we found are not all equivalent, hence in FD AD â†’ C, both A and D are important attributes and cannot be removed.

Hence resultant FD = { B â†’ A, AD â†’ C, C â†’ B, C â†’ D } and we can rewrite as

**FD = { B â†’ A, AD â†’ C, C â†’ BD } is Canonical Cover of FD = { B â†’ A, AD â†’ BC, C â†’ ABD }.**

**Example 2:** Given a relational Schema R( W, X, Y, Z) and set of Function Dependency FD = { W â†’ X, Y â†’ X, Z â†’ WXY, WY â†’ Z }. Find the canonical cover?

**Solution:** Given FD = { W â†’ X, Y â†’ X, Z â†’ WXY, WY â†’ Z }, now decompose the FD using decomposition rule( Armstrong Axiom ).

- W â†’ X
- Y â†’ X
- Z â†’ W ( using decomposition inference rule on Z â†’ WXY )
- Z â†’ X ( using decomposition inference rule on Z â†’ WXY )
- Z â†’ Y ( using decomposition inference rule on Z â†’ WXY )
- WY â†’ Z

Now set of FD = { W â†’ X, Y â†’ X, WY â†’ Z, Z â†’ W, Z â†’ X, Z â†’ Y }

The next step is to find closure of the left side of each of the given FD by including that FD and excluding that FD, if closure in both cases are same then that FD is redundant and we remove that FD from the given set, otherwise if both the closures are different then we do not exclude that FD.

**Calculating closure of all FD { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }**

**1 a.** Closure W+ = WX using FD = { **W â†’ X**, Y â†’ X, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }

**1 b.** Closure W+ = W using FD = { Y â†’ X, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }

From 1 a and 1 b, we found that both the Closure (by including **W â†’ X** and excluding **W â†’ X** ) are not equivalent, hence FD W â†’ X is important and cannot be removed from the set of FD.

**Hence resultant FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }**

**2 a.** Closure Y+ = YX using FD = { W â†’ X, **Y â†’ X**, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }

**2 b.** Closure Y+ = Y using FD = { W â†’ X, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }

From 2 a and 2 b we found that both the Closure (by including **Y â†’ X** and excluding **Y â†’ X** ) are not equivalent, hence FD Y â†’ X is important and cannot be removed from the set of FD.

**Hence resultant FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }**

**3 a.** Closure Z+ = ZWXY using FD = { W â†’ X, Y â†’ X, **Z â†’ W**, Z â†’ X, Z â†’ Y, WY â†’ Z }

**3 b.** Closure Z+ = ZXY using FD = { W â†’ X, Y â†’ X, Z â†’ X, Z â†’ Y, WY â†’ Z }

From 3 a and 3 b, we found that both the Closure (by including **Z â†’ W** and excluding **Z â†’ W** ) are not equivalent, hence FD Z â†’ W is important and cannot be removed from the set of FD.

**Hence resultant FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ X, Z â†’ Y, WY â†’ Z }**

**4 a**. Closure Z+ = ZXWY using FD = { W â†’ X, Y â†’ X, Z â†’ W, **Z â†’ X**, Z â†’ Y, WY â†’ Z }

**4 b.** Closure Z+ = ZWYX using FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z }

From 4 a and 4 b, we found that both the Closure (by including **Z â†’ X** and excluding **Z â†’ X** ) are equivalent, hence FD Z â†’ X is **not** important and can be removed from the set of FD.

**Hence resultant FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z }**

**5 a.** Closure Z+ = ZYWX using FD = { W â†’ X, Y â†’ X, Z â†’ W, **Z â†’ Y**, WY â†’ Z }

**5 b.** Closure Z+ = ZWX using FD = { W â†’ X, Y â†’ X, Z â†’ W, WY â†’ Z }

From 5 a and 5 b, we found that both the Closure (by including **Z â†’ Y** and excluding **Z â†’ Y** ) are not equivalent, hence FD Z â†’ X is important and cannot be removed from the set of FD.

**Hence resultant FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z }**

**6 a.** Closure WY+ = WYZX using FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, **WY â†’ Z** }

**6 b.** Closure WY+ = WYX using FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y }

From 6 a and 6 b, we found that both the Closure (by including **WY â†’ Z** and excluding **WY â†’ Z**) are not equivalent, hence FD WY â†’ Z is important and cannot be removed from the set of FD.

**Hence resultant FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z }**

Since FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z } is resultant FD now, we have checked the redundancy of attribute, since the left side of FD WY â†’ Z has two attributes at its left, letâ€™s check their importance, i.e. whether they both are important or only one.

Closure WY+ = WYZX using FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z }

Closure W+ = WX using FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z }

Closure Y+ = YX using FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z }

Since the closure of WY+, W+, Y+ that we found are not all equivalent, hence in FD WY â†’ Z, both W and Y are important attributes and cannot be removed.

Hence resultant FD = { W â†’ X, Y â†’ X, Z â†’ W, Z â†’ Y, WY â†’ Z } and we can rewrite as:

**FD = { W â†’ X, Y â†’ X, Z â†’ WY, WY â†’ Z } is Canonical Cover of FD = { W â†’ X, Y â†’ X, Z â†’ WXY, WY â†’ Z }.**

**Example 3:** Given a relational Schema R( V, W, X, Y, Z) and set of Function Dependency FD = { V â†’ W, VW â†’ X, Y â†’ VXZ }. Find the canonical cover?

**Solution:** Given FD = { V â†’ W, VW â†’ X, Y â†’ VXZ }. now decompose the FD using decomposition rule (Armstrong Axiom).

- V â†’ W
- VW â†’ X
- Y â†’ V ( using decomposition inference rule on Y â†’ VXZ )
- Y â†’ X ( using decomposition inference rule on Y â†’ VXZ )
- Y â†’ Z ( using decomposition inference rule on Y â†’ VXZ )

Now set of FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ X, Y â†’ Z }.

The next step is to find closure of the left side of each of the given FD by including that FD and excluding that FD, if closure in both cases are same then that FD is redundant and we remove that FD from the given set, otherwise if both the closures are different then we do not exclude that FD.

**Calculating closure of all FD { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ X, Y â†’ Z }.**

**1 a.** Closure V+ = VWX using FD = {**V â†’ W**, VW â†’ X, Y â†’ V, Y â†’ X, Y â†’ Z}

**1 b.** Closure V+ = V using FD = {VW â†’ X, Y â†’ V, Y â†’ X, Y â†’ Z }

From 1 a and 1 b, we found that both the Closure( by including **V â†’ W** and excluding **V â†’ W** ) are not equivalent, hence FD V â†’ W is important and cannot be removed from the set of FD.

**Hence resultant FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ X, Y â†’ Z }.**

**2 a**. Closure VW+ = VWX using FD = { V â†’ W, **VW â†’ X**, Y â†’ V, Y â†’ X, Y â†’ Z }

**2 b.** Closure VW+ = VW using FD = { V â†’ W, Y â†’ V, Y â†’ X, Y â†’ Z }

From 2 a and 2 b, we found that both the Closure( by including **VW â†’ X** and excluding **VW â†’ X** ) are not equivalent, hence FD VW â†’ X is important and cannot be removed from the set of FD.

**Hence resultant FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ X, Y â†’ Z }.**

**3 a.** Closure Y+ = YVXZW using FD = { V â†’ W, VW â†’ X, **Y â†’ V**, Y â†’ X, Y â†’ Z }

**3 b.** Closure Y+ = YXZ using FD = { V â†’ W, VW â†’ X, Y â†’ X, Y â†’ Z }

From 3 a and 3 b, we found that both the Closure( by including **Y â†’ V** and excluding **Y â†’ V** ) are not equivalent, hence FD Y â†’ V is important and cannot be removed from the set of FD.

**Hence resultant FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ X, Y â†’ Z }.**

**4 a**. Closure Y+ = YXVZW using FD = { V â†’ W, VW â†’ X, Y â†’ V, **Y â†’ X**, Y â†’ Z }

**4 b.** Closure Y+ = YVZWX using FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ Z }

From 4 a and 4 b, we found that both the Closure( by including **Y â†’ X** and excluding **Y â†’ X** ) are equivalent, hence FD Y â†’ X is **not** important and can be removed from the set of FD.

**Hence resultant FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ Z }.**

**5 a.** Closure Y+ = YZVWX using FD = { V â†’ W, VW â†’ X, Y â†’ V, **Y â†’ Z** }

**5 b.** Closure Y+ = YVWX using FD = { V â†’ W, VW â†’ X, Y â†’ V }

From 5 a and 5 b, we found that both the Closure( by including **Y â†’ Z** and excluding **Y â†’ Z** ) are not equivalent, hence FD Y â†’ Z is important and cannot be removed from the set of FD.

**Hence resultant FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ Z }.**

Since FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ Z } is resultant FD now, we have checked the redundancy of attribute, since the left side of FD VW â†’ X has two attributes at its left, letâ€™s check their importance, i.e. whether they both are important or only one.

Closure VW+ = VWX using FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ Z }

Closure V+ = VWX using FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ Z }

Closure W+ = W using FD = { V â†’ W, VW â†’ X, Y â†’ V, Y â†’ Z }

Since the closure of VW+, V+, W+ we found that all the Closures of VW and V are equivalent, hence in FD VW â†’ X, W is not at all an important attribute and can be removed.

Hence resultant FD = { V â†’ W, V â†’ X, Y â†’ V, Y â†’ Z } and we can rewrite as

**FD = { V â†’ WX, Y â†’ VZ } is Canonical Cover of FD = { V â†’ W, VW â†’ X, Y â†’ VXZ }.**

**CONCLUSION:** From the above three examples we conclude that canonical cover / irreducible set of functional dependency follows the following steps, which we need to follow while calculating Canonical Cover.

**STEP 1:** For a given set of FD, decompose each FD using decomposition rule (Armstrong Axiom) if the right side of any FD has more than one attribute.

**STEP 2:** Now make a new set of FD having all decomposed FD.

**STEP 3:** Find closure of the left side of each of the given FD by including that FD and excluding that FD, if closure in both cases are same then that FD is redundant and we remove that FD from the given set, otherwise if both the closures are different then we do not exclude that FD.

**STEP 4:** Repeat step 4 till all the FDs in FD set are complete.

**STEP 5:** After STEP 4, find resultant FD = { B â†’ A, AD â†’ C, C â†’ B, C â†’ D } which are not redundant.

**STEP 6:** Check redundancy of attribute, by selecting those FDâ€™s from FD sets which are having more than one attribute on its left, letâ€™s an FD AD â†’ C has two attributes at its left, letâ€™s check their importance, i.e. whether they both are important or only one.

**STEP 6 a:** Find Closure AD+

**STEP 6 b:** Find Closure A+

**STEP 6 c:** Find Closure D+

Compare Closure of STEP (6a, 6b, 6c) if the closure of AD+, A+, D+ are not equivalent, hence in FD AD â†’ C, both A and D are important attributes and cannot be removed, otherwise, we remove the redundant attribute.