Escolar Documentos
Profissional Documentos
Cultura Documentos
Table of Contents
TOPICS
LAB
1:
LAB
2:
LAB
3:
LAB
4:
LAB
5:
PAGES
3
11
18
25
32
LAB
6:
54
THEORY
The basic set of operations for the relational model
These operations enable a user to specify basic retrieval requests.
The result of retrieval is a new relation, which may have been formed from one or more
relations.
The algebra operations thus produce new relations, which can be further manipulated
using operations of the same algebra.
FUNDAMENTAL OPERATORS
There are 4 fundamental operators to retrieve information from relational database.
Restrict ( Select )
<selection condition>( R )
Project
<attribute list> (R)
Page 2 of 9
Join
Inner Join
( <attribute list> (R))
Outer Join
Left Outer Join
( <attribute list> (R))
Cross Product
( <attribute list> (R)) X ( <attribute list> (R))
TRADITIONAL OPERATORS
There are 3 traditional set operator:
Union
( <attribute list> (R)) ( <attribute list> (R))
Intersection
( <attribute list> (R))
Difference
( <attribute list> (R)) ( <attribute list> (R))
ACTIVITY
The following activities (Activity 3A, Activity 3B and Activity 3C) are based on the tables below:
STAFF1
staffNo
00689
00500
00111
staffName
Samat
Ali
Anaz
Position
Electric engineer
Web developer
Programmer
STAFF2
staffNo
00111
00500
00689
00444
staffName
Anaz
Ali
Samat
Azie
Position
Programmer
Web developer
Electric engineer
Web developer
Page 3 of 9
00123
Hazlim
Technical support
PROJECT
projectNo
1
2
3
projectName
DADD
Programming
Multimedia
Cost
1 000 000
500 000
800 000
CUSTOMER
custNo
C001
C010
C011
C007
C021
custName
Adam & co
Tegas Tulin Sdn Bhd
Wangsa Mewangi Sdn Bhd
Wawasan Sdn Bhd
Halim & Son Sdn Bhd
projectNo
1
2
2
5
3
staffNo
00111
00123
00123
00999
00689
Activity 3A
Activity Outcome:
a. Identify the fundamental operators to retrieve information.
i. Restrict (Select)
ii. Project
iii. Join (Outer, Inner)
iv. Cross Product
Based on given table, generate the output base on operation below.
Restrict (Select)
Result1
Result1
staffNo
staffName
Position
00500
Ali
Web developer
00444
Azie
Web developer
Project
Result2
Result2
custNO
staffNo
Page 4 of 9
C001
Adams & Co
00111
C0010
00123
C0011
00123
C007
00999
C021
00689
JOIN
A. INNER JOIN
Result3
Result3
staffNo
0011
Position
cusNo
cusName
ProjNo
Anaz
Programmer
C001
Adams & Co
B. OUTER JOIN
Result4
Cartesian Product
Result5
STAFF1 X PROJECT
Result5
Page 6 of 9
Activity 3B
Activity Outcome:
a. Define the traditional set of operators.
i. Union
ii. Intersection
iii. Difference
Based on given table, generate the output base on operation below.
UNION
STAFF1
STAFF2
INTERSECTION
STAFF1
STAFF2
Page 7 of 9
DIFFERENCE
Difference STAFF1 - STAFF2
Activity 3C
Activity Outcome:
a. Use the operators to write the expression.
Based on given table, generate the expression using relational algebra on situation below.
1. Select from STAFF2 where position is Web Developer.
2. Select staff name and project number for staff 00123 in CUSTOMERs relation.
Page 8 of 9
Page 9 of 9