-
(edX stanfordOnline Databases: Modeling and Theory) Relational Algebra컴퓨터/DB 2025. 5. 6. 17:41728x90
https://www.edx.org/course/modeling-and-theory
StanfordOnline: Databases: Modeling and Theory | edX
This course is one of five self-paced courses on the topic of Databases, originating as one of Stanford's three inaugural massive open online courses released in the fall of 2011. The original "Databases" courses are now all available on edx.org. This cour
www.edx.org
* Relational algebra is a formal language.
(관계 대수는 형식 언어)
* It's an algebra that forms the underpinnings of implemented languages like SQL.
(SQL과 같은 구현된 언어의 기초를 형성하는 대수 체계이다.)
* Simplest query: relation name (ex. student)
Use operators to filter, slice, combine
* select operator: pick certain rows out of a relation
표기법: Sigma with a subscript(아래에 적은 문자) + the relation name over which we're finding that selection predicate
subscript: the condition that's used to filter the rows that we extract from the relations
* Project Operator
a list of attributes를 적는다
* example of Composing Operators
relational query들은 relations를 결과로 반환하므로 가능
* 중복은 제거된다.
The semantics of relational algebra says that duplicates are always eliminated.
SQL과 다른 점이다. (중복을 제거하지 않는다)
* Cartesian product
The result are every combination of tuples from those relations
위 예시에서 sID라는 어트리뷰트명이 동일하다.
이 경우 relation의 이름이 prefix로 붙는다.
It will be refer to as Student.sID and Apply.sID.
* Natural Join
어트리뷰트명이 같은 튜플끼리 결합한다.
(automatically enforces equality on the shared attributes)
그리고 같은 이름의 어트리뷰트를 중복 노출하지 않는다.
Student와 Apply를 natural join하면 student의 sID와 Apply의 sID가 같은 것끼리 결합한다.
그리고 sID는 칼럼 한 개로만 노출한다.
notation: bow tie
binary operator라 괄호를 해준다 (결합 법칙이 성립하여 안 해줘도 됨)
natural join은 관계 대수에 expressive power를 추가해주지 않는다.
natural join이 없어도 cross-product로 똑같은 결과를 얻을 수 있기 때문.
* Theta Join
Natural Join처럼 관계 대수에 expressive power를 더하는 operator는 아니다
표기법: bow tie operator + subscript theta(condition)
대부분의 데이터베이스에서 구현한다.
두 릴레이션을 받고, 모든 튜플을 combination한 후, theta condition을 만족하는 combination만 남긴다.
반응형'컴퓨터 > DB' 카테고리의 다른 글