Joins Revisited
Last updated
Last updated
Join operations take two relations and return as a result another relation
A join operation is a Cartesian product which requires that tuples in the two relations match (under some condition). It also specifies the attributes that are present in the result of the join
The join operations are typically used as subquery expressions in the from clause
Join condition – defines which tuples in the two relations match, and what attributes are present in the result of the join
Join type – defines how tuples in each relation that do not match any tuple in the other relation (based on the join condition) are treated
The cartesian product of two relations () will return all possible combinations of the tuples in r and s.
The cartesian product is the first step in joining two relations. A join is simply a catresian product followed by selection/projection.
We have 3 kinds of joins:
Conditional Join
This is the same as performing a cartesian product based on a condition.
It is denoted by () and is equivalent to .
Equijoin
The result of this join will only contain records having equal values for the common field.
Ex.
Natural Join
This is an equijoin considering all fields common between r and s. These fields do not have to be mentioned in a condition.
If there are no common fields, natural join will be the same as a cross product.