Multiple choice

Consider the following SQL query

Select distinct $a_1, a_2, …, a_n$

from $r_1, r_2, …, r_m$

where P

For an arbitrary predicate P, this query is equivalent to which of the following relational algebra expressions?

  1. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \times r_2 \times \dots \times r_m\right)$
  2. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \bowtie r_2 \bowtie \dots \bowtie r_m \right)$
  3. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \cup r_2 \cup \dots \cup r_m \right)$
  4. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \cap r_2 \cap \dots \cap r_m \right)$
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Cross product (x) combines the tuples of the one relation with all the tuples of other relation. Thus, tuples of relation $r_1, r_2 .... m$ are combined. Select operator $\sigma$ is used to select resultant tuples. Projection operator $ \pi _{a_1,a_2...a_n}$ is sued to select as subset of attributes from the resultant tuples by specifying the names of the attributes.

So attributes $a_1, a_2, $ an are projected from the resultant tuples.

Thus, option(A) is correct