Relation Algebra
Relation Algebra
Inner join
will have only those tuples that satisfy the matching criteria are included
It discards row(s) of either table that do not match any row of the other
table
Inner join
Types of inner join
1. Theta join()
2. Equi join()
3. Natural join()
Theta join()
A general case of join operation
Also called conditional join
Denoted by
Used to join two or more relations on some conditions
θ is a predicate
Conditional operators: : =,<,>, ≤,≥,and ≠
Theta join()
Equi join
A special case of theta joini
Where it uses the equivalence condition
Conditional operator: =
Equi join
Example
Natural Join
A special case of equi join
Can be used if there is only a common attribute
The name and domain of the attributes must be the same
Does not use any comparison operator
Natural join= Cartesian product+ selection+ projection
Example
Natural Join
Division Operation(/)
Denoted by / or
Used for queries qhich involve the ‘all’ or ‘every’
R1/R2 = tuples of R1 associated with all tuples of R2
If and only if every attribute of R2 is present in R1
Example
Division Operation(/)
Outer join
The results include unmatched rows of one of the tables, or of both
tables
The matching is based on the join condition
Types of outer join
1. Left outer join
2. Right outer join
3. Full outer join
Outer join
The results include unmatched rows of one of the tables, or of both
tables
The matching is based on the join condition
Types of outer join
1. Left outer join(will have matching rows and unmatching rows from
the left relation)
2. Right outer join(will have matching rows and unmatching rows from
the right relation)
3. Full outer join(will have matching rows and unmatching rows from
both left and right relation)
Example
Outer join