Home » Database » Database miscellaneous » Question

Database miscellaneous

  1. 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?
    1. Π a1 , a2 ,...,an σP (r1 × r2 × ..... × rm)
    2. Π a1 , a2 ,...,an σP (r1 ⋈ r2 ⋈ ..... ⋈ rm)
    3. Π a1 , a2 ,...,an σP (r1 ∪ r2 ∪ ..... ∪ rm)
    4. Π 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



Your comments will be displayed only after manual approval.