You are on page 1of 4

COMSATS Institute of Information Technology,

Department of Computing

CSC271: Database Systems

Lab 02: Entity-Relational Model and Diagram

Instructor: Dr. Khalid Latif

CSC271: Database Systems Page 1




Introduction
The goal of relational database design is to generate a set of relational schemas that allows us to store
information without unnecessary redundancy, yet also allows us to retrieve information easily.

Objectives
After performing this lab students should be able to:

1. Identify relations and associations given a case study or scenario.


2. Design and develop an E-R model using E-R Diagram notations.

Tools/Software Requirement
MySQL Community Server 5.6
MySQL Workbench 6.1

Description

1. This lab assumes that MySQL Community Server is running and MySQL Workbench is
loaded.
2. From the bottom of the main Workbench screen, select the plus sign near Models to
create a new E-R diagram.

3. Select (double click) the Add Diagram option. A new tab for the ERD would open.

4. You may click the entity (table) icon from the tool bar and then click an
appropriate portion of the diagram to create a new entity in the model.

CSC271: Database Systems Page 2




5. Double click the newly created table placeholder in the diagram to open
its properties in the bottom of the screen. There you can modify name of the relation and
may also add attributes and their constraints such as PK for primary key, NN for setting
not null, and AI for auto increment.

6. From the menu, go to Model > Model Options and select Show Caption in the options
for diagram to enable relationship labels.
7. Before modeling an association between two relations, make sure that the target relations
have primary keys. Later, click (DONT DRAG) the relevant association icon from the
toolbar and select first (where foreign key should be added) and then the second relation
(referring to the primary key). In case of many-to-many associate, a new relation would
be created that you may modify.
8. MySQL Workbench doesnt allow to model a single many-to-many association directly
as it creates an associative entity instead, and creates two one-to-many associations.

Lab Task
1. Draw an ERD for the following situation using MySQL Workbench.
a) Deewan Engineering is an auto-parts manufacturing firm with approximately 500
employees. A database is required to keep track of all employees, their skills,
projects assigned, and departments worked in. Every employee has a unique
number assigned by the firm and is required to store his or her name and date of
birth. If an employee is currently married to another employee of Deewan, the
date of marriage and who is married to whom must be stored; however, no record
of marriage is required if an employees spouse is not also an employee. Each
employee is given a job title (e.g., engineer, secretary, and so on). An employee
does only one type of job at any given time, and we only need to retain
information for an employees current job.
b) There are 11 different departments, each with a unique name. An employee can
report to only one department. Each department has a phone number.
c) To procure various kinds of equipment, each department deals with many
vendors. A vendor typically supplies equipment to many departments. We are
required to store the name and address of each vendor and the date of the last
meeting between a department and a vendor.

CSC271: Database Systems Page 3




d) Many employees can work on a project. An employee can work on many projects
(e.g., Atlas Honda, Indus Motors, and so on) but can only be assigned to at most
one project in a given city. For each city, we are interested in its name and
population. An employee can have many skills (preparing material requisitions,
checking drawings, and so on), but she or he may use only a given set of skills on
a particular project. (For example, an employee Mumtaz may prepare requisitions
for the newly acquired Indus Motors project and prepare requisitions as well as
check drawings for manufacturing bumpers of new City for Atlas Honda.)
Employees use each skill that they possess in at least one project. Each skill is
assigned a number, and we must store a short description of each skill. Projects
are distinguished through project numbers. Also note that the estimated cost of
each project should be stored in the database.
2. Generate the database schema from the diagram.

Deliverable
Submit the MWB file while designing the ER-D of the model using MySQL Workbench.

CSC271: Database Systems Page 4

You might also like