Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based on the above database schema, express the following queries in relational algebra. Assume set semantics for all operations. Please try to solve as many

image text in transcribed

Based on the above database schema, express the following queries in relational algebra. Assume set semantics for all operations.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Please try to solve as many as you can!

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 supplier's 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 part's name - color is part's color - pid is the primary key. Catalog (pid, sid,price) : tuples in the Catalog table correspond to a catalog entries: i.e., 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 - (sid,pid) is the primary key - sid is a foreign key referencing Suppliers(sid) - pid is a foreign key referencing Parts(pid) Orders (cid,pid, sid, qty) : each tuple in Orders corresponds to an order. Assumes 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 - (cid,sid, pid) is the primary key. - (sid,pid) is a foreign key referencing Catalog (sid,pid) 1. (10pts) Find all distinct parts supplied by Pullman stores. Return "pid"s of those parts. 2. (10pts)Find the suppliers in Pullman who supply a yellow part for less than $11. Return "sid"s and names for those suppliers. 3. (10pts) Find all parts which are provided by some supplier (i.e., they appear in the catalog) but they were never ordered by a customer. Return the "pid"s and names of those parts. 4. (10pts) Find all customers who ordered one of the products that Andy ordered. Return names and cities of those customers and the "pid"s of the products they ordered. 5. (10pts) Find the suppliers who have received orders from customers who live in the city where that supplier is located. Return "sid"s, names, and cities of those suppliers. 6. (10pts) Find customers who ordered more than 2 items from a single supplier (i.e., sum of the quantities of all parts customer purchased from the supplier is at least 3) . Return names of the customers,"sid"s of the suppliers, and number of items they ordered. 7. (10pts) Find the customer "cid"s who paid more than $20 on 'green' parts. 8. (10pts) Find the parts which are supplied by at least 2 different suppliers. Return the "pid"s, names, and colors of those parts. 9. (10pts)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. 10. (10pts) Find the number of suppliers in each city. Customers: Suppliers: Parts: Catalog: Orders: APPENDIX-B 1. Catalog.pid p1 p2 p 3 p5 p7 2 . Catalog.sid Suppliers.sname s1 BestTools 34 Parts and More 3. Parts.pid Parts.pname p7 Part7 4. Customers.cname Customers.city Orders.pid John Pullman p3 Kelly Moscow p2 Kelly Moscow p3 Kelly Moscow p5 Tom spokane p2 Tom spokane p3 Andy Pullman p3 Andy Pullman p5 Andy Pullman p2 5. Orders.sid Suppliers.sname Customers.city s2 Pullman Tools Pullman s4 Parts and More Pullman s3 Acme Tools Moscow 6. Customers.oname Orders.sid numItems John s23 Kelly s2 3 Tom 533 Tom s2 s s 4 Andy 563 Andy s2 3 7. Orders. cid c3 8. Parts.pidParts.pnamep1p5Parts.colorPart1Part5redyellow 9. Parts,pnamePart1Part2Part3Part5Part7Catalog.sid2s2s2s4s3s3Catalog.price2482015933 10. Suppliers.aity numsupplier Pullman 3 MoscowSpokane12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions