presentation
TRANSCRIPT
![Page 1: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/1.jpg)
![Page 2: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/2.jpg)
Topic: Relational Algebra:
1)unary operation 2)Binary operation
Presented By: Group #03
Members: 1 : Sania Shokat 2 : Ayesha Ramzan 3 : Arooj fatima 4 : Mehwish Aslam
![Page 3: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/3.jpg)
Table of contents:Relational Algebra:
Unary Operationo Selectiono projection
Binary Operationo Union o Set Difference o Cartesian Product
![Page 4: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/4.jpg)
Relational Algebra:
Relational Algebra is a procedural language that processes one or more relations to define another relation without changingoriginal relation.
![Page 5: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/5.jpg)
1.Selection Operation: o Acts like a filter on a relation.o Return only a certain number of tuples.o Selects the tuple using a condition.o Resulting relation has the same degree as the original relation.
Unary Relation:
o Involve only one relation.
![Page 6: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/6.jpg)
Examples: Assume a relation EMP has the following tuples:
Name Office Dept RankAhmed 220 CS lecturerbaber 140 Ecno AssistantSaleem 160 CS Associatemirza 500 FIn Associate
![Page 7: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/7.jpg)
σ dept=‘cs’(EMP)
Result:.
Name Office Dept RankAli 400 CS AssistantSaleem 160 CS Associate
Question: Select only those employees who are in CS department.
![Page 8: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/8.jpg)
2. Projection:
o Limit the attribute returned from the original relation.o Projection operator is pi π .o Resulting table has the same number of tuples as the original.
Example: Assume the EMP relation
Name Office Dept RankAhmed 220 CS lecturerbaber 140 Ecno AssistantSaleem 160 CS Associatemirza 500 FIn Associate
![Page 9: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/9.jpg)
Question:Display the names and departments of the all employees working inCS department:
π name,Dept (σ dept=‘cs’(EMP) )
Result:Name DeptAhmed CSSaleem CS
![Page 10: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/10.jpg)
o Operations which involve pairs of relations.
o Uses two operations as input and produce a new relation as output.
o Types:
1. Union
2. Set Difference
3. Cartesian Product
Binary Operations:
![Page 11: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/11.jpg)
o Union operation of two relations combines the tuples of both relations to produce a third relation.
o Denoted by U.
1.Union:
![Page 12: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/12.jpg)
X
Y Z
1 A 10
2 B 20
3 C 30
X Y Z
1 A 10
4 D 40
5 E 50
X Y Z
1 A 10
2 B 20
3 C 30
4 D 40
5 E 50
Table A Table B A UNION B
Example: (A U B)
Two relations A and B are combined together by using union operator.
![Page 13: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/13.jpg)
2. Set Difference
o Works on two relations.
o Produces a third relation that contains the tuples that occur
in the first relation but not in second.
![Page 14: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/14.jpg)
Example: There are two relations A and B.
X Y Z
1 A 10
2 B 20
3 C 30
X Y Z
1 A 10
4 D 40
5 E 50
X Y Z
2 B 20
3 C 30
X Y Z
4 D 40
5 E 50
Table B A - B B - ATable A
![Page 15: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/15.jpg)
3. Cartesian Product :
o Works on two relations.
o Concatenates every tuple in one relation with every tuple second.
o Also called cross product.
o Product is denoted by a × b.
![Page 16: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/16.jpg)
Example:
X Y Z
1 A 10
2 B 20
3 C 30
Table A
X Y Z
1 A 10
4 D 40
5 E 50
X1
Y1
Z1
X2
Y2
Z2
1 A 10
1 A 10
1 A 10
4 D 40
1 A 10
5 E 50
2 B 20
1 A 10
2 B 20
4 D 40
2 B 20
5 E 50
3 C 30
1 A 10
3 C 30
4 D 40
3 C 30
5 A 50
Table B
Table A × B
![Page 17: Presentation](https://reader036.vdocuments.us/reader036/viewer/2022070600/58e4a45b1a28aba3458b6877/html5/thumbnails/17.jpg)