Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following schema ( primary key fields are underlined ) : Customers ( cid , cname, city ) - cid is the unique identifier
Consider the following schema primary key fields are underlined:
Customers cid cname, city
cid is the unique identifier for the customer
cname is the name of the customer
city is the city where customer resides
cid is the primary key.
Suppliers sid sname, city
sid is the unique identifier for the supplier
sname is suppliers name
city is the city supplier is located
sid is the primary key
Parts pid pname, color
pid is the unique identifier for the part
pname is the parts name
color is parts color
pid is the primary key.
Catalog pid sid,price : tuples in the Catalog table correspond to a catalogentries: ie parts and their suppliers.
pid is the id of the part in the catalog entry
sid is id of the supplier that supplies the part in the catalog
price is the cost of the part in the catalog
sidpid is the primary key
sid is a foreign key referencing Supplierssid
pid is a foreign key referencing Partspid
Orders cidpid, sid, qty : each tuple in Orders corresponds to an order. Assume each customer orders a particular part from a supplier once.
cid is the customer that buys the part
pid is the part sold
sid is the supplier that supplies the part
qty is the number of parts sold in a particular order
cidsid, pid is the primary key.
sidpid is a foreign key referencing Catalog sidpid
Based on the above database schema, express the following queries in relational algebra. Assume set semantics for all operations.
Find all distinct parts supplied by Pullman stores. Return pids of those parts.
Find the suppliers in Pullman who supply a yellow part for less than $ Return sids and names for those suppliers.
Find all parts which are provided by some supplier ie they appear in the catalog but they were never ordered by a customer. Return the pids and names of those parts.
Find all customers who ordered one of the products that Andy ordered. Return names and cities of those customers and the pids of the products they ordered.
Find the suppliers who have received orders from customers who live in the city where that supplier is located. Return sids names, and cities of those suppliers.
Find customers who ordered more than items from a single supplier ie sum of the quantities of all parts customer purchased from the supplier is at least Return names of the customers,sids of the suppliers, and number of items they ordered.
Find the customer cids who paid more than $ on green parts.
Find the parts which are supplied by at least different suppliers. Return the pids names, and colors of those parts.
For each part in the catalog find the supplier that offers the lowest price; give the part name, supplier sid and the price supplier sells the part for.
Find the number of suppliers in each city.
The same data is also available in appendix A In the tool, you can try the queries and check the output. The expected output for each relational algebra expression is provide in appendix B
APPENDIXA
Customers:
cidcnamecity
cJohnPullman
cAlliPullman
cKellyMoscow
cTomSpokane
cSamSpokane
cAndyPullman
Suppliers:
sidsnamecity
sBest ToolsPullman
sPullman ToolsPullman
sAcme ToolsMoscow
sParts & MorePullman
sSupply StoreSpokane
sSpokane HW StoreSpokane
Parts:
pidpnamecolor
pPartred
pPartred
pPartgreen
pPartgreen
pPartyellow
pPartred
PPartred
Catalog:
pidsidprice
ps$
ps$
ps$
ps$
ps$
ps$
ps$
ps$
ps$
ps$
ps$
ps$
ps$
ps$
Orders:
cidpidsidqty
cps
cps
cps
cps
cps
cps
cps
cps
cps
cps
cps
cps
cps
APPENDIXB
Catalog.pid
p
p
p
p
p
Catalog.sid Suppliers.sname
s BestTools
s Parts and More
Parts.pid Parts.pname
p Part
Customers.cname Customers.city Orders.pid
John Pullman p
Kelly Moscow p
Kelly Moscow p
Kelly Moscow p
Tom Spokane p
Tom Spokane p
Andy Pullman p
Andy Pullman p
Andy Pullman p
Orders.sid Suppliers.sname Customers.city
s Pullman Tools Pullman
s Parts and More Pullman
s Acme Tools Moscow
Customers.cname Orders.sid numItems
John s
Kelly s
Tom s
Tom s
Andy s
Andy s
Orders.cid
c
Parts.pid; Parts.pname; Parts.color
p; Part; red
p; Part; yellow
Parts.pname; Catalog.sid; Catalog.price
Part; s;
Part; s;
Part; s;
Part; s;
Part; s;
Suppliers.city; numSupplier
Pullman;
Moscow;
Spokane;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started