Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider a database consisting of the following tables (relations): SAILORS(sid,

ID: 3846960 • Letter: C

Question

Consider a database consisting of the following tables (relations): SAILORS(sid, sname, rating, age) BOATS(bid, bname, color) RESERVED(sid, bid, day) Write SQL statement for each of the following queries. Find the bids of the boats whose bname contains the string "storm". Find the sids of the sailors who have a rating of at least 10. Find the bnames of boats whose color is red or green. Find the colors of boats reserved by Smith. Find the snames of sailors who have reserved a red or green boat. Find the snames of sailors who have reserved a red boat and a green boat.

Explanation / Answer

1.) SELECT bid from BOATS

WHERE bname = 'storm';

2.) SELECT sid from SAILORS
WHERE rating >= 10;

3.) SELECT bname from BOATS

WHERE color = 'red' or color = 'green';

4.) SELECT color from BOATS

WHERE (RESERVED.bid = BOATS.bid and RESERVED.sid = SAILORS.sid and SAILORS.sname = 'Smith');

5.) SELECT sname from SAILORS

WHERE (SAILORS.sid = RESERVED.sid and BOATS.bid = RESERVED.bid

and (BOATS.color = 'red' or BOATS.color = 'green'));

6.) SELECT sname from SAILORS

WHERE (SAILORS.sid = RESERVED.sid and BOATS.bid = RESERVED.bid

and (BOATS.color = 'red' and BOATS.color = 'green'));

Hope it helps, do give your response.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote