Professional Documents
Culture Documents
Dfc2033 Lab Activity
Dfc2033 Lab Activity
Dfc2033 Lab Activity
Table of Contents
TOPICS PAGES
Learning Outcomes
This activity encompasses activities 3A, 3B and 3C
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
DFC 2033 DATABASE SYSTEM
Join
Inner Join
(Л <attribute list> (R)) (Л <attribute list> (R))
Outer Join
Left Outer Join
(Л <attribute list> (R)) (Л <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)) (Л <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 staffName Position
00689 Samat Electric engineer
00500 Ali Web developer
00111 Anaz Programmer
STAFF2
staffNo staffName Position
00111 Anaz Programmer
00500 Ali Web developer
00689 Samat Electric engineer
00444 Azie Web developer
Page 3 of 9
DFC 2033 DATABASE SYSTEM
PROJECT
projectNo projectName Cost
1 DADD 1 000 000
2 Programming 500 000
3 Multimedia 800 000
CUSTOMER
custNo custName projectNo staffNo
C001 Adam & co 1 00111
C010 Tegas Tulin Sdn Bhd 2 00123
C011 Wangsa Mewangi Sdn Bhd 2 00123
C007 Wawasan Sdn Bhd 5 00999
C021 Halim & Son Sdn Bhd 3 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
Restrict (Select)
Result1 σ Position = “Web developer” ( STAFF2 )
Result1
staffNo staffName Position
Project
Result2
custNO custName staffNo
Page 4 of 9
DFC 2033 DATABASE SYSTEM
JOIN
A. INNER JOIN
Result3
staffNo staffName Position cusNo cusName ProjNo
B. OUTER JOIN
Result4 (Л staffNo, staffName, Position (STAFF2))
Page 5 of 9
DFC 2033 DATABASE SYSTEM
Result4
Cartesian Product
Result5 STAFF1 X PROJECT
Result5
Page 6 of 9
DFC 2033 DATABASE SYSTEM
Activity 3B
Activity Outcome:
a. Define the traditional set of operators.
i. Union
ii. Intersection
iii. Difference
UNION
STAFF1 STAFF2
INTERSECTION
STAFF1 STAFF2
Page 7 of 9
DFC 2033 DATABASE SYSTEM
DIFFERENCE
Difference STAFF1 - STAFF2
Activity 3C
Activity Outcome:
Based on given table, generate the expression using relational algebra on situation below.
2. Select staff name and project number for staff 00123 in CUSTOMER’s relation.
Page 8 of 9
DFC 2033 DATABASE SYSTEM
Page 9 of 9