{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Q2 soln

# Q2 soln - Exercises Suppliers(sid integer sname string...

This preview shows pages 1–4. Sign up to view the full content.

Exercises Find the names of suppliers who supply some red part. Suppliers( sid: integer, sname: string, address: string) Parts( pid: integer, pname: string, color: string) Catalog( sid: integer, pid: integer, cost: real) SELECT S.sname FROM Suppliers S, Parts P, Catalog C WHERE P.color=’red’ AND C.pid=P.pid AND C.sid=S.sid

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Exercises Find pairs of sids such that the supplier with the first sid charges  more for some part than the supplier with the second sid. Suppliers( sid: integer, sname: string, address: string) Parts( pid: integer, pname: string, color: string) Catalog( sid: integer, pid: integer, cost: real) SELECT C1.sid, C2.sid FROM Catalog C1, Catalog C2 WHERE C1.pid = C2.pid AND C1.sid = C2.sid AND C1.cost > C2.cost
Exercises Find the sids of suppliers who supply some red part or are at  221 Packer Street. Suppliers( sid: integer, sname: string, address: string) Parts( pid: integer, pname: string, color: string) Catalog( sid: integer, pid: integer, cost: real) SELECT S.sid FROM Suppliers S WHERE S.address = ‘221 Packer street’ OR S.sid IN (SELECT C.sid FROM Parts P, Catalog C WHERE P.color=’red’ AND P.pid = C.pid )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}