본문 바로가기
데이터베이스설계

[데이터베이스설계] 2-7 차집합, 할당문

by 젼젼39 2024. 11. 16.
Set-Difference
operation

차집합
Set Difference operation 차집합 => r s
-      차집합 연산을 사용하면 한 relation엔 있지만 다른 relation에는 없는 튜플을 찾을수있음
-      차집합 연산으로 교집합 구할 수 있음  --> r s = r – (r – s) = s – (s – r)
* 유니온 호환성 성립되어야 차집합 성립
 

Q) find all courses taught in the Fall 2017 semester, but not in the Spring 2018 semester
  => π course_id (σ semester=”Fall” ^ year=2017 (section)) – π course_id (σ semester=”Spring” ^ year=2018 (section))
Assign
-ment
operation
<-
할당문
The assignment operation 할당문 => Physics <- σ dept_name = “Physics” (instructor)
-      일시적인 관계 변수에 일부를 할당해 관계대수식을 작성하는 게 편리함  //길면 보기 힘듦
-      할당 작업은 <- 로 표시됨. 프로그래밍 언어의 할당문st
 

Q) find all instructor in the “Physics” and “Music” department
=> Physics <- σ dept_name = “Physics” (instructor)
   Music <- σ dept_name = “Music” (instructor)
   Physics Music
 
-      할당연산을 이용해서, 쿼리를 일련의 할당으로 구성된 순차적 프로그램으로 작성한 다음,
        쿼리 결과 값이 표시되는 표현식으로 작성할 수 있음.