in Databases edited by
565 views
0 votes
0 votes

in Databases edited by
565 views

2 Comments

Ans should be both A and B.

In 1st Query inner query which is not correlated nested query hence which can run independently which captures id's of that sailors who are having green boats. By using IN outer tuple variable S will check whtere current S.sid is present in the group of inner query result or not then using "AND"  it checks same for same sailor, if he has "red" boat as well or not by joining 3 tables. hence This will give names of sailors who are having both boats.

In 2nd Query it simply checks intersection between set of sailors who are having "red" boats and set of sailors who are having "green" boats which will give set of sailors who are having both boats.

0
0

Yes answer given is both but in first query inner part : Isn`t the where clause is wrong : It should be :
S2.id=R2.id and R2.bid=B2.bid or you assumed it as "typo".

0
0

Please log in or register to answer this question.

Related questions

3 votes
3 votes
1 answer
3
chaser asked in Databases Dec 30, 2016
490 views
chaser asked in Databases Dec 30, 2016
by chaser
490 views
1 vote
1 vote
1 answer
4
Na462 asked in Databases Jan 19, 2019
1,222 views
Na462 asked in Databases Jan 19, 2019
by Na462
1.2k views