# Relational algebra, Union Operations, Binary Operations, Difference, Cartesian productÂ

## 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;
1.Unary operations
Selection, Projection
Operations which involve only one relation are called unary operations.
2.Binary operations:
Operations which involve pairs of relations are called binary operations.
Examples:
Union, Difference, Cartesian product

Selection operation:
Selection operator is Sigmaâ

It acts like a filter operation on relations.
â c (R)
Returns only those tuples in R that satisfy condition C
Conditions:
Comparison operators = < > =
Logical 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
Table: EMP

Example
Select only those employees who are in cs department BUT NOT lecturer AND NAME IS NOT SALEEM
Solution:
â Dept = âcsâ AND-SYMBOL ÂĴ(Rank=âlecturerâ AND-SYMBOL Name=âSaleemâ)(Emp)

Example
Select only those employees who are not in the cs department or lecturer.
â ÂĴ(Rank=âlecturerâ OR-SYMBOL Dept = âcsâ)(EMP)

Example:
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)

Example:

select only those employees who are in the CS department
â Dept = âCsâ (EMP)

“>

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,