Ammar Academy

RELATIONAL ALGEBRA
Relational algebra is a procedural query language, which takes instances of relations as input and yields instances of relations as output. It uses operators to perform queries. An operator can be either unary or binary.
Below depicts the Relational Algebra's symbols and set operations and functions.

Select Operation (σ)
It selects tuples that satisfy the given predicate from a relation.
Notation − σp(r)
Where σ stands for selection predicate and r stands for relation.
p is prepositional logic formula which may use connectors like and, or, and not. These terms may use relational operators like − =, ≠, ≥, < , >, ≤.
EXAMPLE:
1. Select tuples from books where subject subject is 'database'.
σsubject = "database"(Books)
2. Select tuples from books where subject is 'database' and 'price' is 450
σsubject = "database" and price = "450"(Books)
3. Select tuples from books where subject is 'database' and 'price' is 450 or those books published after 2010.
σsubject = "database" and price = "450" or year > "2010"(Books)
Project Operation (∏)
It projects column(s) that satisfy a given predicate.
Notation − ∏A1, A2, An (r)
Where A1, A2 , An are attribute names of relation r.
Duplicate rows are automatically eliminated, as relation is a set.
EXAMPLE:
1. Selects and projects columns named as subject and author from the relation Books.
∏subject, author (Books)