What does the following query find?
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'red')
MINUS
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'green')

What does the following query find?
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'red')
MINUS
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'green') Correct Answer Find the sailor IDs of all sailors who have reserved red boats but not green boats

The given SQL query finds the sailor IDs of all sailors who have reserved red boats but not green boats. It does this by first selecting the sailor IDs (r.sid) of reservations where the boat color is 'red' and then subtracting the sailor IDs of reservations where the boat color is 'green'. The MINUS operator is used to find the set difference, and in this context, it retrieves the sailor IDs of sailors who have reserved red boats but not green boats. Option A is the correct choice for describing the query's result.

Related Questions

Consider the following relation schema Sailors(sid, sname, rating, age) Reserve(sid, bid, day) Boats(bid, bname, color) What is the equivalent of following relational algebra query in SQL query. πsname((σcolor= ‘red’Boats) ⨝ Reserves ⨝ Sailors)