Presentation is loading. Please wait.

Presentation is loading. Please wait.

실습 4주차.

Similar presentations


Presentation on theme: "실습 4주차."— Presentation transcript:

1 실습 4주차

2 Exercise Exercise. Consider the following schema:
Suppliers(sid: integer, sname: string, address: 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. Therefore 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. Write the following queries in relational algebra.

3 1. σcolor=‘red’Parts 2. πpid σcolor=‘red’Parts
<Suppliers> <Parts> <Catalog> Sid Sname Address : Pid Pname color : Sid Pid cost : 문제) Find the names of suppliers who supply some red part. 1. σcolor=‘red’Parts 2. πpid σcolor=‘red’Parts <Parts> <Parts> Pid Pname color : p12 red Pid Pname color : p12 red

4 3. (πpid σcolor=‘red’Parts) ▷◁ Catalog
문제) Find the names of suppliers who supply some red part. 3. (πpid σcolor=‘red’Parts) ▷◁ Catalog <Parts> <Catalog> Pid Pname color : p12 red Sid Pid cost : s3 p12 Pid Pname color : p12 red Sid cost : s3

5 4. πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog)
문제) Find the names of suppliers who supply some red part. 4. πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) 5. πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) ▷◁ Suppliers Pid Pname color : p12 red Sid cost : s3 Pid Pname color : p12 red Sid cost : s3 Pid Pname color p12 : red Sid cost s3 : Sname Address Kim : <Suppliers> Sid Sname Address s3 Kim :

6 6. πsname(πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) ▷◁ Suppliers)
문제) Find the names of suppliers who supply some red part. 6. πsname(πsid((πpid σcolor=‘red’Parts) ▷◁ Catalog) ▷◁ Suppliers) Pid Pname color p12 : red Sid cost s3 : Sname Address Kim :

7 Exercise 1. Find the names of suppliers who supply some red part.
2. Find the sids of suppliers who supply some red or green part. 3. Find the sids of suppliers who supply some red part or are at 221 Packer Street. 4. Find the sids of suppliers who supply some red part and some green part. 5. Find the sids of suppliers who supply every part. 6. Find the sids of suppliers who supply every red part. 7. Find the sids of suppliers who supply every red or green part. 8. Find the sids of suppliers who supply every red part or supply every green part. 9. Find pairs of sids such that the supplier with the first sid charges more for some part than the supplier with the second sid. 10. Find the pids of parts supplied by at least two different suppliers. 11. Find the pids of the most expensive parts supplied by suppliers named Yosemite Sham. 1번 정답

8 1. 2. 3. 4. 5. 6.

9 7. 8. 9. 10.

10 11.

11 Q & A ?


Download ppt "실습 4주차."

Similar presentations


Ads by Google