GATE / CS ARCHIVE

GATE CSE 2012 / QUESTION 43

Foreign-key inclusion constraint

Database Management Systems · Relational Algebra & Calculus · Full GATE CSE 2012 paper

GATE 2012, Q43 2 marks · MCQ
Report issue

Relational Algebra & Calculus

Question 43, GATE 2012: Let r1 and r2 be instances of R1(A,B) and R2(C,D). B is a foreign key referencing C, and referential integrity holds. Which is always true? π denotes projection.
(A) π_B(r1)−π_C(r2)=∅ (B) π_C(r2)−π_B(r1)=∅ (C) π_B(r1)=π_C(r2) (D) π_B(r1)−π_C(r2)≠∅.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

In the classical relational model used by the relational-algebra expression, every B value in r1 must occur as a C value in r2. Thus π_B(r1) is a subset of π_C(r2), and π_B(r1)−π_C(r2)=∅, A. Referenced C values need not all occur in B, so equality and reverse containment are not guaranteed. This is the textbook non-null relational interpretation; SQL nullable foreign keys require separate treatment of NULL.

Check: For a concrete permitted instance, r1 may reference only C=1 while r2 contains C=1 and C=2. Then the forward difference is empty but the reverse difference contains 2. Referenced rows may exist even when no row currently references them.

Original paper, page 10 · Answer key