Relational algebra, Union Operations, Binary Operations, Difference, Cartesian product
By: Prof. Dr. Fazal Rehman | Last updated: March 3, 2022
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 operationsSelection, ProjectionOperations 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 productSelection operation:Selection operator is Sigma∑It acts like a filter operation on relations.∑ c (R)Returns only those tuples in R that satisfy condition CConditions:Comparison operators = < > =Logical operatorsName Office Dept RankSaleem 400 Cs AssistantJunaid 220 Econ LecturerGhafoor 160 Econ AssistantBabar 420 Cs AssistantSaleem 500 Fin associateTable: EMPExampleSelect only those employees who are in cs department BUT NOT lecturer AND NAME IS NOT SALEEMSolution:∑ Dept = ‘cs’ AND-SYMBOL ¬(Rank=’lecturer’ AND-SYMBOL Name=’Saleem’)(Emp)ExampleSelect 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)“>