Professional Documents
Culture Documents
Chapter 5.1
V3.0
Copyright @ Napier University
Dr Gordon Russell
Relational Algebra
Relational Algebra is :
SELECT empno
FROM employee
WHERE depno = 1;
Set Operations - semantics
R
A 1
B 2 R UNION S
D 3 A 1
F 4 B 2
E 5 C 2
D 3
S E 5
A 1 F 4
C 2 E 4
D 3
E 4
INTERSECTION Example
R
A 1
B 2 R |NTERSECTION S
D 3
F 4 A 1
E 5 D 3
S
A 1
C 2
D 3
E 4
DIFFERENCE Example
R
A 1
B 2 R DIFFERENCE S
D 3
F 4 B 2
E 5 F 4
E 5
S
A 1 S DIFFERENCE R
C 2
D 3 C 2
E 4 E 4
CARTESIAN PRODUCT
S R JOINR.ColB = S.SColB S
SColA SColB
A 1 A 1 A 1
C 2 B 2 C 2
D 3 D 3 D 3
E 4 F 4 E 4
Natural Join
Notice that much of the data is lost when applying a join to two
relations. In some cases this lost data might hold useful
information. An outer join retains the information that would
have been lost from the tables, replacing missing data with
nulls.