Search code examples
databaserdbmsfunctional-dependencies

How to choose a Candidate key in the given relation schema R?


Consider the relation schema R = (A, B, C, D, E, F) and the set of functional dependencies:

A→B

A→C

BC→E

BC→D

E→F

BC→F

Which is the candidate key of relation R?

A) A

B) BC

C) ABC

D) ABCE

The standard answer given is C, which I should use ABC as candidate key in this relationship.

But since:

A -> B,C

B,C -> D,E,F

so I think A can identify all other attributes as

A -> B,C,D,E,F

Did I misunderstand the dependency relations?

Why can't I simply use A as candidate key to identify all the rest attributes?


Solution

  • You are right, a (candidate) key in this case is A, while A B C is a superkey.

    Given the formal definition of candidate key as a “set of attributes that determines all the attributes of the relation and that lose this property by eliminating some attribute from it”, we can show that the closure of A, A+, determines all the attributes in this way:

    A+ = A  (to compute the closure, we start with the attribute)
    A+ = ABC (for transitivity with respect to A→B and A→C)
    A+ = ABCDEF (for transitivity with respect to BC→E and BC→D and BC→F)
    

    Moreover, it is easy to see that it is the unique set of attributes that has this property. In fact, A must be present in any (candidate) key, since it never appear on the right part of a functional dependency, so it is not determined by any other attribute or combination of attributes. But since it is already a (candidate) key, any set of attributes including it will be a proper superkey.