Tutorial 2
Problem 1:
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. You should use only the basic
operators plus join: (set union ‘U’, set difference ‘‘, selection ‘
σ
’, projection ‘
π
’, renaming ‘
ρ
’, and join ‘><’
(for natural join you can also just write ‘JOIN’)).
1. Find the sid of all suppliers who supply green parts.
2. Find the sid of all suppliers who supply only green parts.
3. Find the sname of suppliers who supply some green part but are NOT at "201 N. Goodwin Ave.".
4. Find the sname of suppliers who don't supply any part that is more expensive than $50.
Solution
1.
π
_[sid] (
σ
_[color='green'] (Parts JOIN Catalog))
2. The easiest way to solve these types of questions in relational algebra is to find the complement
relation and then compute its difference from the original relation.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '07
 Winslett
 Relational model, Tuple, $50

Click to edit the document details