DBMS Joins Inner THETA Outer Equi Types of Join Operations
DBMS Joins Inner THETA Outer Equi Types of Join Operations
Operations
guru99.com/joins-sql-left-right.html
Types of Join
There are mainly two types of joins in DBMS:
Inner Join
Inner Join is used to return rows from both tables which satisfy the given condition. It is
the most widely used join operation and can be considered as a default join-type
Theta join
Natural join
EQUI join
Theta Join
Theta Join allows you to merge two tables based on the condition represented by theta.
Theta joins work for all comparison operators. It is denoted by symbol θ. The general
case of JOIN operation is called a Theta join.
Syntax:
1/6
A ⋈θ B
Table A Table B
1 1 1 1
1 2 1 3
For example:
column 1 column 2
1 2
EQUI Join
EQUI Join is done when a Theta join uses only the equivalence condition. EQUI join is
the most difficult operation to implement efficiently in an RDBMS, and one reason why
RDBMS have essential performance problems.
For example:
column 1 column 2
1 1
It performs selection forming equality on those attributes which appear in both relations
and eliminates the duplicate attributes.
2/6
Example:
Consider the following two tables
Num Square
2 4
3 9
Num Cube
2 8
3 18
C ⋈ D
C⋈D
2 4 8
3 9 18
Outer Join
An Outer Join doesn’t require each record in the two join tables to have a matching
record. In this type of join, the table retains each record even if no other matching record
exists.
3/6
Consider the following 2 Tables
Num Square
2 4
3 9
4 16
Num Cube
2 8
3 18
5 75
A B
A⋈B
2 4 8
3 9 18
4 16 –
In our example, let’s assume that you need to get the names of members and movies
rented by them. Now we have a new member who has not rented any movie yet.
4/6
A B
A⋈B
2 8 4
3 18 9
5 75 –
Example:
A B
A⋈B
2 4 8
3 9 18
4 16 –
5 – 75
Summary:
There are mainly two types of joins in DBMS 1) Inner Join 2) Outer Join
An inner join is the widely used join operation and can be considered as a default
join-type.
Inner Join is further divided into three subtypes: 1) Theta join 2) Natural join 3)
EQUI join
Theta Join allows you to merge two tables based on the condition represented by
theta
5/6
When a theta join uses only equivalence condition, it becomes an equi join.
Natural join does not utilize any of the comparison operators.
An outer join doesn’t require each record in the two join tables to have a matching
record.
Outer Join is further divided into three subtypes are: 1)Left Outer Join 2) Right
Outer Join 3) Full Outer Join
The LEFT Outer Join returns all the rows from the table on the left, even if no
matching rows have been found in the table on the right.
The RIGHT Outer Join returns all the columns from the table on the right, even if no
matching rows have been found in the table on the left.
In a full outer join, all tuples from both relations are included in the result,
irrespective of the matching condition.
6/6