CPSC471 Relational Algebra Lecture Slides
CPSC471 Relational Algebra Lecture Slides
Relational
Algebra
Dr. Robert Collier
Winter 2015
Chapter Outline
Relational Algebra
Relational Algebra
10
11
12
13
14
15
16
17
18
19
20
21
RS=SR
(R S) T = R (S T)
22
23
24
25
26
27
28
29
DNAME
DNUMBER
MGRSSN
FNAME
MINIT
LNAME
SSN
Research
Administration
5
4
333445555
987654321
Franklin
Jennifer
T
S
Wong
Wallace
333445555
987654321
Headquarters
888665555
James
Borg
888665555
30
EQUIJOIN Operation
The most common use of join involves join conditions with
equality comparisons only. Such a join, where the only
comparison operator used is =, is called an EQUIJOIN. In the
result of an EQUIJOIN we always have one or more pairs of
attributes (whose names need not be identical) that have
identical values in every tuple.
The JOIN seen in the previous example was EQUIJOIN.
31
32
DNAME
DNUMBER
MGRSSN
MGRSTARTDATE
LOCATION
Headquarters
Administration
Research
1
4
5
888665555
987654321
333445555
1981-06-19
1995-01-01
1988-05-22
Houston
Stafford
Bellaire
Research
Research
5
5
333445555
333445555
1988-05-22
1988-05-22
Sugarland
Houston
33
34
35
36
37
38
39
40
41
SUM Salary
DNO
42
43
44
45
46
47
48
49
50
51
52
53
54
ALL_EMPS SSN(EMPLOYEE)
EMPS_WITH_DEPS ESSN(DEPENDENT)
EMPS_WITHOUT_DEPS
(ALL_EMPS - EMPS_WITH_DEPS)
RESULT
LNAME, FNAME (EMPS_WITHOUT_DEPS * EMPLOYEE)
55
TRS
a1
b1
a1
b1
a2
b1
a2
b4
a3
b1
a3
a4
b1
a1
b2
a3
b2
a2
b3
a3
b3
a4
b3
a1
b4
a2
b4
a3
b4
56
XSW
YX-R
Z B(Y)
TW-Z
b1
a1
b1
a1
b3
b2
b1
b2
a1
b2
a2
b2
b3
b4
b3
a1
b3
b4
a1
b4
a2
b1
a2
b2
a2
b3
a2
b4
a3
b1
a3
b2
a3
b3
a3
b4
57