Constraints are conditions that must hold on all
valid relation instances. There are three main types of constraints:
1. Key constraints
2. Entity integrity constraints
3. Referential integrity constraints
Superkey of R: A set of
attributes SK of R such that no two tuples in any valid
relation instance r(R) will have the same value for
SK. That is, for any distinct tuples t1 and t2 in r(R), t1[SK] ¹ t2[SK].
Key of R: A "minimal" superkey; that is, a
superkey K such that removal of any attribute from K results in a set of
attributes that is not a superkey.
Example: The CAR relation schema:
CAR(State, Reg#, SerialNo, Make,
Model, Year)
has two keys Key1 = {State,
Reg#}, Key2 = {SerialNo}, which are also superkeys.
{SerialNo, Make} is a superkey but not a key.
If a relation has several candidate keys, one is
chosen arbitrarily to be the primary key. The primary key attributes are underlined.
0 comments