Keys

A key is an attribute of the relation. There are several types of keys:

  • superkey

    • K is a superkey of R if values of K are sufficient to identify a unique tuple of each possible relation r(R)

    • Ex. {ID} and {ID,name} are both superkeys of instructor

  • candidate key

    • A candidate key is a minimal superkey

    • Ex. {ID} is a candidate key for instructor

  • primary key

    • One of the candidate keys is selected as a primary key

    • A primary key must uniquely identify a tuple

  • foreign key

    • A relation R1 may include an attribute that is the primary key of another relation R2; this attribute is called the foreign key from R1 to R2

    • R1 is called the referencing relation and R2 is called the referenced relation

    • The foreign key constraint (or referential integrity constraint) requires that the values of the attribute in the referencing relation must appear in at least 1 tuple of the referenced relation

In the university database figure (see previous section), the candidate keys for each relation have been underlined and the arrows denote foreign key dependencies.

Last updated