+21 votes
2k views

Suppose $R_{1} (\underline{A}, B)$ and $R_{2} (\underline{C}, D)$ are two relation schemas. Let $r_{1}$ and $r_{2}$ be the corresponding relation instances. $B$ is a foreign key that refers to $C$ in $R_{2}$. If data in $r_{1}$ and $r_{2}$ satisfy referential integrity constraints, which of the following is ALWAYS TRUE?

1. $\prod_{B}(r_{1})- \prod _{C}(r_{2})= \varnothing$
2. $\prod_{C}(r_{2})- \prod _{B}(r_{1})= \varnothing$
3. $\prod_{B}(r_{1}) = \prod _{C}(r_{2})$
4. $\prod_{B}(r_{1}) - \prod _{C}(r_{2}) \neq \varnothing$
asked
edited | 2k views
0
A is correct

As B only contains the value present in C as it refers C.

## 1 Answer

+29 votes
Best answer

Answer is A.

Referential integrity means, all the values in foreign key should be present in primary key.

$r2(c)$ is the super set of $r1(b)$

So, {subset - superset} is always empty set.

answered by Active (3.3k points)
edited
0
but it is possible that r1 has less tuple than r2 and how subset - superset=empty?
0
Subset will likely to have less than equal to tupples to the superset, anyway the difference will nullify all. So, produces a empty table/relation.
+11
Referential integrity does not prevent NULL value in foreign key, right ? If so, then maybe, $\Pi_{B}(r_1) - \Pi_{C}(r_2) = \{NULL\}$
0
This is true in Relational Algebra since they remove duplicates automatically .. Incase if we replace both projection operators with SELECT in SQL then this neednot be TRUE as SELECT in SQL doesnot remove duplicates unlike SELECT DISTINCT...
0

@Rounak Agarwal referential integrity constraint says that the value present in foreign key is subset of value present in referred attribute since primary attribute can.t have null values so foreign key can't have null values to preseve the integrity constraint.

0
What if in R1(A,B) , B also contains null value ,then is it true that null = Ø
0
let B has value {1,5,8,15}(foreign key)

and let C has value {1,5,6,7,8,15,19}

so here B-C=Ø

notice that to satisfy Referential integrity  constrain all the foreign should be present in referenced relation.
Answer:

+18 votes
2 answers
1
+34 votes
2 answers
2
+28 votes
6 answers
3
+18 votes
2 answers
4
+26 votes
3 answers
5
+20 votes
2 answers
6
+19 votes
3 answers
7