Answered step by step
Verified Expert Solution
Question
1 Approved Answer
SUPPLIERS (SID : integer, SNAME: string, CITY: string) PARTS (PID : integer, PNAME: string, COLOR: string) CATALOG (SID: integer, PID: integer, COST: real) The key
SUPPLIERS (SID : integer, SNAME: string, CITY: string) PARTS (PID : integer, PNAME: string, COLOR: string) CATALOG (SID: integer, PID: integer, COST: real) The key fields are underlined, and the domain of each field is listed after the field name. Thus, SID is the key for SUPPLIERS, PID is the key for PARTS, and SID and PID together form the key for CATALOG. The CATALOG relation lists the prices charged for parts by suppliers. CATALOG.SID is a foreign key referring to SUPPLIERS.SID and CATALOG.PID is a foreign key referring to PARTS.PID Write the following queries in SQL . Find the SIDs of suppliers who supply a red part and a green part. 2. Find the SIDs of suppliers who supply a red part or a green part. 3. Find the SNAMEs of suppliers who supply every red part and every green part 4. Find the SNAMEs of suppliers who do not supply every red part. 5. For every supplier that only supplies red parts, print the SID and the name of the supplier and the average cost of parts that she supplies. 6. For each part, find the SNAMEs of the suppliers who do not charge the most for that part. The answer of this query should have two columns: PID and SNAME 7. For every part supplied by a supplier who is at the city of Newark, print the PID and the SID and the name of the suppliers who sell it at the highest price 8. For every part which has at least two suppliers, find its PID, its PNAME and the total number of suppliers who sell it 9. Find the PIDs of parts supplied by every supplier who is at the city of Newark or by every supplier who is at the city of Trenton 10. Find the PIDs of parts supplied by every supplier who is at the city of Newark and by every supplier who is at the city of Trenton 11. Find the SIDs of suppliers who supply a red part but do not supply a blue part. 12. For every supplier who supplies at least 4 parts, find his SID, SNAME and the PID of the most expensive part(s) that he supplies. 13. For every distinct color of the parts, find the total number of suppliers who supply a part of this color 14. Find the SIDs of suppliers who supply at least two parts of different color 15. For every part which has a supplier, find its PID, PNAME, its average cost, maximum cost and minimum cost
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