GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 13

Foreign-key inclusion in relational algebra

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

GATE 2004, Q13 1 mark · MCQ
Report issue

Relational Algebra & Calculus

Question 13, GATE 2004: Relations R1(A,B,C) and R2(D,E) have keys A and D respectively. C is a foreign key in R1 referencing D in R2. Instances r1,r2 satisfy referential integrity. Which expression must be empty? Projection outputs in set differences are identified by their compatible single domains.
Options:
(A) π_D(r2) − π_C(r1)
(B) π_C(r1) − π_D(r2)
(C) π_D(r1 ⋈_(C≠D) r2)
(D) π_C(r1 ⋈_(C=D) r2)
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Referential integrity requires every C value in r1 to occur as a referenced D value in r2. Hence π_C(r1)⊆π_D(r2), and π_C(r1)−π_D(r2) is empty, B, under classical relational algebra without SQL nulls.

2. The reverse difference can contain unreferenced parent keys.

3. Teaching check: Think of C values as child references and D values as parent keys. A dangling reference would be a value in the child projection absent from the parent projection. Referential integrity forbids precisely that difference, while allowing parent rows with no children.

Original paper, page 2