In: Computer Science
INTRO TO DATABASES
Consider the boat reservation system:
Sailors (sid, sname,rating, age)
Boats(bid, bname, color)
Reserves (sid, bid, day)
Formulate the following question in relational algebra using two different sequences of relational operators:
A. Find the colors of boats reserved by Lubber.
B. Find the sids of sailors older than 20 who have not reserved a red boat.
Please UPVOTE if it helps.
NOTE :
A. Find the colors of boats reserved by Lubber.
Solution : πcolor((σsname= ‘Lubber’ Sailor)∞ Reserves ∞ Boats ))
B . Find the sids of sailors older than 20 who have not reserved a red boat.
Solution : πsid (σage>20Sailors) – πsid ((σcolor=‘red’ Boats) ∞Reserves)
1. Find all sailors (sids) with age over 20. [ πsid (σage>20Sailors) ]
2. Find all sailors (sids) who have reserved a red boat. [ πsid ((σcolor=‘red’ Boats) ∞Reserves)
3. Now, we can find sids of sailors older than 20 who have not reserved a red boat by taking difference between those people who's age is greater than 20 and those who have reserved the red boat.