Last modified on May 27th, 2019
Relational algebra, Union Operations, Binary Operations, Difference, Cartesian product
Relational algebra is a query language that processes one or more relations to define another relation.
The basic operation of relational algebra are as follows;
Operations which involve only one relation are called unary operations.
Operations which involve pairs of relations are called binary operations.
Union, Difference, Cartesian product
Selection operator is Sigma∑
It acts like a filter operation on relations.
∑ c (R)
Returns only those tuples in R that satisfy condition C
Comparison operators = < > =
Name Office Dept Rank
Saleem 400 Cs Assistant
Junaid 220 Econ Lecturer
Ghafoor 160 Econ Assistant
Babar 420 Cs Assistant
Saleem 500 Fin associate
Select only those employees who are in cs department BUT NOT lecturer AND NAME IS NOT SALEEM
∑ Dept = ‘cs’ AND-SYMBOL ¬(Rank=’lecturer’ AND-SYMBOL Name=’Saleem’)(Emp)
Select only those employees who are not in the cs department or lecturer.
∑ ¬(Rank=’lecturer’ OR-SYMBOL Dept = ‘cs’)(EMP)
Select only those employers who are assistant or in the economics department
∑ rank=’assitant’ OR-SYMBOL Dept = ‘Economics’(EMP)
Example: Select only those employees with the last name Saleem who are assistant.
∑ Name=’Saleem’ AND SYMBOL Rank = ‘assistant’ (EMP)
select only those employees who are in the CS department
∑ Dept = ‘Cs’ (EMP)