You are on page 1of 15

DFC 2083 DATABASE DESIGN

LAB ACTIVITY 3: Entity Relationship (ER) Model &


Normalization – Part 1
Duration: 2 Hours

Learning Outcomes
This activity encompasses activities 3A, 3B, 3C
At the end of this activity session, you should be able to:
1. Identify the basic elements of ERD.
2. Convert a given ERD into relational tables.

Activity 3A
Activity Outcome: Identify the basic elements of ERD and design the ERD based on a
given scenario by using Chen’s Model.

SCENARIO

Infinity Design Solution Sdn. Bhd, is an advertising company recently signed a new strategic
agreement to collaborate with Success Software Co., a software contract and consultancy
firm. For now onwards, both company are sharing the resources and knowledge in various
fields. Recently, Success Software Co wants to upgrade their database with the following
information:
 Customer - CustomerID, Name, Email, Telephone
 Location – LocationID, Address, Type
 Rate – RateID, RateClass, RatePerKWH

After doing their preliminary analysis, the have come up with the following business rules:
 Customer can have one or more locations
 Each location can have one and only one customer
 Each location can have one or more rates
 Each rate may be used at many locations, or not used at a location

INSTRUCTION:
Answer the entire questions below.

1. Identify all the basic elements of ERD that are involved based on the above scenario:
a) Entity and Attribute

Entity Attribute

Page 29 of 61
DFC 2083 DATABASE DESIGN

b) Relationship, Connectivity and Cardinality

has

use

c) Identifier keys

Entity Primary Key

2. Draw the E-R Diagram using Chen’s Model based on the Activity3A.

Page 30 of 61
DFC 2083 DATABASE DESIGN

Activity 3B
Activity Outcome: Identify the basic elements of ERD and design the ERD based on a
given scenario by using Crow’s Foot.

SCENARIO

Infinity Design Solution Sdn. Bhd, is an advertising company was dealing with AIA Insurance
to provide insurance coverage for company vehicles.

AIA needs to keep track of information about the vehicles for Infinity Design Solution Sdn Bhd.
They need to store information of customer, car and accident. Customer information including
LicenseNo, Name, and Address. Customer can own one or more cars, where the car
information including PlateNo, Model and Year. A car not involved or involved in many
accidents. If the car is involved in an accident, the information need to be aware is ReportNo,
Location and Date.

INSTRUCTION:
Answer the entire questions below.

1. Identify all the basic elements of ERD that are involved based on the above scenario:
a) Entity and Attribute

Entity Attribute

b) Relationship, Connectivity and Cardinality

own

involve

c) Identifier keys

Entity Primary Key

Page 31 of 61
DFC 2083 DATABASE DESIGN

2. Draw the E-R Diagram using Crow’s Foot Model based on the Activity3B

Page 32 of 61
DFC 2083 DATABASE DESIGN

Activity 3C
Activity Outcome: Convert a given ERD into relational tables.

1. Convert the E-R Diagram based on the Activity 3A into the relational tables.

2. Convert the E-R Diagram based on the Activity 3B into the relational tables.

Page 33 of 61
DFC 2083 DATABASE DESIGN

LAB ACTIVITY 3: Entity Relationship (ER) Model &


Normalization – Part 2
Duration: 4 Hours

Learning Outcomes
This activity encompasses activities 3D and 3E

At the end of this activity session, you should be able to:


1. Design E-R Diagram based on a given scenario by using Chen’s Model and
Crow’Foot

Activity 3D
Activity outcome: Using Chen Model Notation, Draw the ERD for the given scenario below.

There are many soccer teams in Liga Super Malaysia ; each team has an ID,name,main stadium,
and which city this team belongs.Each team has many players,and each player belongs to one
team.Each player has a number,name,DOB,start year and shirt number that he uses.Teams play
matches, for each match you need to keep track the date on which the game is played, match ID
and the final result of the match.Each match has exactly three referees.For each referee have an
referee ID,name,DOB and year of experience.

(10 Marks)

Page 34 of 61
DFC 2083 DATABASE DESIGN

Activity 3E
Activity outcome: Using Crow’s Foot Model Notation, Draw the ERD for the given scenario
below.

Seremban Hospital has several wards. This hospital has a few types of ward depends on types
of patients. Patient information will be recorded into file that patient number, patient name,
address, phone number, IC number, patient and group of blood patient. Each patient is treated
by a doctor at one time but one doctor can treats a number of patients. The information of doctors
recorded are: doctor ID, doctor name, address, phone no, IC no and expertise. The nurses will
be assigned to take care of the patients. Nurses in this hospital are graded based on their
experience, qualification and duration of working in the hospital.

(10 Marks)

Page 35 of 61
DFC 2083 DATABASE DESIGN

LAB ACTIVITY 3: Entity Relationship (ER) Model &


Normalization – Part 3
Duration: 4 Hours

Learning Outcomes
This activity encompasses activities 3F, 3G, 3H, 3I and 3J.

At the end of this activity session, you should be able to:


1. Understand normalization in database.
2. Understand Functional and Transitive dependencies
3. Construct normalization from 1NF until 3NF.

Activity 3F
Activity Outcome : Understand normalization in database.

Fill in the appropriate terms for normalization in database based on the following statements.

1. ______________________ is a 2 dimensional table with columns and row.

2. 2 problems in relational data model are _______________________________ and


______________________________________.

3. 3 types of anomalies are _________________________, _________ ______________

and ______________________________.

4. ___________________________ is a process for assigning into a table and reduces data


redundancy and helps eliminate the data anomalies.

5. ________________________ is a table that contains one or more repeating groups.

6. 3 level of normalization are _______________________, _______________________ and


_____________________________.

7. ________________________ is a relation in which based on the concept of transitive


dependency.

8. In the _____________ normal form, a composite attribute is converted to individual attribute

Page 36 of 61
DFC 2083 DATABASE DESIGN

Activity 3G
Activity Outcome : Understand functional and transitive dependencies
in database normalization.

Consider the following relation definition and sample data:

PROJECT
ProjectID EmployeeName EmployeeSalary
100A Jamilah 1500
100A Samad 2000
100B Samad 2000
200A Jamilah 1500
200B Jamilah 1500
200C Affendi 2500
200C Samad 2000
200D Affendi 2500

PROJECT (ProjectID, EmployeeName, EmployeeSalary)

Where ProjectID is the name of a work project.


EmployeeName is the name of an employee who works on that project.
EmployeeSalary is the salary of the employee whose name is EmployeeName.

Assuming that all of the functional dependencies and constraints are apparent in this data,
which of the following statements is true?

 ProjectID EmployeeName
 ProjectID_ EmployeeSalary
 (ProjectID, EmployeeName) EmployeeSalary
 EmployeeName EmployeeSalary
 EmployeeSalary ProjectID
 EmployeeSalary (ProjectID, EmployeeName)

Answer these questions:

a) What is a key for PROJECT?


b) Are all non-key attributes dependent on the entire key?
c) In what normal form is PROJECT?
d) Describe two modification anomalies from which PROJECT suffers.

Page 37 of 61
DFC 2083 DATABASE DESIGN

Activity 3H
Activity Outcome: Construct normalization process (UNF – 3NF) based on the given
scenario.

SCENARIO

Success Software Co., a software contract and consultancy firm maintains details of all the
various projects in which its employees are currently involved. These details comprise:
 Employee Number
 Employee Name
 Date of Birth
 Department Code
 Department Name
 Project Code
 Project Description
 Project Supervisor
Assume the following:
 Each employee number is unique.
 Each department has a single department code.
 Each project has a single code and supervisor.
 Each employee may work on one or more projects.
 Employee names need not necessarily be unique.
 Project Code, Project Description and Project Supervisor are repeating fields.

Page 38 of 61
DFC 2083 DATABASE DESIGN

LAB ACTIVITY 3: Entity Relationship (ER) Model &


Normalization – Part 4
Duration: 4 Hours

Learning Outcomes
This activity encompasses activities 3I and 3J.

At the end of this activity session, you should be able to:


4. Understand normalization in database.
5. Understand Functional and Transitive dependencies
6. Construct normalization from 1NF until 3NF.

Activity 3I
Activity Outcome: Construct normalization process (UNF – 3NF) based on the given
relation.

Staff
Project# ProjectName Staff# Position RateHour TotalWorkHour
Name
PA201 ABC Web 00658 Samat Electrical Eng. RM20 20
Development
00500 Halim Web Developer RM22 18
00444 Azie Web Developer RM22 15
PP421 XYZ System 11254 Kamal System Analyst RM25 30
Development
00925 Hazlim Technician RM16 56
PM715 PQR Mobile 00658 Samat Electrical Eng. RM20 40
Development
00500 Anaz Programmer RM18 35
11254 Kamal System Analyst RM25 27

Page 39 of 61
DFC 2083 DATABASE DESIGN

Activity 3J
Activity Outcome: Construct normalization process (UNF – 3NF) based on the given
form.

MPH Stationary Sdn Bhd

No Peminjam : BR001 Asrama : Kolej Delima Satu


Nama : Nur Shaza Shamira No Bilik : DS12
Alamat : Jalan Kusai
No
Nama Buku Pinjam Pulang Pengarang Penerbit
Buku

BK011 Sejarah Semalam 12/03/16 15/03/16 Budiman Fajar Bakti

BK012 Hijau Bumi Malaysia 15/06/16 29/06/16 Hajar Pelangi

BK013 Merah 14/05/16 24/05/16 Johan Pelangi

Page 40 of 61
DFC 2083 DATABASE DESIGN

LAB ACTIVITY 4: Structured Query Language (SQL) –


Part 1
Duration: 2 Hours

Learning Outcomes
This activity encompasses activities 4A, 4B

At the end of this activity session, you should be able to:


1. Understand and apply DDL commands.
2. Understand and apply DML commands
3. Understand and apply SQL Advanced commands
4. Understand and apply SQL Functions

Hardware / Software: MySQL

SCENARIO

Miss Suria has been given the task of developing a database for a system of salary for the
company Millennium Cyber Sdn. Bhd. Miss Suria only has been given a month to complete
the task. Based on IT Manager of Infinity Design Solution Sdn Bhd, Miss Suria will be helped by
a practical student. Unfortunately, the student is not familiar with the concept of develop
database by using MySQL. Hence, Miss Suria need to implement workshop for students related
to the concept of SQL. These are some exercises the student will do to improve her skills in
SQL.

INSTRUCTION:
Answer the entire questions below.

Activity 4A
Activity Outcome: Able to create Database, tables and manipulates tables using DDL
statements

Procedures:

Step 1 : Create new database name COMPANY.


CREATE DATABASE COMPANY;

Step 2 : Create tables VENDOR and PRODUCT.

Page 41 of 61
DFC 2083 DATABASE DESIGN

Step 3 : Click on SQL tab and type the SQL command(VENDOR table) as shown below.

CREATE TABLE VENDOR (


V_KOD INTEGER NOT NULL UNIQUE,
V_NAMA VARCHAR(35) NOT NULL,
V_POSKOD VARCHAR(5) NOT NULL,
V_TELEFON INTEGER NOT NULL,
PRIMARY KEY (V_KOD));
Step 4 : Run the SQL command.
Step 5 : Save the Query.
Step 6 : Click on SQL tab to create PRODUCT table.

CREATE TABLE PRODUCT (


P_KOD VARCHAR(7) NOT NULL,
P_ITEM VARCHAR(35) NOT NULL,
P_HANTAR INTEGER(3) NOT NULL,
P_HARGA DECIMAL(8,2) NOT NULL,
V_KOD INTEGER NOT NULL,
PRIMARY KEY (P_KOD),
FOREIGN KEY (V_KOD) REFERENCES
VENDOR(V_KOD));

Step 7 : Type SQL command to change the P_ITEM character length from 35 to 40.

ALTER TABLE PRODUCT


MODIFY P_ITEM VARCHAR(40);

Step 8 : Type SQL command to Add attribute V_AGE into table VENDOR.

ALTER TABLE VENDOR


ADD V_AGE INT(3);

Step 9 : Type SQL command to change the data type attribute V_AGE from INT to CHAR.
ALTER TABLE VENDOR
MODIFY V_AGE CHAR;

Step 10 : Type SQL command to Delete attribute V_AGE from table VENDOR.

ALTER TABLE VENDOR


DROP V_AGE;

Page 42 of 61
DFC 2083 DATABASE DESIGN

Step 11 : Type SQL command to delete VENDOR table.

SET FOREIGN_KEY_CHECKS = 0
DROP TABLE VENDOR;

Activity 4B
Activity Outcome: Able to manipulates tables using DDL statements
(Refer Activity 4A)

Procedures:

Step 1 : Click on SQL tab and type SQL command that insert new data into PRODUCT table .
INSERT INTO
PRODUCT(P_KOD,P_ITEM,P_HANTAR,P_HARGA,V_KOD) VALUES
('JT00833', 'Joystick', 6, 30.99, 25595);

Step 2 : Type the following SQL command to insert another data into PRODUCT table.
INSERT INTO PRODUCT
(P_KOD,P_ITEM,P_HANTAR,P_HARGA,V_KOD)
VALUES (‘KK0011’, ‘Scanner’, 12, 300.99, 21344);

Step 3 : Click on SQL tab.

Step 4 : Type SQL command to update a data in the PRODUCT table.


UPDATE PRODUCT
SET P_HARGA = 12
WHERE P_KOD = ‘JT00833’;

Step 5 : Click on SQL tab and type SQL command to delete a data in the PRODUCT table
using the following command.

DELETE FROM PRODUCT


WHERE P_KOD=’JT00833’;

Step 6 : Click on SQL tab and type SQL command to delete a data in the PRODUCT table
using the following command.

SELECT * FROM PRODUCT;

Page 43 of 61

You might also like