Difference between a theta join, equijoin and natural join

maclunian picture maclunian · Oct 24, 2011 · Viewed 129.1k times · Source

I'm having trouble understanding relational algebra when it comes to theta joins, equijoins and natural joins. Could someone please help me better understand it? If I use the = sign on a theta join is it exactly the same as just using a natural join?

Answer

outis picture outis · Oct 24, 2011

A theta join allows for arbitrary comparison relationships (such as ≥).

An equijoin is a theta join using the equality operator.

A natural join is an equijoin on attributes that have the same name in each relationship.

Additionally, a natural join removes the duplicate columns involved in the equality comparison so only 1 of each compared column remains; in rough relational algebraic terms: ⋈ = πR,S-as ○ ⋈aR=aS