Question:

Based on the following schema,
sailors (sailor-id, sailpr-name, age):
boats (boat-id, boat-name, colour):
reserves (sailor id, boat id, day);
What does the following SQL query imply? 
SELECT S.sailor_name FROM sailors S, boats B, reserves R
WHERE S.sailor_id = R.sailor_id AND R.boat_id = B.boat_id
AND (B.colour = 'red' OR B.colour = 'green');

Show Hint

Join conditions across multiple tables should be matched properly before applying filter conditions like color or ID.
Updated On: May 3, 2025
  • The names of the sailors who are travelling by a red or a green boat.
  • The names of the sailors who are reserved for the boat number 10

  • The names of the sailors who have a red boat but not a green boat.
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

(A)

Tables involved:

  • (B) sailors — stores sailor information.
  • (C) boats — stores boat information including colour.
  • (D) reserves — relationship table showing which sailor reserved which boat and when.

(E)

Query logic:

  • (F) The WHERE clause joins the three tables using sailor ID and boat ID.
  • (G) It then filters only those boats that are either 'red' or 'green'.
  • (H) It selects the names of sailors who have a matching reservation.

(I)

Key Point:

  • There is no mention of actual travel — only reservation is checked.
  • Hence, the correct interpretation is the names of sailors who have reserved a red or green boat.
Was this answer helpful?
0
0

Top Questions on SQL

View More Questions