Professional Documents
Culture Documents
DBMS - Joins
DBMS - Joins
We underst and t he benefit s of t aking a Cart esian product of t wo relat ions, which gives us all t he
possible t uples t hat are paired t oget her. But it might not be feasible for us in cert ain cases t o t ake a
Cart esian product where we encount er huge relat ions wit h t housands of t uples having a considerable
large number of at t ribut es.
Join is a combinat ion of a Cart esian product followed by a select ion process. A Join operat ion pairs
t wo t uples from different relat ions, if and only if a given join condit ion is sat isfied.
Notation
R1 ⋈θ R2
R1 and R2 are relat ions having at t ribut es (A1, A2, .., An) and (B1, B2,.. ,Bn) such t hat t he at t ribut es
don’t have anyt hing in common, t hat is R1 ∩ R2 = Φ.
Equijoin
When Thet a join uses only equality comparison operat or, it is said t o be equijoin. The above example
corresponds t o equijoin.
Natural Join (⋈)
Nat ural join does not use any comparison operat or. It does not concat enat e t he way a Cart esian
product does. We can perform a Nat ural Join only if t here is at least one common at t ribut e t hat
exist s bet ween t wo relat ions. In addit ion, t he at t ribut es must have t he same name and domain.
Nat ural join act s on t hose mat ching at t ribut es where t he values of at t ribut es in bot h t he relat ions
are same.
Outer Joins
Thet a Join, Equijoin, and Nat ural Join are called inner joins. An inner join includes only t hose t uples wit h
mat ching at t ribut es and t he rest are discarded in t he result ing relat ion. Therefore, we need t o use
out er joins t o include all t he t uples from t he part icipat ing relat ions in t he result ing relat ion. There are
t hree kinds of out er joins − left out er join, right out er join, and full out er join.