Relations2 QA
Relations2 QA
Primary Key
Definition: A domain of an n-ary relation is called a primary key when the value of the n-tuple
from this domain determines the n-tuple.
Composite Key
Definition: Combinations of domains can also uniquely identify n-tuples in an n-ary relation.
When the values of a set of domains determine an n-tuple in a relation, the Cartesian product of
these domains is called a composite key.
Selection
Definition: Let R be an n-ary relation and C a condition that elements in R may satisfy. Then the
selection operator SC maps the n-ary relation R to the n-ary relation of all n-tuples from R that
satisfy the condition C.
Projection
Definition: The projection Pi1 i2 ,...,im where i1 < i2 < ... < im , maps the n-tuple (a1 , a2 , ..., an ) to
the m-tuple (ai1 , ai2 , ..., aim ), where m ≤ n.
Join
Definition: Let R be a relation of degree m and S a relation of degree n. The join Jp (R, S), where
p ≤ m and p ≤ n, is a relation of degree m + n − p that consists of all (m + n − p)-tuples
(a1 , a2 , ..., am−p , c1 , c2 , ..., cp , b1 , b2 , ..., bn−p ), where the m-tuple (a1 , a2 , ..., am−p , c1 , c2 , ..., cp ) be-
longs to R and the n-tuple (c1 , c2 , ..., cp , b1 , b2 , ..., bn−p ) belongs to S.
1
ICS 241: Discrete Mathematics II (Spring 2015)
c Under what conditions would (name, street address, city) be a composite key?
Same as above because many people can live in the same city.
Table 8 Flights
{(Nadir, 122, 34, Detroit, 08:10), (Nadir, 199, 13, Detroit, 08:47), (Nadir, 322, 34, Detroit, 09:44)}
{(Nadir, 122, 34, Detroit, 08:10), (Acme, 221, 22, Denver, 08:17), (Nadir, 199, 13, Detroit, 08:47),
(Acme, 222, 22, Denver, 09:10), (Nadir, 322, 34, Detroit, 09:44)}
2
ICS 241: Discrete Mathematics II (Spring 2015)
Airline Destination
Nadir Detroit
Acme Denver
Acme Anchorage
Acme Honolulu
Supplier Part number Project Part number Project Quantity Color code
23 1092 1 1001 1 14 8
23 1101 3 1092 1 2 2
23 9048 4 1101 3 1 1
31 4975 3 3477 2 25 2
31 3477 2 4975 3 6 2
32 6984 4 6984 4 10 1
32 9191 2 9048 4 12 2
33 1001 1 9191 2 80 4