Relational Algebra operators cheat sheet

All most used operators/symbols in Relational Algebra

Lorenzo Tinfena
4 min readApr 4, 2022

Attention: You should know all these operators, this is only to keep in mind all those in one place with an optional short explanation.

If you new in Relational algebra you can read this only to get an overview, and I recommend for a good knowledge to read this article by Khelifi Ahmed Aziz, that it seems quite complete to me.

Convention: For tuples I mean the rows in a relation.

Relational Algebra symbols operators cheat sheet complete all in one

Main operators

  • Projection: Output only some columns given their attribute names.
  • Selection: Output the tuples in ‘A‘ that satisfy the condition ‘c‘.
  • Rename: First form: Output ‘A‘ but with attribute ‘b‘ renamed to ‘a’. Second form: change the same of ‘A’ to ‘B’ and the corresponding attribute names.

Set operators

  • Union: (must be union-compatible) Output all not repeated tuples.
  • Interesction: (must be union-compatible) Output all common tuples.
  • Difference: (must be union-compatible) Output all ‘A’ tuples not also included in ‘B’.
  • Cartesian product / cross join / cross product: Output all possible tuple combinations, concatenating attributes.

Joins and join-like operators

  • Conditional join / Theta-join: Output pairs of tuples contanenated from ‘A’ and ‘B’ that satisfy the condition ‘θ’.
  • Equi join: Is a type of conditional join, but the condition ‘c’ is an equality.
  • Natural join: Is a type of Equi join, but with the default equality condition keep only the tuples such as for every commonly named attributes from ‘A’ and ‘B’, the value is equal.
  • Left/Right semijoin: Like natural join, but maintain only attributes of an only side.
  • Left/Right outer join: Like natural join, but keep also tuples of a side (some cells can be null).
  • Full outer join: Like natural join, but keep all tuples (some cells can be null).
  • Antijoin: Like left semijoin, but keep only tuples with different values for the same attribute name.
  • Division: The inverse of cartesian product, so it holds only unique attributes of ‘A’, in such a way that all possible combinations from the output and ‘B’ belong to ‘A’

The source is https://en.wikipedia.org/wiki/Relational_algebra , check that for more details.

Attention

I’m not an expert, and there may be errors in this project. It’s just my considerations with my very little experience. For this reason, considerations, improvements or criticisms are welcome in the comments.

--

--

Lorenzo Tinfena
Lorenzo Tinfena

Written by Lorenzo Tinfena

Computer science student - Artificial intelligence enthusiast. https://github.com/lorenzotinfena

No responses yet