Introduction

• Relational Algebra is a theoretical foundation for the query languages(SQL) used in relational database management systems (RDBMS).

Definition

• Relational algebra is a formal system used to manipulate relations (tables) in relational databases.

Characteristics

• Relational algebra provides a foundation for expressing queries and transformations on relational databases.
• It’s a mathematical framework that helps in understanding and designing efficient database queries and operations.

Relational Algebra Operations

The common operations used in relational algebra are:-

• Selection (σ):
• This operation retrieves rows from a relation/table that satisfy a given condition.
• It’s analogous to the WHERE clause in SQL.
• Projection (π):
• This operation retrieves specific columns from a relation, discarding the rest.
• It’s similar to the SELECT clause in SQL.
• Union (∪):
• This operation combines tuples from two relations(tables) that have the same schema, removing duplicates.
• Intersection (∩):
• This operation returns tuples that exist in both of the two relations.
• Difference (-):
• This operation returns tuples that are in one relation but not in the other.
• Cartesian Product (×):
• This operation combines every tuple in one relation with every tuple in another relation, resulting in a new relation with combined tuples.
• Join (⨝):
• This operation combines tuples from two relations based on a common attribute, creating a new relation.
• There are various types of joins, such as inner join, outer join (left, right, full), and natural join.

Categories: DBMS