0% found this document useful (0 votes)
40 views

Join Operations

The document discusses different types of join operations in databases including inner joins like theta joins and equi joins. It also covers outer joins like left, right, and full outer joins. Join operations allow combining tuples from different relations based on matching criteria.

Uploaded by

Thamizhmozhi N
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Join Operations

The document discusses different types of join operations in databases including inner joins like theta joins and equi joins. It also covers outer joins like left, right, and full outer joins. Join operations allow combining tuples from different relations based on matching criteria.

Uploaded by

Thamizhmozhi N
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Join Operations

Join operation is essentially a cartesian product followed by a selection


criterion.

Join operation denoted by ⋈.

JOIN operation also allows joining variously related tuples from different
relations.

Types of JOIN:

Various forms of join operation are:

Inner Joins:

 Theta join
 EQUI join
 Natural join

Outer join:

 Left Outer Join


 Right Outer Join
 Full Outer Join

Inner Join
In an inner join, only those tuples that satisfy the matching criteria are
included, while the rest are excluded. Let’s study various types of Inner
Joins:

Theta Join
The general case of JOIN operation is called a Theta join. It is denoted by
symbol θ
Example
A ⋈θ B
Theta join can use any conditions in the selection criteria.

For example:
A ⋈ A.column 2 > B.column 2 (B)
A ⋈ A.column 2 > B.column 2 (B)
column 1 column 2
1 2
EQUI join
When a theta join uses only equivalence condition, it becomes a equi join.

For example:
A ⋈ A.column 2 = B.column 2 (B)
A ⋈ A.column 2 = B.column 2 (B)
column 1 column 2
1 1
EQUI join is the most difficult operations to implement efficiently using
SQL in an RDBMS and one reason why RDBMS have essential performance
problems.

NATURAL JOIN (⋈)


Natural join can only be performed if there is a common attribute (column)
between the relations. The name and type of the attribute must be same.

Example

Consider the following two tables

C
Num Square
2 4
C
3 9
D
Num Cube
2 8
3 27
C⋈D
C⋈D
Num Square Cube
2 4 8
3 9 27
OUTER JOIN
In an outer join, along with tuples that satisfy the matching criteria, we
also include some or all tuples that do not match the criteria.

Left Outer Join(A ⟕ B)


In the left outer join, operation allows keeping all tuple in the left relation.
However, if there is no matching tuple is found in right relation, then the
attributes of right relation in the join result are filled with null values.

Consider the following 2 Tables

A
Num Square
2 4
A
3 9
4 16
B
Num Cube
2 8
3 18
5 75
A B
A⋈B
Num Square Cube
2 4 8
3 9 18
4 16 –
Right Outer Join ( A ⟖ B )
In the right outer join, operation allows keeping all tuple in the right
relation. However, if there is no matching tuple is found in the left relation,
then the attributes of the left relation in the join result are filled with null
values.

A B
A⋈B
Num Cube Square
2 8 4
3 18 9
A⋈B
5 75 –
Full Outer Join ( A ⟗ B)
In a full outer join, all tuples from both relations are included in the result,
irrespective of the matching condition.
A B
A⋈B
Num Cube Square
2 4 8
3 9 18
4 16 –
5 – 75
Summary
Operation(Symbols) Purpose
The SELECT operation is used for
selecting a subset of the tuples
Select(σ)
according to a given selection
condition
The projection eliminates all attributes
Projection(π) of the input relation but those
mentioned in the projection list.
UNION is symbolized by symbol. It
Union Operation(∪) includes all tuples that are in tables A
or in B.
– Symbol denotes it. The result of A – B,
Set Difference(-) is a relation which includes all tuples
that are in A but not in B.
Intersection defines a relation
Intersection(∩) consisting of a set of all tuple that are in
both A and B.
Operation(Symbols) Purpose
Cartesian operation is helpful to merge
Cartesian Product(X)
columns from two relations.
Inner join, includes only those tuples
Inner Join
that satisfy the matching criteria.
The general case of JOIN operation is
Theta Join(θ) called a Theta join. It is denoted by
symbol θ.
When a theta join uses only
EQUI Join equivalence condition, it becomes a
equi join.
Natural join can only be performed if
Natural Join(⋈) there is a common attribute (column)
between the relations.
In an outer join, along with tuples that
Outer Join
satisfy the matching criteria.
In the left outer join, operation allows
Left Outer Join( )
keeping all tuple in the left relation.
In the right outer join, operation allows
Right Outer join( )
keeping all tuple in the right relation.
In a full outer join, all tuples from both
Full Outer Join( ) relations are included in the result
irrespective of the matching condition.

You might also like