Relational Algebra in DBMS
Table of Content:
What is Relational Algebra?
RELATIONAL ALGEBRA is a widely used procedural query language. It collects instances of relations as input and gives occurrences of relations as output. It uses various operations to perform this action. Relational algebra operations are performed recursively on a relation. The output of these operations is a new relation, which might be formed from one or more input relations.
Basic Relational Algebra Operations:
Relational Algebra devided in various groups
Unary Relational Operations
- SELECT (symbol: σ)
- PROJECT (symbol: π)
- RENAME (symbol: )
Relational Algebra Operations From Set Theory
- UNION (υ)
- INTERSECTION ( ),
- DIFFERENCE (-)
- CARTESIAN PRODUCT ( x )
Binary Relational Operations
- JOIN
- DIVISION
Operation |
Purpose |
Select(σ) |
The SELECT operation is used for selecting a subset of the tuples according to a given selection condition |
Projection(π) |
The projection eliminates all attributes of the input relation but those mentioned in the projection list. |
Union Operation(∪) |
UNION is symbolized by symbol. It includes all tuples that are in tables A or in B. |
Set Difference(-) |
- Symbol denotes it. The result of A - B, is a relation which includes all tuples that are in A but not in B. |
Intersection(∩) |
Intersection defines a relation consisting of a set of all tuple that are in both A and B. |
Cartesian Product(X) |
Cartesian operation is helpful to merge columns from two relations. |
Inner Join |
Inner join, includes only those tuples that satisfy the matching criteria. |
Theta Join(θ) |
The general case of JOIN operation is called a Theta join. It is denoted by symbol θ. |
EQUI Join |
When a theta join uses only equivalence condition, it becomes a equi join. |
Natural Join(?) |
Natural join can only be performed if there is a common attribute (column) between the relations. |
Outer Join |
In an outer join, along with tuples that satisfy the matching criteria. |
Left Outer Join |
In the left outer join, operation allows keeping all tuple in the left relation. |
Right Outer join |
In the right outer join, operation allows keeping all tuple in the right relation. |
Full Outer Join |
In a full outer join, all tuples from both relations are included in the result irrespective of the matching condition. |