Search code examples
key3nfbcnf

Prime attribute and keys


Is a prime attribute only a member of candidate keys or can it also be superkeys? I am a bit confused as I am reading somewhere that a prime attribute can be a member of ANY key, and other says it needs to be a member of a Candidate key.


Solution

  • A prime attribute is a member of a candidate key.

    In general, “key” is synonym of “candidate key”, while “superkey” is a “candidate key” together with other attributes (so, with this terminology, a “superkey” cannot be a “candidate key”).

    A slightly different terminology, on the other hand, says that a “superkey” is something that determines all the other attributes (so, even a “candidate key” is considered a “superkey”). With this terminology, somebody talks of a proper (or maybe strict) “superkey” when it is a “candidate key” togetehr with other attributes.

    So, in summary:

    • a “candidate key” is a set of attributes that determines all the attributes of the relation and such that we cannot remove any attribute from it without losing this property (and on this definition everybody agrees)

    • a “superkey” can have two different interpretations: a) a “candidate key” with zero or more other attributes; or b) a “candidate key” with other attributes.

    Finally, when you find the term “key” alone, this is almost always a synonym of “candidate key”.