You are on page 1of 22

ELECTRICAL ENGINEERING DEPARTMENT

ACADEMIC SESSION: _____________


DEC40073- DATABASE SYSTEM

PRACTICAL WORK: 2

TITLE: Entity Relationship Model (ERD)

PRACTICAL WORK
DATE:
LECTURER’S NAME: PUAN AZLIN BINTI YAJID
(DK4, DK6, DP5, CLO2, C3, P4)
DANIEL ISKANDAR BIN
MOHD SHUKRI
13DTK21F1070
PRACTICAL SKILL ASSESSMENT RUBRIC (PLO5/ CLO2)

PRACTICAL WORK 2: ENTITY RELATIONSHIP DIAGRAM (ERD)


PRACTICAL WORK ASSESSMENT RUBRIC

Practical Very Poor 1 Poor Moderate 3 Good Excellent


Assessment 0 2 4 5
Student can identify some Student can identify most Student can identify entities Student can identify all
Student cannot identify all entities with the assistance of entities with the assistance of with little assistance of entities without assistance of
i. Identify entity
entities without assistance. lecturer / friends. lecturer / friends. lecturer / friends. lecturer / friends.

Student can identify some Student can identify most Student can identify attributes Student can identify all
Student cannot identify all attributes with the assistance attributes with the assistance with little assistance of lecturer attributes without assistance
ii. Identify attribute
attributes without assistance. of lecturer / friends. of lecturer / friends. / friends. of lecturer / friends.

Student can identify some Student can identify most Student can identify Primary Student can identify all
iii. Identify Primary Student cannot identify all Primary and/or Foreign Keys Primary and/or Foreign Keys and/or Foreign Keys with little Primary and/or Foreign Keys
and/or Foreign Primary and/or Foreign Keys with the assistance of lecturer with the assistance of lecturer assistance of lecturer / without assistance of lecturer
Keys without assistance. / friends. / friends. friends. / friends.

Unable to Student can identify some Student can identify most Student can identify Student can identify all
iv. Identify complete Student cannot identify all relationship and cardinality relationship and cardinality relationship and cardinality relationship and cardinality
relationship the task relationship and cardinality with the assistance of lecturer with the assistance of lecturer with little assistance of without assistance of lecturer
and cardinality given without assistance. / friends. / friends. lecturer / friends. / friends.
and not
submitting Student build incomplete their Student can build their own Student can build their own Student can build a complete
report Student unable to build their own ERD with a lot of incomplete ERD with a little complete ERD with little ERD correctly.
v. Create ERD
own ERD. mistake or missing elements. mistake or missing elements. mistake or missing elements.

Unable to complete the task Unable to complete all the Managed to complete only Managed to complete most Managed to complete all task
vi. Time given and late report task given with an adequate several task within the task within the stipulated time. given within the stipulated
management submission/ lack interaction participation. Show some stipulated time. Great class Great class involvement time. Excellent teamwork &
and group with group members. No effort to learn. involvement great involvement in every
involvement teamwork. activity

Lack awareness of safety & Show some awareness of Show some awareness of Show awareness of safety & Show excellent awareness of
health; very poor safety & health; poor safety & health; moderate health; good self-discipline safety & health; very high
vii. Self-discipline selfdiscipline value and could selfdiscipline value or self-discipline value or value and managed to follow self-discipline value and
and awareness not follow any instructions managed to follow only some managed to follow only some every instruction managed to follow every
instructions instructions instruction
LAB REPORT ASSESSMENT
Results Students do Based on correct answer
not submit
Question their Based on correct answer
practical
Conclusion work report Plagiarism Not able to conclude the Able to conclude the practical Able to conclude the practical Able to conclude the practical
practical work work but in general. work but not clear work
LEARNING OUTCOMES (LO):
1.
CLO2: Manipulate correctly Structured Query Language (SQL) for database using
a database management system during practical works.

OBJECTIVES
2.
By the end of this practical, students should be able to:
1. Model relationships for Entity Relationship Diagram in MySQL Database.
2. Understand the concept of Primary Key and Foreign Key

THEORY
3.
Entity Relationship Diagram, also known as ERD, ER Diagram or ER model, is a
type of structural diagram for use in database design. An ERD contains different
symbols and connectors that visualize two important information: The major entities
within the system scope, and the inter-relationships among these entities. Three types
of relationships in ERD are One-One Relationship (1-1), One-Many Relationship (1M)
and Many-Many Relationship (M-N).

EQUIPMENT / TOOLS
4.
1. Computer with Internet Connection
2. Database modeling tool – ERDPlus

2|Page
PROCEDURE
5.
Based on the case study below:
A student can borrow one or more books. A book has a supplier and a supplier can
supply many books.The information of students are matric no, student name, class,
semester and phone no.The important data of book are serial no, book title and year
of published. Supplier have id supplier, address and phone no.

Activity 2a: Information extraction from the case studies

Step 1: Identify the entities


1. BOOK.
2. SUPPLIER.
3. STUDENT.

3|Page
Step 2: Identify the attributes for each entity.
Entity Attributes Primary Key Foreign Key
(if any)
BOOK serial no, book title and year of Serial no.
published
SUPPLIER id supplier, address and phone Id supplier.
no.
STUDENT matric no, student name, class, Matric no.
semester and phone no.

Step 3 : Define the relationships and cardinality


RELATIONSHIP CARDINALITY

SUPPLY
____________

BORROW

Activity 2b: Construct Entity Relationship Diagram (ERD)

1. Sign up an account in ERDPlus.

2. Login into ERDPlus.

3. Click “New Diagram” tab and name your diagram with “PRACTICAL WORK
2_YOURNAME”.

4. Click your diagram file from listing files and you now are ready to draw your
ERD.

4|Page
5|Page
5. To create an Entity, click the “Entity” button. Then place your cursor in the
empty workspace and click your mouse. Rename the Entity name based on
your Activity 1a and set its type.

3
2

6. To create an attribute for the entity, click “Attribute” button. Rename the
attribute based on your Activity 1a and set its type.

3
2

7. The other way to create other attribute(s), click “Add Attribute to Entity”.
Rename the attribute on “Attribute Name” and set its type.

6|Page
7|Page
8. To create a relationship between entities, Click “Relationship” button. Place the
cursor on the workspace and click your mouse. Then rename the relationship
based on Activity 1a on “Relationship Name”. Select Entity One and Entity Two
that will be connected by the relationship created and also relationship type
performed by each entity.

1 3

2 5

9. Create all entities, attributes, and relationship in Activity 1a by repeating step 5


until 8.

10. Click “Label” button and click on the workspace below your ERD. Then type
your name and registration number on “Test Label”.

8|Page
9|Page
11. Click the “Menu” button and select “Export Image” to export the image of ERD.
Tick “Transparent Background” and Save your file.

Activity 2c: Convert ER Diagrams to Relational Schemas

1. On the top of ERD Plus page, click “Documents” and this will bring you back to
the main page.

2. Select your ERD Diagram files and click the triple dot on the right.

3. Choose “Convert to Relational Scheme” and rename the file. Then click
“Create”.

10 | P a g e
11 | P a g e
4. Click your “Relational Scheme” files and the following diagram will be displayed.

Example Relational Scheme Diagram

5. Click the “Menu” button and select “Export Image” to export the image of
Relational Scheme. Tick “Transparent Background” and Save your file.

Activity 2d: Export SQL from Relational Schemas

1. On the top of ERD Plus page, click “Documents” and this will bring you back to
the main page.

2. Select your Relational Scheme files and click the triple dot on the right.

3. Choose “Generate SQL” and click “Copy”.

Example of generated SQL

12 | P a g e
RESULT
6.
Make a screenshot for every executed task and clearly label each output.

Activity 2a: Information extraction from the case studies

Activity 2b: Construct Entity Relationship Diagram (ERD)

Activity 2c: Convert ER Diagrams to Relational Schemas

13 | P a g e
Activity 2d: Export SQL from Relational Schemas
CREATE TABLE SUPPLIER

(
address INT NOT NULL,
phone_no INT NOT NULL,
id_supplier INT NOT NULL,
PRIMARY KEY (id_supplier)
);

CREATE TABLE BOOK


(
serial_no INT NOT NULL,
book_title INT NOT NULL,
year_of_published INT NOT NULL,
id_supplier INT NOT NULL,
PRIMARY KEY (serial_no),
FOREIGN KEY (id_supplier) REFERENCES SUPPLIER(id_supplier)
);

CREATE TABLE STUDENT


(
matric_no INT NOT NULL,
student_name INT NOT NULL,
class INT NOT NULL,
semester INT NOT NULL,
phone_no INT NOT NULL,
serial_no INT NOT NULL,
PRIMARY KEY (matric_no),
FOREIGN KEY (serial_no) REFERENCES BOOK(serial_no)
);

14 | P a g e
(10 marks)

DISCUSSION
7.
A database organization needs to record all the information about the employee. Each employee
can be identical by their id numbers, name, address, and the organization also have to monitor
salary information and telephone number for each employee. Each employee will work under one
department which will be identical through unique department id, department name and budget for
each department. Each employee can work under one department only while each department can
have maximum 100 employees. Each department is entitled to handle several projects. Projects
are identified by unique project number, project title and budget for each project. Employee who
has children, children’s name and age must be put in the system. It is for insurances policy for the
organization.

15 | P a g e
a) Construct an ERD for the situation above by using ERDPlus.

b) Convert ER Diagrams to Relational Schemas.

c) Export SQL from Relational Schemas.


CREATE TABLE EMPLOYEE
(
NAME VARCHAR(70) NOT NULL,
ID INT NOT NULL,
GENDER VARCHAR(45) NOT NULL,
SSN VARCHAR(35) NOT NULL,
SALARY VARCHAR(100) NOT NULL,
BDATE INT NOT NULL,
ADRESS VARCHAR(20) NOT NULL
);

CREATE TABLE DEPENDENT


(
D_NAME VARCHAR(15) NOT NULL,

16 | P a g e
D_GENDER VARCHAR(35) NOT NULL,
D_RELATIONSHIP VARCHAR(21) NOT NULL
);

CREATE TABLE DEPARTMENT


(
DPART_NO INT NOT NULL,
DPART_NAME VARCHAR(37) NOT NULL,
LOCATION VARCHAR(24) NOT NULL
);

CREATE TABLE PROJECT


(
P_NAME VARCHAR(67) NOT NULL,
P_LOCATION VARCHAR(55) NOT NULL,
P_NO INT NOT NULL
);

(15 marks)

CONCLUSION
8.

In conclusion, I can understand how to create this database by using ERDplus and
creating a structural diagram. I can also carefully create a structure diagram,
Model relationships for Entity Relationship Diagram in MySQL Database. I also
understand Understand the concept of Primary Key and Foreign Key.
(5 marks)

PREPARED BY: APPROVED BY:


Course Lecturer Course Coordinator / Head of Programme

17 | P a g e
10 | P a g e

You might also like