

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Note: Print your name and NetID in the upper right corner of every page of your submission. Handin your stapled homework to Trisha Benson in 4322 SC. In case Trisha is not in office, slide your homework under the door.
NOTE: Please use Greek notations for relational algebra operators. (e.g., σ for a selection operator, π for a projection operator, × for a cartesian product, ρ for a renaming operator, and 1 for a join operator.)
Consider the following relations:
Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)
Give the queries in relational algebra to answer the following questions.
(1.1) Find the sid of all suppliers who supply green parts. (1.2) Find the sname of suppliers who supply some green part but are NOT at “201 N. Goodwin Ave.”. (1.3) Find the sname of suppliers who don’t supply any part that is more expensive than $50.
Consider the following relations containing airline flight information:
Flights(flno, from, to, distance, departTime, arriveTime) Aircraft(aid, name, cruisingrange) Certified(eid, aid) Employees(eid, name, salary)
The Flights relation only contains non-stop flights information. Every pilot is an employee who is certified for some aircraft - otherwise he/she is not a pilot but just an employee. Only pilots are certified to fly.
Give the queries in relational algebra to answer the following questions.
(2.1) Find the names of pilots certified for an aircraft name “Boeing 747”. (2.2) Find the aids of all aircraft that can be used on non-stop flights from Chicago to San Jose.
(2.3) Find the eids of employees who make the highest salary, using the cartesian product (×) or the join operator ( 1 ) to determine the highest salary. (2.4) Find names of pilots who can operate planes with a range greater than 3,000 miles but are not certified on a “Boeing 747” aircraft. (For this problem, assume that pilot names are unique.)
(3.1) Using the difference relational operator (−), we can write the intersection of two relations R and S as R − (R − S). Write the relational algebra expression of the intersection of three relations (R, S, and T ), using only the difference relation operator (−).
(3.2) Assume that there is a database schema consisting of one relation, whose schema is: Student(sid,sname,gpa)
Using only the primitive operators (∪, −, σ, π, ×, and ρ), write the relational algebra ex- pression to find the sids of students with the highest gpa. (You should NOT use the extended operators in Section 5.4.)
Consider relations R(a,b,c), S(d,e,f), and T(a,d,g), where all the attributes are integers.
Use relational algebra to rewrite the following SQL queries:
(4.1) SELECT b FROM R WHERE b NOT IN (SELECT b FROM R, S, T WHERE R.a = T.a AND S.d = T.d AND f = 3);
(4.2) SELECT e FROM S WHERE f = 3 UNION SELECT e FROM S, T WHERE S.d = T.d AND g > 30;
Use SQL to rewrite the following queries:
(4.3) πb,a(σf =3(S) 1 σg> 50 (T ) 1 R).
(4.4) πe(S) − πe(S 1 T ).