기술(Tech, IT)/데이터베이스(Database)

[DB] JOIN - Implicit JOIN (1)

Daniel803 2023. 2. 22. 04:26

 Join에 대한 이해부터 시작하자. Join이란 아래와 같다.

:Typically, we want only combinations of the Cartesian product that satisfy certain conditions and so we would normally use a Join operation instead of the Cartesian product operation. The Join operation, which combines two relations to form a new relation, is one of the essential operations in the relational algebra.

: 특정 조건을 만족하는 Cartesian product(곱집합)을 만들고자 할 때 곱집합 연산 대신 Join 연산을 사용한다. Join 연산은 관계 대수에서 반드시 필요한 연산자의 하나로 두 개의 relation을 조합해 새로운 relation을 형성한다.

 

: JOIN is typically considered to analogous to multiplication since if table A has m tuples and table B has n tuples, A JOIN B can have as many as m x n tuples.

: JOIN은 곱하기와 유사하게 생각할 수 있다, 왜냐하면 테이블 A에 m개의 튜플이 존재하고 테이블 B에 n개의 튜플이 존재한다면 A JOIN B는 최대 m x n개의 튜플을 가질 수 있기 때문이다.

 

 JOIN 연산에는 Implicit JOIN과 Explicit JOIN이 있는데 Implicit JOIN은 오래된 방식으로 업계에선 더이상 사용하지 않는다. JOIN 명령어를 ','(콤마)로 대체하고 아래와 같이 사용할 수 있다.

 

Implicit JOIN:

SELECT id, name, school FROM student, student_major WHERE id = student_id;

Explicit JOIN:

SELECT id, name, school FROM student JOIN student_major ON id = student_id;

 

참고

- Database Systems, A Practical Approach to Design, Implementation and Management Sixth Edition