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.
View worked solution
Answer: D
To determine which transformation is incorrect, let us analyze each option:
- Option A:
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:
For the left-hand side (LHS) expression to be valid, the selection condition must only involve attributes that are present in the projection list . Since only uses attributes from , applying the selection before or after the projection yields the same result. Thus, this transformation is correct. - Option C:
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:
On the LHS, the selection condition can involve any attributes of , including those not present in . Once the selection is applied, we project only the attributes in .
However, on the RHS, the projection is performed first, which discards all attributes not in . If references any of these discarded attributes, the subsequent selection cannot be evaluated, making the RHS expression invalid. Thus, this transformation is incorrect.
Free practice · Your answers on this page are not saved.
