Skip to content
Official PYQ · 2004

GATE CS 2004 Q13 — Tuple Calculus and SQL

Explain with AI

Let R1(A‾,B,C)R_1 \left(\underline{A}, B, C\right) and R2(D‾,E)R_2\left(\underline{D}, E \right) be two relation schema, where the primary keys are shown underlined, and let C be a foreign key in R1R_1 referring to R2R_2. Suppose there is no violation of the above referential integrity constraint in the corresponding relation instances r1r_1 and r2r_2. Which of the following relational algebra expressions would necessarily produce an empty relation?

Choose one option
View worked solution

Answer: B

The question asks which relational algebra expression will necessarily produce an empty relation under the given referential integrity constraint.

We are given:

  • R1(A‾,B,C)R_1(\underline{A}, B, C) with primary key AA.
  • R2(D‾,E)R_2(\underline{D}, E) with primary key DD.
  • CC is a foreign key in R1R_1 referencing the primary key DD in R2R_2.

By the definition of referential integrity, every value in the foreign key column CC of relation instance r1r_1 must exist in the primary key column DD of relation instance r2r_2. In terms of relational algebra, this subset relationship is expressed as:

ΠC(r1)⊆ΠD(r2)\Pi_C(r_1) \subseteq \Pi_D(r_2)

Let us analyze the options based on this set inclusion property:

  1. ΠD(r2)−ΠC(r1)\Pi_D(r_2) - \Pi_C(r_1): Since ΠC(r1)⊆ΠD(r2)\Pi_C(r_1) \subseteq \Pi_D(r_2), this expression represents elements in DD that are not referenced by CC. This set can be non-empty if there are primary key values in r2r_2 that have no matching records in r1r_1.
  2. ΠC(r1)−ΠD(r2)\Pi_C(r_1) - \Pi_D(r_2): Since every element in ΠC(r1)\Pi_C(r_1) must also be in ΠD(r2)\Pi_D(r_2) (due to the subset constraint X⊆Y  ⟹  X−Y=∅X \subseteq Y \implies X - Y = \emptyset), subtracting ΠD(r2)\Pi_D(r_2) from ΠC(r1)\Pi_C(r_1) will always yield an empty relation.
  3. ΠD(r1⋈C≠Dr2)\Pi_D(r_1 \bowtie_{C \neq D} r_2): This performs a theta-join where C≠DC \neq D. This can easily produce a non-empty relation if there are multiple distinct keys in r2r_2.
  4. ΠC(r1⋈C=Dr2)\Pi_C(r_1 \bowtie_{C = D} r_2): This is an inner join on the foreign key constraint, which yields the set of all referenced values ΠC(r1)\Pi_C(r_1). This is non-empty as long as r1r_1 contains at least one tuple.

Thus, only option B is guaranteed to be empty under all valid instances.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions