Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question Consider the Sailors - Boats - Reserves DB described in the text. s ( sid , sname, rating, age ) b ( bid ,
Question
Consider the SailorsBoatsReserves DB described in the text.
s sid sname, rating, age
b bid bname, color
r sid bid, date
Write each of the following queries in SQL
Find the colors of boats reserved by Albert.
SELECT color
FROM s b r
WHERE rsidssid AND rbidbbid AND
snameAlbert
Find all sailor ids of sailors who have a rating of at least or reserved boat
SELECT sid
FROM s
WHERE rating
UNION
SELECT sid
FROM r
WHERE bid
Find the names of sailors who have not reserved a boat whose name contains the string
storm Order the names in ascending order.
SELECT sname
FROM s s
WHERE sid NOT IN
SELECT sid
FROM r s
WHERE rsidssid AND sname LIKE storm
ORDER BY ssname
Find the sailor ids of sailors with age over who have not reserved a boat whose name
includes the string thunder
SELECT sid
FROM s
WHERE age AND sid NOT IN
SELECT sid
FROM r b
WHERE rbidbbid AND bname LIKE thunder
Find the names of sailors who have reserved at least two boats.
SELECT sname
FROM s r r r r
WHERE ssidrsid AND ssidrsid AND
rbidrbid
Note: If we want to eliminate duplicates, we SELECT DISTINCT sname. Alternatively, we
could simply change the condition in the WHERE clause from rbidrbid to say
rbid
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started