Skip to content
Official PYQ · 2008

GATE CS 2008 Q68 — Relational Model: Relational Algebra

Explain with AI

Let R and S be two relations with the following schema

R(P,Q‾,R1,R2,R3)R(\underline{P,Q}, R1, R2, R3)

S(P,Q‾,S1,S2)S(\underline{P,Q}, S1, S2)

where {P,Q}\left\{P, Q\right\} is the key for both schemas. Which of the following queries are equivalent?

  1. ΠP(R⋈S)\Pi_P \left(R \bowtie S\right)

  2. ΠP(R)⋈ΠP(S)\Pi_P \left(R\right) \bowtie \Pi_P\left(S\right)

  3. ΠP(ΠP,Q(R)∩ΠP,Q(S))\Pi_P \left(\Pi_{P, Q} \left(R\right) \cap \Pi_{P,Q} \left(S\right) \right)

  4. ΠP(ΠP,Q(R)−(ΠP,Q(R)−ΠP,Q(S)))\Pi_P \left(\Pi_{P, Q} \left(R\right) - \left(\Pi_{P,Q} \left(R\right) - \Pi_{P,Q} \left(S\right)\right)\right)

Choose one option
View worked solution

Answer: D

To find the equivalent queries, let us analyze each expression based on the schema where the common attributes between RR and SS are PP and QQ:

  • Query I: ΠP(R⋈S)\Pi_P (R \bowtie S)
    Since the common attributes of RR and SS are PP and QQ, the natural join R⋈SR \bowtie S performs an equality match on both PP and QQ. Thus, the (P,Q)(P, Q) pairs in the join are exactly those present in both relations. Projecting this result on PP yields the PP-values of the common (P,Q)(P, Q) pairs.
  • Query III: ΠP(ΠP,Q(R)∩ΠP,Q(S))\Pi_P (\Pi_{P, Q} (R) \cap \Pi_{P,Q} (S))
    This expression explicitly finds the intersection of the (P,Q)(P, Q) pairs from both relations and then projects the result on PP. This is semantically identical to Query I. Thus, I ≡\equiv III.
  • Query IV: ΠP(ΠP,Q(R)−(ΠP,Q(R)−ΠP,Q(S)))\Pi_P (\Pi_{P, Q} (R) - (\Pi_{P,Q} (R) - \Pi_{P,Q} (S)))
    Using the set-theoretic identity A−(A−B)=A∩BA - (A - B) = A \cap B, we can simplify the inner expression: ΠP,Q(R)−(ΠP,Q(R)−ΠP,Q(S))=ΠP,Q(R)∩ΠP,Q(S)\Pi_{P, Q} (R) - (\Pi_{P,Q} (R) - \Pi_{P,Q} (S)) = \Pi_{P, Q} (R) \cap \Pi_{P,Q} (S) Applying the outer projection ΠP\Pi_P makes this query identical to Query III. Thus, I ≡\equiv III ≡\equiv IV.
  • Query II: ΠP(R)⋈ΠP(S)\Pi_P (R) \bowtie \Pi_P(S)
    This performs a join only on the attribute PP. For example, if R={(1,2)}R = \{(1, 2)\} and S={(1,3)}S = \{(1, 3)\}, then ΠP(R)⋈ΠP(S)={1}\Pi_P(R) \bowtie \Pi_P(S) = \{1\}, but R⋈S=∅R \bowtie S = \emptyset (and thus ΠP(R⋈S)=∅\Pi_P(R \bowtie S) = \emptyset). Hence, Query II is not equivalent to the others.

Therefore, only queries I, III, and IV are equivalent.

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

Published
Report a correction
Keep exploringMore Relational Model: Relational Algebra questions