CS457 Syllabus & Progress

### Minimal cover of a Set of Functional Dependencies

• Minimal Cover of a set of Functional Dependencies

• Definition: minimal cover

• A set of functional dependencies min is a minimal cover of a set of functional dependencies     if:

1. min   covers

2. The cover property does not hold if:

 We remove one attribute in the LHS or the RHS of any functional dependency in ℉min

(In other words: every functional dependency in min   is minimal

A functional dependency does not contain any excess attribute in the LHS or the RHS )

• Finding a Minimal Cover for a set of Functional Dependencies

• Algorithm for finding a Minimal Cover:

 ``` ℉min = ℉ // Initialization /* ===================================================== Prepare to find minimal RHS We find a mininal RHS by "dropping dependencies" ====================================================== */ For each FD X → A1A2...AN ∈ ℉min do { replace X → A1A2...AN by: X → A1 X → A2 ... X → AN } /* ============================================================ Find the minimal LHS's ============================================================ */ For each FD X → A ∈ ℉min do: { // Remove one attribute from LHS at a time..... For each attribute B ∈ X do: { /* ========================================= Check if attribute B ∈ X is neccesary ========================================= */ Compute (X - B)+ using FDs in ℉min; if ( A ∈ (X - B)+ ) { replace X → A by (X-B) → A in ℉min // B was not neccessary } } /* ============================================================ Find the minimal RHS's ============================================================ */ For each FD X → A ∈ ℉min do: { // Remove 1 RHS at a time..... /* ========================================= Check if X → A is neccesary ========================================= */ compute X+ using ℉min - {X → A} if ( A ∈ X+ ) { remove X → A from ℉min // X → A was not necessary } } /* ========================================= Finalize.... ========================================= */ Group the FDs with common LHS into one single FD. ```

• Example: Finding a Minimal Cover

• Example: Find a minimal cover for the following set of functional dependencies:

 ``` Relation R = (A, B, C, D, E, F) ℉1 = { A → C AC → D E → ADF } ```

• Execution of the minimal cover algorithm:

1. Initialization:

 ``` ℉min = ℉1 = { A → C AC → D E → ADF } ```

2. Break down the RHS of each functional dependency into a single attribute :

 ``` Before: ℉min = ℉1 = { A → C AC → D E → ADF } After: ℉min = ℉1 = { A → C AC → D E → A E → D E → F } ```

3. Minimize the LHS :

 ``` For each FD X → A ∈ ℉min do: { // Remove one attribute from LHS at a time..... For each attribute B ∈ X do: { /* ========================================= Check if attribute B ∈ X is neccesary ========================================= */ Compute (X - B)+ using FDs in ℉min; if ( A ∈ (X - B)+ ) { replace X → Ai by (X-B) → Ai in ℉min // B was not neccessary } } ```

NOTE:

 You only need to consider functional dependencies whose LHS has ≥ 2 attributes !!!!

Execution:

 ``` ℉min = { A → C AC → D <---- Consider this FD E → A E → D E → F } Considering minimality of LHS of AC → D 1. Compute: C+ using ℉min C+ = C (Initialization) = C Done D ⊆ C+ ? ===> No. So attr A is necessary 2. Compute: A+ using ℉min A+ = A (Initialization) = AC (A → C) = ACD (AC → D) Done D ⊆ (AC - C)+ ? ===> Yes !!! So C is NOT necessary ```

Result:

 ``` Before: ℉min = { A → C AC → D E → A E → D E → F } After: ℉min = { A → C A → D E → A E → D E → F } ```

Note:

• Verify that:

 The After set of functional dependencies is equivalent to the Before set !!!

4. Next: minimize the RHS by remove unecessary functional dependencies

 ``` Initially: ℉min = { A → C A → D E → A E → D E → F } 1. Check if " A → C " is necessary Compute A+ using: ℉min = { A → C (do NOT use this FD !) A → D E → A E → D E → F } A+ = A (Initialization) = AD (A → D) Done C ⊆ A+ ??? No. ===> "A → C" is necessary 2. Check if " A → D " is necessary Compute A+ using: ℉min = { A → C A → D (do NOT use this FD !) E → A E → D E → F } A+ = A (Initialization) = AC (A → C) Done D ⊆ A+ ??? No. ===> "A → D" is necessary 3. Check if " E → A " is necessary Compute E+ using: ℉min = { A → C A → D E → A (do NOT use this FD !) E → D E → F } E+ = E (Initialization) = ED (E → D) = EDF (E → F) Done A ⊆ E+ ??? No. ===> "E → A" is necessary 4. Check if " E → D " is necessary Compute E+ using: ℉min = { A → C A → D E → A E → D (do NOT use this FD !) E → F } E+ = E (Initialization) = EA (E → A) = EAF (E → F) = EAFC (A → C) = EAFCD (A → D) Done D ⊆ E+ ??? Yes ! ===> "E → A" is not necessary !!! Update: ℉min = { A → C A → D E → A E → F } 5. Check if " E → F " is necessary Compute E+ using: ℉min = { A → C A → D E → A E → F } (do NOT use this FD !) E+ = E (Initialization) = EA (E → A) = EAC (A → C) = EACD (A → D) Done F ⊆ E+ ??? No. ===> "E → F" is necessary ```

Result:

 ``` ℉min = { A → C A → D E → A E → F } ```

5. Group the functional dependencies that have common LHS together

Final Result: minimal cover

 ``` ℉min = { A → CD E → AF } ```

The resulting set of functional dependencies is a minimal cover of the original set of functional dependencies

The minimal cover is equivalent to the original set of functional dependencies but may have a fewer number of functional dependencies