Question: Write in SQL. 2. Consider the following schema: Suppliers(id, name, address) Parts(id, name, color) Catalog (sid, pid, cost) where underlined field(s) are the primary key

2. Consider the following schema: Suppliers(id, name, address) Parts(id, name, color) Catalog (sid, pid, cost) where underlined field(s) are the primary key for each relation, sid is a supplier ID, and pid is a part ID. For example, Toshiba (supplier) may produce red battery cases (part) at $1.15 each (cost). Write the following queries in SQL. You should not have duplicate values in your results. (a) Find the names of suppliers who supply at least one red part. (b) Find the IDs of suppliers who supply at least one red part or are located at 123 College Ave. (c) Find the IDs of suppliers who supply all red or green parts (i.e., if a part is red or green, that supplier will have it). (d) Find the IDs of suppliers who supply all red parts or all green parts (i.e., if a part is red, then an all-red supplier will have it, and similarly for green). (e) Find the ID(s) of the most expensive part(s) supplied by Toshiba (there may be multiple parts with the same such price). 3. Consider the following schema: Students(id, name, major, level, age) Classes(name, startTime, room, pid) Takes(sid, cname) Profs(id, name, dept) Notes: - Underlined field(s) are the primary key for each relation. - level in Students is one of 'FR', 'SO', 'JR', or 'SR', representing what year the student is (freshman, sophomore, junior, or senior). - pid in Classes is the id of the professor teaching that course. - sid and cname in Takes are the student ID and course name, respectively. Write the following queries in SQL. You should not have duplicate values in your results. (a) Find the names of all juniors taking a class taught by Marie Curie. (b) Find the names of courses either held in Tillett 232 or with at least 5 students enrolled. (c) Find the names of professors who teach in every room in which some class is taught. (d) Find the average age of students for each level. (e) For each professor who has taught only in Tillett 232, list the professor's name and the total number of classes they've taught
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
