|X| represents number of tuples in X
bold letters represent keys in the relation
Consider the relations R(A, B) and S(A, C), and that R has a foreign key on A that
references S.
|R ✶ S| (where ' * ' represents natural join) is:
The options are:
1. |R|
2. |S|
3. |R|.|S|
4. max(|R|, |S|)
5. min(|R|, |S|)
What I understand about the cardinality of natural join is that if there is no common attribute among the two relations then natural join will act like a cross-product and the cardinality will be r * s. But I don't understand how key constraints play a role in determining the cardinality.
Can someone please explain?
Presuming the bold A in each schema means it is a key; and presuming the Foreign Key constraint holds -- that is, the A
value for every row in R
does correspond to an A
value in S
:
R
naturally joins to a row in S
on A
.S
that don't join to R
(because there's no Foreign Key constraint to enforce that).R
, answer 1.Is there are real-life use for a schema like this? Consider S
is Customer Name in C
, keyed by Customer number in A
. R
holds date of birth in B
, also keyed by Customer number in A
. Every Customer must have a name; it's true every Customer (person) must have a d.o.b., but we don't need to record that unless/until they purchase age-restricted items.