Candidate Key - Determining Candidate Keys

Determining Candidate Keys

The previous example only illustrates the definition of a candidate key and not how these are determined in practice. It is important to determine all superkeys, which is especially difficult if the relation represents a set of relationships rather than a set of entities. Therefore it is often useful to attempt to find any "forgotten" superkeys by also determining the functional dependencies. We can derive more superkeys by applying the following rule:

if S is a superkey and XY a functional dependency
then (S ∖ {Y}) ∪ {X} is also a superkey, where '\' is the set difference.

Consider for example the relation

Marriage (Husband, Wife, Date)

for which it will trivially hold that

{Husband, Wife, Date}

is a superkey. If we assume that a certain person can marry at most once on a given date then this implies the functional dependencies:

{Husband, Date} → Wife
{Wife, Date} → Husband

In this case, applying the above rule leads to the derivation of the superkeys {Husband, Date} and {Wife, Date} respectively.

Read more about this topic:  Candidate Key

Famous quotes containing the words determining, candidate and/or keys:

    A quality is something capable of being completely embodied. A law never can be embodied in its character as a law except by determining a habit. A quality is how something may or might have been. A law is how an endless future must continue to be.
    Charles Sanders Peirce (1839–1914)

    If we should swap a good library for a second-rate stump speech and not ask for boot, it would be thoroughly in tune with our hearts. For deep within each of us lies politics. It is our football, baseball, and tennis rolled into one. We enjoy it; we will hitch up and drive for miles in order to hear and applaud the vitriolic phrases of a candidate we have already reckoned we’ll vote against.
    —Federal Writers’ Project Of The Wor, U.S. public relief program (1935-1943)

    And yet we constantly reclaim some part of that primal spontaneity through the youngest among us, not only through their sorrow and anger but simply through everyday discoveries, life unwrapped. To see a child touch the piano keys for the first time, to watch a small body slice through the surface of the water in a clean dive, is to experience the shock, not of the new, but of the familiar revisited as though it were strange and wonderful.
    Anna Quindlen (b. 1952)