The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+22 votes

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 in Databases by Veteran (399k points)
edited by | 2.2k views
A is correct

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

2 Answers

+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 by
but it is possible that r1 has less tuple than r2 and how subset - superset=empty?
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.
Referential integrity does not prevent NULL value in foreign key, right ? If so, then maybe, $\Pi_{B}(r_1) - \Pi_{C}(r_2) = \{NULL\}$
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...

@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.

What if in R1(A,B) , B also contains null value ,then is it true that null = Ø
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.
0 votes

Correct me if I am wrong:

A: B might not use some values of C. But B cannot have anything that C doesn't contain. So the difference will be phi. This is the Ans.

B: Same as option A, C might have values that B doesn't use so the diffenerce cannot be phi here. Moreover the Q askes which one is always true, this one might not be true in some cases.

C: Same argument, B and C might not be equal always.

D: Difference is phi, proven in option A.

answered by Junior (795 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,403 questions
53,576 answers
70,852 users