{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full Document Right Arrow Icon
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
Background image of page 2
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 )
Background image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}