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

Write the following queries in relational algebra, using the schema blow, where

ID: 3854372 • Letter: W

Question

Write the following queries in relational algebra, using the schema blow, where the primary keys are underlined. Sailors(sid, sname, rating, age) Reserves(sid, bid, day) Boats(bid, bname, color) a. Find names of sailors who have reserved boat 103 (i.e., bid = 103). b. Find names of sailors who have reserved a red boat. c. Find names of sailors who have reserved a red or a green boat. d. Find names of sailors who have reserved a red and a green boat. Write the following queries in relational algebra, using the university schema I gave you in class. a. Find the names of all students who have taken at least one Comp. Sci. course. b. Find the IDs and names of all students who have not taken any course offered before 2009. Write the following queries in relational algebra, using the schema below, where the primary keys are underlined. employee (pname, street, city) works (pname, cname, salary) company (cname, city) a. Find the names, street addresses, and cities of residence of all employees who work for "First Bank Corporation" and earn more than exist10,000. b. Find the names of all employees in this database who live in the same city as the company for which they work.

Explanation / Answer

1)

a) select S.sname from Sailors S and Reserves R Boats B where S.sid=R.sid and R.bid=B.bid and B.bid=103;

b) select S.sname from Sailors S and Reserves R Boats B where S.sid=R.sid and R.bid=B.bid and B.color='red';

c)select S.sname from Sailors S and Reserves R Boats B where S.sid=R.sid and R.bid=B.bid and B.color='red' or B.color='green' ;

d)select S.sname from Sailors S and Reserves R Boats B where S.sid=R.sid and R.bid=B.bid and B.color='red' and B.color='green' ;

3)

a)select E.pname,E.street,E.city from employee E,Works W,company C where E.pname=W.pname and W.cname=C.cname and C.cname='First bank Corporation' and W.salary > $10000;

b)select E.pname from employee E,Works W,company C where E.pname=W.pname and W.cname=C.cname and E.city=C.city order by E.pname;