Keys
Keys of Relations
K is a superkey for relation R if K functionally determines all of R.
K is a key for R if K is a superkey, but no proper subset of K is a superkey.
Example:
HasPokémon(trainerID, name, badges, Pokémon, type)
FDs: trainerID → name badges; Pokémon → type
Superkeys (some of them):
{trainerID, name, badges, Pokémon, type}
{trainerID, name, Pokémon, type}
{trainerID, Pokémon}
Key (only one in this example): {trainerID, Pokémon}
2
Which of the following sets of attributes
is are keys?
MoviesShowing(theater, title, startTime, endTime, has3D, needsCrowdControl, price)
FDs:
title→ has3D needsCrowdControl
theater startTime → title
title startTime → endTime
needsCrowdControl has3D → price
1. {title, theater, startTime}
2. {theater, endTime, title}
3. {title, theater, needsCrowdControl, has3D}
4. None of the above
3
Where Do Keys Come From?
1. Just assert a key K.
◦ If the FDs are K → A for all attributes A.
◦ Then K is a superkey
◦
Be sure that no subsets of K are superkeys as well.
2. Assert FDs and deduce the keys by
systematic exploration.
4
© Copyright 2026 Paperzz