Question
Questions:(2,7,8,9,14,15)
1. For every boat, list the marina number, slip number, boat name, owner number, owner's first name, and owners last name. 2. For every completed or open service request for routine engine maintenance, list the slip ID, description, and status. For every service request for routine engine maintenance, list the slip ID, marina number, slip number, estimated hours, spent hours, owner number, and owner's last name. List the first and last names of all owners who have a boat in a 40-foot slip. Use the IN operator in your formulation. Repeat Exercise 4, but this time use the EXISTS operator in your formulation. 3. 4. 5. List the names of any pair of boats that have the same type. For example, one pair would be Anderson II and Escape, because the boat type for both boats is Sprite 4000. The first name listed should be the major sort key and the second name should be the minor sort key. List the boat name, owner number, owner last name, and owner first name for each boat in marina 1 6. 7. 8. 9. Repeat Exercise 7, but this time only list boats in 30-foot slips. List the marina number, slip number, and boat name for boats whose owners live in Glander Bay or whose type is Sprite 4000. List the marina number, slip number, and boat name for boats whose owners live in Glander Bay and whose type is Sprite 4000. List the marina number, slip number, and boat name for boats whose owners live in Glander Bay but whose type is not Sprite 4000. Find the service ID and slip ID for each service request whose estimated hours is greater than the number of estimated hours of at least one service request on which the category number is 3. 10. 11. 12. 13. Find the service ID and slip ID for each service request whose estimated hours is greater than the number of estimated hours on every service request on which the category num- ber is 3. 14. List the slip ID, boat name, owner number, service ID, number of estimated hours, and num- ber of spent hours for each service request on which the category number is 2. Repeat Exercise 14, but this time be sure each slip is included regardless of whether the boat in the slip currently has any service requests for category 2 15.
Explanation / Answer
2. select slip_id,description, status
from service_request sr, service_category sc
where sr.category_num= sc.category_num and category_description= 'routine engine maintenance';
7. select boat_name, owner.owner_num, last_name, first_name
from marina_slip ms,owner
where ms.owner_num=owner.owner_num and marina_num =1;
8. select boat_name, owner.owner_num,last_name, first_name
from marina_slip ms, owner
where ms.owner_num= owner.owner_num and marina_num = 1 and length =30;
9.select marina_num, slip_num,boat_name
from marina_slip ms,owner ow
where ms.owner_num= ow.owner_num and city= 'Glander Bay'
Union
select marina_num, slip_num, boat_name
from marina_slip
where boat_type='Sprite 4000';
14. select ms.slip_id, boat_name,owner_num,service_id,est_hours,spent_hours
from service_request sr, marina_slip ms
where ms.slip_id = sr.slip_id
and category_num =2;
15.select ms.slip_id , boat_name ,owner_num ,service_id ,est_hours ,spent_hours
from service_request sr left join marina_slip ms
on ms.slip_id = sr.slip_id
and category_num =2;