Relational Algebra

It's a procedural query language , which takes relation as input and generate an output based on the condition . SQL base -> Relational Algebra Operators -> Extract data from database Operations : Selection Projection Union Set Difference Cartesian product Rename (P) Cartesian Product: Return all possible relations Join: Return only the condition matched relation Why not Cartesian Product? -> Join is two types . Inner Join -> Will return the tuples which will be matching with the condition . It is three types Theta Join Equi Join Natural Join Outer Join -> Will return the tuples which will be matching with condition along with other rows that will not be matched . It is three types Left Outer Join Right Outer Join Full Outer Join Equi Join : When theta join uses only equality(=) comparison operator , It is said to be equijoin . Notation: Sigma (Predicate) A*B Natural Join: The result of the natural join is the set of all combinations of tuples in two relations R1 and R2 that are equal on their common attribute names . In equi join , There needs a condition . In natural join , No need of condition . Notation:

Apr 22, 2025 - 17:52
 0
Relational Algebra

It's a procedural query language , which takes relation as input and generate an output based on the condition .

SQL base -> Relational Algebra

Operators -> Extract data from database

Operations :

  1. Selection
  2. Projection
  3. Union
  4. Set Difference
  5. Cartesian product
  6. Rename (P)

Cartesian Product: Return all possible relations
Join: Return only the condition matched relation

Why not Cartesian Product?
->

Join is two types .

  1. Inner Join -> Will return the tuples which will be matching with the condition . It is three types
  • Theta Join

  • Equi Join

  • Natural Join

Image description

  1. Outer Join -> Will return the tuples which will be matching with condition along with other rows that will not be matched . It is three types
  • Left Outer Join

  • Right Outer Join

  • Full Outer Join

Equi Join :
When theta join uses only equality(=) comparison operator , It is said to be equijoin .

Notation:

Image description

Sigma (Predicate) A*B

Natural Join:
The result of the natural join is the set of all combinations of tuples in two relations R1 and R2 that are equal on their common attribute names .

In equi join , There needs a condition . In natural join , No need of condition .

Notation: