01/30/13

CSCI 2141 Handout January 30, 2013
Consider the following schema:
Supplier(sid: integer, sname: string, address: string)
Part(pid: integer, pname: string, colour: string)
Catalog(sid: integer, pid: integer, cost: real)
The relation Supplier stores suppliers and the key of that relation is sid. The relation Part stores parts, and pid is the key of that
relation. Finally, Catalog stores which supplier supplies which part at which cost. The key is the combination of the two
attributes sid and pid. Match the relational algebra query to its English equivalent:
Query
πsname(σcolour=’red’ (Part) σcost<100 (Catalog) Supplier)
∩ πsname (σcolour=’green’ (Part)
σcost<100
1.
(Catalog)
Supplier)
πsid(σcolour=’red’ (Part)
σcost<100 (Catalog)
Supplier) ∩ πsid(σcolour=’green’ (Part)
σcost<100
2.
(Catalog)
B. “Find the names of suppliers supplying some red
part for less than $100.”
Supplier)
3. πsname (σcolour=’red’ (Part)
σcost<100 (Catalog)
C. “Find the names of suppliers such that there is a
supplier with that name supplying some red part for
less than $100 and a supplier with that name
supplying some green part for less than $100.”
D. “Find the sids of suppliers supplying some red
part for less than $100 and some green part for less
than $100, and return only sid’s of suppliers
recorded in the table Supplier.”
Supplier)
πsname(πsid,sname(σcolour=’red’ (Part)
σcost<100 (Catalog) Supplier) ∩πsid,sname
(σcolour=’green’ (Part)
σcost<100 (Catalog)
5. πsname (πsid (σcolour=’red’ (Part)
4.
(Catalog))
Match English
A. “Find the names of suppliers supplying some red
part for less than $100.”
Supplier)
Supplier))
σcost<100
E. “Find the names of suppliers supplying some red
part for less than $100 and some green part for less
than $100.”