Consider the following SQL query select distinct al, a2,........., an from r1,…
2003
Consider the following SQL query
select distinct al, a2,........., an
from r1, r2,........, rm
where P For an arbitrary predicate P, this query is equivalent to which of the following relational algebra expressions ?

- A.
A
- B.
B
- C.
C
- D.
D
Attempted by 161 students.
Show answer & explanation
Correct answer: A
Correct expression: π_{a1,a2,...,an}(σ_P(r1 × r2 × ... × rm))
Derivation:
FROM r1, r2, ..., rm → Cartesian product r1 × r2 × ... × rm.
WHERE P → selection σ_P applied to the Cartesian product.
SELECT DISTINCT a1,a2,...,an → projection π_{a1,a2,...,an}, which removes duplicates.
Why the other choices are incorrect:
Using join operators (⋈) presumes specific join semantics or explicit join conditions; the general comma-style FROM with an arbitrary WHERE is most directly modeled as selection on the Cartesian product.
Union (∪) and intersection (∩) require relations with the same schema and represent combining or intersecting whole tuples; they do not model listing multiple relations in FROM followed by filtering with WHERE.
Therefore the closest and correct relational-algebra equivalence is projection after selection on the Cartesian product: π_{a1,...,an}(σ_P(r1 × r2 × ... × rm)).
A video solution is available for this question — log in and enroll to watch it.