Monday, September 12, 2016

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

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 "σ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)".







         Previous Question                                                                                Next Question


No comments:

Post a Comment

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery