0% found this document useful (0 votes)
153 views8 pages

Lab Act2 Part 2 Completed

The document discusses relational algebra operators that can be used to retrieve and manipulate data from relational databases. It defines four fundamental operators: restrict (select), project, join (inner and outer), and cross product. It also defines three traditional set operators: union, intersection, and difference. Examples of applying each operator to sample tables are provided to demonstrate how they can be used to query and transform relational data.

Uploaded by

Thibyan Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views8 pages

Lab Act2 Part 2 Completed

The document discusses relational algebra operators that can be used to retrieve and manipulate data from relational databases. It defines four fundamental operators: restrict (select), project, join (inner and outer), and cross product. It also defines three traditional set operators: union, intersection, and difference. Examples of applying each operator to sample tables are provided to demonstrate how they can be used to query and transform relational data.

Uploaded by

Thibyan Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

THANUS A/L LOGANATHAN DFC 20203 DATABASE DESIGN

01DDT22F1106
DDTP2B

LAB ACTIVITY 2: Relational Data Model – PART 3


Duration: 4 Hours

Learning Outcomes

This activity encompasses activities 2H, 2I and 2J At the end of this activity, you should be

able to:
Identify the fundamental operators to retrieve information.
Restrict (Select)
Project
Join (outer, inner)
Cross Product

Define the traditional set of operators.


Union
Intersection
Difference

Use the operators to write the expression.

SCENARIO

Infinity Design Solution Sdn. Bhd, an advertising company wants to automate the system of
managing Human Resources (HR) data. Miss Suria was selected to be an IT programmer for
Infinity Design Solution. En. Mohamed insist to develop a system to manage staff payroll.
Miss Suria needs to prepare preliminary research about the operators and relational algebra.

INSTRUCTION:
Answer the entire questions below.

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
ormore relations.
◾ The algebra operations thus produce new relations, which can be
furthermanipulated using operations of the same algebra.

Page 1 of 57
DFC 20203 DATABASE DESIGN

FUNDAMENTAL OPERATORS

There are 4 fundamental operators to retrieve information from relational database.


 Restrict ( Select )
σ<selection condition>( R )

 Project
Л <attribute list> (R)

 Join
◾Inner Join
(Л <attribute list> (R)) (Л <attribute list> (R))

◾Outer Join
 Left Outer Join
(Л <attribute list> (R)) (Л <attribute list> (R))

 Right 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))

Page 2 of 57
THANUS A/L LOGANATHAN DFC 20203 DATABASE DESIGN
01DDT22F1106
DDTP2B

ACTIVITY

The following activities (Activity Activity 2H until Activity 2J) 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
00123 Hazlim Technical support

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

Page 3 of 57
DFC 20203 DATABASE DESIGN

Activity 2H
Activity Outcome: 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.

i. Restrict (Select)

Result1 σ Position = “Web developer” ( STAFF2 )


Result1
staffNo staffName Position

00500 Ali Web Developer

00444 Azie Web Developer

ii. Project Result2 Л custNo, custName, staffNo (CUSTOMER)


custNo custName staffNo

C001 Adam & co C001

C010 Tegas Tulin Sdn Bhd 00123

C011 Wangsa Mewangi Sdn Bhd 00123

C007 Wawasan Sdn Bhd 00999

C021 Halim & Son Sdn Bhd 00689

Page 4 of 57
THANUS A/L LOGANATHAN DFC 20203 DATABASE DESIGN
01DDT22F1106
DDTP2B

iii. JOIN
A. INNER JOIN

Result3 (Л staffNo, staffName, Position (STAFF2)) (Л custNo,


custName, ProjNo, staffNo (CUSTOMER))
staffNo staffName Position custNo custName projectNo staffNo

00111 Anaz Programmer C001 Adam & co 1 00111

00689 Samat Electric C021 Halim & 3 00689


engineer Sons Sdn
Bhd
00123 Hazlim Technical C010 Tegas 2 00123
Develepor Tulin Sdn
Bhd
00123 Hazlim Technical C011 Wangsa 2 00123
Developer Mewangu
Sdn Bhd

B. OUTER JOIN

Result4 (Л staffNo, staffName, Position (STAFF2)) (Л custNo,


custName, ProjNo, staffNo (CUSTOMER))

staffNo staffName Position custNo custName projectNo

00111 Anaz Programmer C001 Adam & 1


co
00500 Ali Web Developer Null Null Null

00689 Samat Electric engineer C021 Halim & 3


Son Sdn
Bhd
00444 Azie Web developer Null Null Null

00123 Hazlim Technical support C011 Wangsa 2


Mewangu
Sdn Bhd
00123 Hazlim Technical support C010 Tegas 2
Tulin Sdb
BHd

Page 5 of 57
DFC 20203 DATABASE DESIGN

iv. Cartesian Product

Result5 STAFF1 X PROJECT

staffNo staffName Position projectNo projectName Cost


00689 Samat Electric 1 DADD 1 000 000
engineer
00689 Samat Electric 2 Programming 500 000
engineer
000689 Samat Electric 3 Multimedia 800 000
engineer
00500 Ali Web Null Null Null
developer
00500 Ali Web 1 DADD 1 000 000
developer
00500 Ali Web 2 Programming 500 000
developer
00111 Anaz Programmer 1 DADD 1 000 000
00111 Anaz Programmer 2 Programming 500 000
00111 Anaz Programmer 3 Multimedia 800 000

Page 6 of 57
THANUS A/L LOGANATHAN DFC 20203 DATABASE DESIGN
01DDT22F1106
DDTP2B

Page 7 of 57
DFC 20203 DATABASE DESIGN

Page 8 of 57

You might also like