-
Consider the following SQL query :
Select distinct a1, 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?
-
- Π a1 , a2 ,...,an σP (r1 × r2 × ..... × rm)
- Π a1 , a2 ,...,an σP (r1 ⋈ r2 ⋈ ..... ⋈ rm)
- Π a1 , a2 ,...,an σP (r1 ∪ r2 ∪ ..... ∪ rm)
- Π a1 , a2 ,...,an σP (r1 ∩ r2 ∩ ..... ∩ rm)
- Π a1 , a2 ,...,an σP (r1 × r2 × ..... × rm)
Correct Option: A
SQL does the following operations
1. It forms the Cartesian product of relations that are named in form clause.
2. It performs a relational algebra selection using the where clause predicate. By this the results are projected onto attributes of selected clause.
Now, All the possible combination of tuples from r1, r2 ,...rn = r1 × r2 × r3 × r4 ...rn. If P is a predicate then select all the condition is denoted by σP (r1 × r2 × ....... × rn).
If we want to select only some tupels in relation then composite expression for above SQL is
Π | σP (r1 × r2 × ….. × rm) |
a1 , a2 ,…,an |