## Which is the equivalent SQL query for the given relational algebra expression?

####
**Question:**

**7. Consider relations(tables) R(A, B, C) and S(B, D). Which of the given SQL queries are equivalent to the Relational Algebra expression "Π**

_{A, R.B, C, S.B, D}(R X S)"?(a) SELECT * FROM R, S;

(b) SELECT * FROM R, S WHERE R.B = S.B;

(c) SELECT A, R.B, C, S.B, D FROM R, S;

(d) SELECT A, R.B, C, D FROM R, S WHERE R.B = S.B;

####
**Answer:**

**Both (a) and (C)**

**SELECT**with * or**SELECT**with all attributes are equal to the Projection operation in relational algebra. Hence, for the given relational algebra projection on R X S, the equivalent SQL queries are both (a) and (c)
The queries in options (b) and (d) are operations involving a join condition. These two queries are equivalent to a SELECTION operation in relational algebra with a JOIN condition or PROJECTION operation with a JOIN condition.

The query "SELECT * FROM R, S WHERE R.B = S.B;" is equivalent to "σ

The query "SELECT A, R.B, C, D FROM R, S WHERE R.B = S.B;" is equivalent to "σ

The query "SELECT * FROM R, S WHERE R.B = S.B;" is equivalent to "σ

_{R.B = S.B}(R X S)".The query "SELECT A, R.B, C, D FROM R, S WHERE R.B = S.B;" is equivalent to "σ

_{R.B = S.B}(R X S)".