Database Management System

⌘K
  1. Home
  2. Docs
  3. Database Management Syste...
  4. The Relational Algebra an...
  5. Relational Algebra Operations from Set Theory

Relational Algebra Operations from Set Theory

Relational algebra includes a subset of operations derived from set theory, as relations (or tables) in databases are viewed as sets of tuples (rows).

The key set-theoretic operations in relational algebra are:

  • Union (∪)
  • Intersection (∩)
  • Difference (−)
  • Cartesian Product (×)

The Union operation combines the tuples (rows) of two relations. It returns all tuples that are present in either of the two relations, eliminating duplicates.

    Conditions:

    • Both relations must have the same number of attributes (columns).
    • The corresponding attributes must have the same type.
    union

    The Intersection operation returns only the tuples that are present in both relations. It retrieves the common elements between the two relations.

    Conditions:

    • Both relations must have the same number of attributes.
    • The corresponding attributes must have the same type.
    intersection

    The Difference operation returns the tuples that are present in the first relation but not in the second relation. It subtracts the second relation from the first.

    Conditions:

    • Both relations must have the same number of attributes.
    • The corresponding attributes must have the same type.
    difference

    The Cartesian Product operation combines each tuple of one relation with every tuple of another relation. It returns a new relation where every row of the first relation is paired with every row of the second relation, resulting in a relation with all possible combinations of tuples.

    cartesian

    How can we help?

    Leave a Reply

    Your email address will not be published. Required fields are marked *