CS457 Syllabus & Progress

## Heurstic 1 for finding keys

• Heursstic 1: Find all keys - increase/decrease until key

• Problem:

Find all keys in the following relations:

 ``` R(A, B, C, D, E, F) ℉ = { A → BC BD → EF F → A } ```

• Heuristic

• Pretend that the LHS (left hand side) and RHS of are nutrients (vitamins :-)).

 The items on the LHS of → are nutrients that you consume The items on the RHS of → are nutrients that your body acquires

Obviously: the following facts are true

 ``` A → A B → B C → C D → D E → E F → F ```

The set of functional dependencies ℉ are the added benefits :

 ``` ℉ = { A → BC BD → EF F → A } ```

• Consuming A will also acquires BC
• Consuming BD will also acquires EF
• Consuming F will also acquires A

Problem statement:

 acquire every nutrient (A, B, C, D, E, F) using the minimum number of intakes

Step 1: compute closure of all functional dependencies in :

 A+ = A, B, C BD+ = A, B, C, D, E, F F+ = F, A, B, C

Step 2:

• If deficient , then add missing attributes ("nutrients") to the LHS until the closure is equal to the relation (complete set) or
• If sufficient , then remove extraneous attributes ("nutrients") from the LHS until the set is minimal

Example:

• A+ = A, B, C

Deficient : Try adding any combinations of: D, E or F

 ```Add 1 attribute: AD+ = ABCDEF key ! AE+ = ABCE AF+ = ABCF Add 2 attributes, but do not include D: AEF+ = ABCEF Add 3 attributes, but do not include D: Not possible - done. ```

• BD+ = A, B, C, D, E, F

Sufficient : Try deleting any combinations of: B or D

 ```Delete 1 attribute: B+ = B D+ = D Delete 2 attributes: Empty set - done. Conclusion: BD is minimal (is a key) ```

• F+ = F, A, B, C

Deficient : Try adding any combinations of: D or E

 ```Add 1 attribute: DF+ = ABCDEF key ! EF+ = ABCEF Add 2 attributes, but do not include F: Not possible - done. ```

Done !!!

• The keys of the relation R are: