๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์„ค๊ณ„

[๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์„ค๊ณ„] 2-6 ํ•ฉ์ง‘ํ•ฉ, ๊ต์ง‘ํ•ฉ

by ์ ผ์ ผ39 2024. 11. 15.
Union
operation

ํ•ฉ์ง‘ํ•ฉ
Union operation => ๋ฆด๋ ˆ์ด์…˜R ๋ฆด๋ ˆ์ด์…˜S
= 2๊ฐœ์˜ relation(ํˆฌํ”Œ์˜ ์ง‘ํ•ฉ)๋“ค์„ ๊ฒฐํ•ฉ     //์ค‘๋ณต ์ œ๊ฑฐ๋จ
 
* r, s๊ฐ€ ํ•ฉ์ง‘ํ•ฉ ์—ฐ์‚ฐ์ด ๋˜๊ธฐ ์œ„ํ•ด ๋งŒ์กฑํ•ด์•ผ ํ•˜๋Š” ์กฐ๊ฑด [์œ ๋‹ˆ์˜จ ํ˜ธํ™˜์„ฑ union compatibility]
(1) r, s๋Š” ๋™์ผํ•œ arity(์ปฌ๋Ÿผ์˜ ์ˆ˜)์„ ๊ฐ€์ ธ์•ผ ํ•œ๋‹ค
(2) ์†์„ฑ ๋„๋ฉ”์ธ(ํ•ด๋‹น์ปฌ๋Ÿผ์— ๋“ฑ์žฅ๊ฐ€๋Šฅํ•œ ๊ฐ’์˜ ์ง‘ํ•ฉ=์ปฌ๋Ÿผ๋ฐ์ดํ„ฐํƒ€์ž…)์ด compatible(ํ˜ธํ™˜)๋˜์–ด์•ผ ํ•จ.
    (์˜ˆ: r์˜ ๋‘๋ฒˆ์งธ column์€ s์˜ ๋‘๋ฒˆ์งธ column๊ณผ ๊ฐ™์€ ํƒ€์ž…์ด์–ด์•ผ ํ•จ)
 

Q) find all courses id taught in the Fall 2017 semester, or in the Spring 2018 semester. Or in both
  => π course_id (σ semester=”Fall” ^ year=2017 (section)) ∪ π course_id (σ semester=”Spring” ^ year=2018 (section))
Set-inter
-section
operation

๊ต์ง‘ํ•ฉ
Set-Intersection operation ๊ต์ง‘ํ•ฉ => r s
* ์œ ๋‹ˆ์˜จ ํ˜ธํ™˜์„ฑ์ด ์„ฑ๋ฆฝ๋˜์–ด์•ผ ๊ต์ง‘ํ•ฉ๋„ ์„ฑ๋ฆฝํ•จ
 

Q) find the set of all courses taught in both the Fall 2017 and the Spring 2018 semesters
  => π course_id (σ semester=”Fall” ^ year=2017 (section)) π course_id (σ semester=”Spring” ^ year=2018 (section))