edited by
787 views
2 votes
2 votes

https://gateoverflow.in/?qa=blob&qa_blobid=7899832711610886100

How can we know that when we have to  use natural join and when Cartesian product??

edited by

1 Answer

1 votes
1 votes

D is correct.

Remember Natural Join is associative but bracket has highest priority always

Lets evaluate options-

a:) Evaluate inner braces first I will get the project Id for Gate.Assume P1,P2.Now i can either join this with Right table first or with left table first as these are associative.I will join with right.We will get all Eno,Pno......Employee id working on Gate.Now we will join this result with the left table i.e employees,and get the employee names.You can try joining project with employee and project first and then the other.You will get same answer.Also remember if natural join has no common attribute then it becomes the Cartesian product.

b:) Here the inner braces will execute first and we get gate projects P1,P2.Now we will do Cartesian product with left table which will be the same thing if you do option A by merging first left two tables and then finally result with the third.

c:) Here when we are joining with works_on,there is no condition to check if employee is working on the project.

d:) As both a and b are correct.So d is correct answer

Related questions

1 votes
1 votes
0 answers
1
1 votes
1 votes
0 answers
2
1 votes
1 votes
0 answers
3
Gupta731 asked Oct 24, 2018
438 views
C is provided as the answer. Statement P, I understand but why S is also correct?
0 votes
0 votes
0 answers
4
Gupta731 asked Oct 24, 2018
283 views
I think the answer should be A, but C is given as the answer.