Relational algebra

A family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it.

The primary operations of relational algebra:

  • Set Operations
    • Union(): For , The union of two relations, it contains all the tuples of , or , or both, with duplicate tuples being eliminated. Both relations must be union-compatible.
      For a union operation to be applied, the following rules must hold:
      • and must have the same quantity of attributes.
      • Attribute domains must be compatible.
      • Duplicate tuples get automatically eliminated.
    • Set Intersect(): Contains all the rows of frequent attributes from two relations.
    • Set different(): For , it retrieves tuples in that are not in .
    • Cartesian product(): Also called Cross-product, it combines two relations.
  • Relational Operations
    • Select(): It selects a sub-set of tuples that satisfy the given predicate from a relation. It is defined as , where stands for selection predicate, stands for relation, and is a propositional logic formula which may use connectors like and, or, and not.
    • Projection(): The Projection operation works on a single relation R, selecting certain attributes and discarding other. Duplicate tuples are automatically eliminated.
    • Rename(): operation to rename the output relation.
    • Assignment():
    • Set Division():
    • Join(): Similar to Cartesian Product, while satisfying certain situations.
      • Natural join(): Natural join between two or more relations will result set of all combination of tuples where they have equal common attribute.
      • Conditional Join(): similar to Natural Join with added conditions.

        - Theta join: Select rows of a cross product given a certain condition.
        - Equijoin: Select rows of a cross product given a equality condition holds between a pair of attributes.
      • Semi-Join()
      • Outer join
        • Left Outer Join(⟕)
        • Right Outer Join(⟖)
        • Full Outer Join(⟗)
  • Logical Operators
    • And()
    • Or()
    • Not()