Académique Documents
Professionnel Documents
Culture Documents
1/3
2/3
3/3
Binary operations
UNION operation:
INTERSECTION operation:
DIFFERENCE operation:
CARTESIAN PRODUCT: X
JOIN operations:
4/3
selection condition
<selection condition>
(R)
produced.
The resultant relation has less or equal number of tuples of the original relation.
Select operation is commutative
<condition1>
< condition2>
(R)) =
<condition2>
5/3
< condition1>
(R))
Hobby = stamps(Person)
Hobby=stamps(Person)
Person
Id
1123
1123
5556
9876
Name
Address
John
123 Main
John
123 Main
Mary 7 Lake Dr
Bart
5 Pine St
Hobby Id
stamps 1123
coins
9876
hiking
stamps
6/3
Name
John
Bart
Address
123 Main
5 Pine St
Hobby
stamps
stamps
other attributes.
<list1>
7/3
Name, Hobby(Person)
Id
Person
(Person)
Name
Address
Hobby
1123
1123
5556
9876
John
John
Mary
Bart
Name,
Hobby
8/3
Name
John
John
Mary
Bart
Hobby
stamps
coins
hiking
stamps
both.
This can be achieved by the RENAME operation
9/3
sid
S1
22
31
58
S1 S2
S2 sid
28
31
44
58
sid
sname rating
age
22
31
58
44
28
dustin
lubber
rusty
guppy
yuppy
45.0
55.5
35.0
35.0
35.0
10/3
7
8
10
5
9
S1
sid
22
31
58
S2 sid
28
31
44
58
S1 S2
11/3
S1
sid
22
31
58
S2 sid
28
31
44
58
S1 S2
13/3
is a relation R X S that has one tuple for each combination of tuples one from R and one
from S.
Relations R and S dont have to be type compatible.
a b
x1 x2
x3 x4
c d
y1 y2
y3 y4
15/3
a
x1
x1
x3
x3
b c
x2 y1
x2 y3
x4 y1
x4 y3
R S
d
y2
y4
y2
y4
17/3
S
B
A B
1 2 R(B)=S(B) 2
4
3 4
9
EQUIJOIN
C
5
7
10
D
6
8
11
A B B C D
1 2 2 5 6
3 4 4 7 8
18/3
NATURLAJOIN
A B C D
1 2 5 6
3 4 7 8
LEFT OUTER JOIN keeps all the tuples in the first relation R and if no matching tuples are found
in S, then the attributes of S in the join result are filled with nulls.
RIGHT OUTER JOIN is the same as left outer join but all tuples from S are kept and Rs values
are filled with nulls.
FULL OUTER JOIN keeps values from both relations and when no values are found pads them
with nulls.
19/3
SELECT C.CrsName
FROM Course C, Teaching T
WHERE C.CrsCode=T.CrsCode AND T.Sem=S2000
Also equivalent to:
20/3
End of Chapter 3
21/3