Skip to content
Official PYQ · 1998

GATE CS 1998 Q2.19 — Tuple Calculus and SQL

Explain with AI

Which of the following query transformations (i.e., replacing the l.h.s. expression by the r.h.s expression) is incorrect? R1 and R2 are relations, C1 and C2 are selection conditions and A1 and A2 are attributes of R1.

Choose one option
View worked solution

Answer: D

To determine which transformation is incorrect, let us analyze each option:

  • Option A: σC1(σC2(R1))→σC2(σC1(R1))\sigma_{C_1} \left(\sigma_{C_2}\left(R_1\right)\right) \to \sigma_{C_2} \left(\sigma_{C_1}\left(R_1\right)\right)
    Selection operations commute. The order in which we apply independent selection conditions does not affect the final set of tuples. Thus, this transformation is correct.
  • Option B: σC1(πA1(R1))→πA1(σC1(R1))\sigma_{C_1} \left(\pi_{A_1}\left(R_1\right)\right) \to \pi_{A_1} \left(\sigma_{C_1}\left(R_1\right)\right)
    For the left-hand side (LHS) expression to be valid, the selection condition C1C_1 must only involve attributes that are present in the projection list A1A_1. Since C1C_1 only uses attributes from A1A_1, applying the selection before or after the projection yields the same result. Thus, this transformation is correct.
  • Option C: σC1(R1∪R2)→σC1(R1)∪σC1(R2)\sigma_{C_1} \left(R_1 \cup R_2\right) \to \sigma_{C_1}\left(R_1\right) \cup \sigma_{C_1} \left(R_2\right)
    Selection distributes over set union. Filtering the union of two relations is equivalent to filtering each relation individually and then taking their union. Thus, this transformation is correct.
  • Option D: πA1(σC1(R1))→σC1(πA1(R1))\pi_{A_1} \left(\sigma_{C_1}\left(R_1\right)\right) \to \sigma_{C_1} \left(\pi_{A_1}\left(R_1\right)\right)
    On the LHS, the selection condition C1C_1 can involve any attributes of R1R_1, including those not present in A1A_1. Once the selection is applied, we project only the attributes in A1A_1.
    However, on the RHS, the projection πA1(R1)\pi_{A_1}(R_1) is performed first, which discards all attributes not in A1A_1. If C1C_1 references any of these discarded attributes, the subsequent selection σC1\sigma_{C_1} cannot be evaluated, making the RHS expression invalid. Thus, this transformation is incorrect.

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

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions