Chapter :- 3 (English)
Topic Wise Chapter (English)
6. Relational Algebra
Relational Algebra
Relational Algebra is a procedural query language used in relational databases.
It uses a set of mathematical operations to manipulate relations (tables) and produce new relations as output.
Here we cover four basic operations:
1. Union ( ∪ )
Definition:
Combines tuples (rows) from two relations and removes duplicates.
Requirements:
· Both relations must be union-compatible (same number of attributes, same data types).
Example:
A ∪ B
Gives all tuples present in either A or B.
2. Intersection ( ∩ )
Definition:
Returns only those tuples that are present in both relations.
Example:
A ∩ B
Gives common tuples of A and B.
3. Set Difference ( − )
Definition:
Returns tuples that are in the first relation but not in the second.
Example:
A − B
Gives tuples that exist in A but not in B.
4. Cartesian Product ( × )
Definition:
Combines every tuple of the first relation with every tuple of the second relation.
Example:
A × B
Produces a large table with all possible combinations.
· .
Used for:
Basis of JOIN operations in databases