Search code examples
relational-databasedatabase-normalizationfunctional-dependenciescandidate-key

How to determine keys from functional dependencies


I'm trying to find the keys for the relation R = ABCDE, with functional dependencies AB->C, C->D, C->E, D->A, E->B

I know how to find the keys when on the right side of the dependencies there are some attributes missing. But here all attributes appear on the right side. I'm not sure how to find the keys and I couldn't find an explanation for this specific example.


Solution

  • My answer is based on https://stackoverflow.com/a/43467969/206413 and https://djitz.com/neu-mscs/answers-to-candidate-key-hard-questions/.

    (1) AB -> C
    (2) C -> D
    (3) C -> E
    (4) D -> A
    (5) E -> B
    
    AB+ = (1) ABC               = (2, 3) ABCDE
    C+  = (2, 3) CDE = (4) ACDE = (5)    ABCDE
    D+  =                       = (4)    AD
    E+  =                       = (5)    BE
    

    So far we have as candidates (AB, C).

    Exploring further:

    D+ = AD => DAB+ = ABCDE
    E+ = BE => EAB+ = ABCDE
    

    Hence our candidates are (AB, C, DAB, EAB)