1)

Consider the following schema:

Suppliers(sid: integer, sname: string, address: string, country: string)

Parts(pid: integer, pname: string, color: string, weight: real)

Catalog(sid: integer, pid: integer, cost: real)

The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries

in SQL:

1. Write SQL statements to create these tables with the proper primary key and foreign

key constraints

2. Find the snames of all Chinese suppliers

3. Find the pnames of parts supplied by American suppliers

4. Find the pnames of parts for which there is some supplier.

5. Find the pnames of green parts that are not supplied by Italian suppliers.

6. Find the snames of suppliers who supply every part.

7. Find the snames of suppliers who supply every red part.

8. Find the pnames of parts supplied by Acme Widget Suppliers and no one else.

9. Find the sids of suppliers who charge more for some part than the average cost of

that part (averaged over all the suppliers who supply that part).

10.For each part, find the sname of the supplier who charges the most for that part.

11. Find the sids of suppliers who supply only red parts.

12.Find the sids of suppliers who supply a red part and a green part.

13.Find the sids of suppliers who supply a red part or a green part.

14.Find the average weight of red parts for suppliers from each country that has at least 2

suppliers.

15.For every supplier that only supplies green parts, print the name of the supplier and the

total number of parts that she supplies.

16.For every supplier that supplies a green part and a red part, print the name and price of

the most expensive part that she supplies.

Consider the following schema:

Suppliers(sid: integer, sname: string, address: string, country: string)

Parts(pid: integer, pname: string, color: string, weight: real)

Catalog(sid: integer, pid: integer, cost: real)

The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries

in SQL:

1. Write SQL statements to create these tables with the proper primary key and foreign

key constraints

2. Find the snames of all Chinese suppliers

3. Find the pnames of parts supplied by American suppliers

4. Find the pnames of parts for which there is some supplier.

5. Find the pnames of green parts that are not supplied by Italian suppliers.

6. Find the snames of suppliers who supply every part.

7. Find the snames of suppliers who supply every red part.

8. Find the pnames of parts supplied by Acme Widget Suppliers and no one else.

9. Find the sids of suppliers who charge more for some part than the average cost of

that part (averaged over all the suppliers who supply that part).

10.For each part, find the sname of the supplier who charges the most for that part.

11. Find the sids of suppliers who supply only red parts.

12.Find the sids of suppliers who supply a red part and a green part.

13.Find the sids of suppliers who supply a red part or a green part.

14.Find the average weight of red parts for suppliers from each country that has at least 2

suppliers.

15.For every supplier that only supplies green parts, print the name of the supplier and the

total number of parts that she supplies.

16.For every supplier that supplies a green part and a red part, print the name and price of

the most expensive part that she supplies.

### Recently Asked Questions

- Can anyone help me to introduce the debt policy of Amcor over the last 10 years?

- UAE business pays SAR 49,500, SAR 57,100, and SAR 62,700 to suppliers in, respectively, Japan, Switzerland, and Canada. The Japanese supplier payment is due in

- Generally speaking, Skinner believed aversive control to be more effective than reinforcement.