Lab 02
Lab 02
I. Objectives
This lab manual introduces a tool you can use to draw the Entity Relationship (ER) diagram. There are
many modeling tools that can be used to draw ER diagrams but we will learn how to draw ER diagrams
using draw.io, which can be accessed online for free. At the end of the session, you should be able to:
• Add entities and attributes
• Add key constraints (primary key and foreign key)
• Work with relationships (name describing the relationship, cardinality and connectivity)
• Create your ER diagram to fit into one page and working space
II. Introduction
In this session, you will be guided on how you can use Diagrams.net to draw ER diagrams. Before we
start, consider the following case as Example 1:
The School of Computer Sciences (CS) of ABC University needs your help to develop a new
student course registration database system. The school offers many courses for its Bachelors
of Computer Science program. Each course has a unique code and course title. Each student
enrolled in the Bachelors of Computer Science program is required to register and complete a
set of fixed core courses and non-core courses (i.e., course category). Students work on
courses and are awarded a grade in any course if they pass the course. The system needs to
record the year and semester in which the course is taken and the grade awarded to the student.
Every student has a unique ID. the system also stores the student’s name, birth date, country
of origin, email, mobile phone number and the year he/she starts the Bachelors program.
Using COURSE, STUDENT_COURSE, and STUDENT, we will create a Crow’s Foot ERD using
Diagrams.net as shown in Figure 1.
d. Next, select “Create New Diagram” and choose Entity Relationship Diagram as shown in Figure
3. Then click on the blue “Create” button.
e. The website will prompt you to select a location on your PC to save the XML file. Save the file
to any folder of your choice.
f. An ER diagram template will be displayed as shown in Figure 4. For this lab exercise, please
highlight and delete everything to start from scratch.
d. Next, double click each attribute box and enter the following attributes: “COURSE_CODE” as
the primary key, “COURSE_TITLE” and “COURSE_CATEGORY”.
e. Select the third item and press DELETE.
f. You may add a new attribute row by dragging the “Row” icon onto the table as shown in
Figure 8. Alternatively, you can also right click on a particular attribute and select “Duplicate”.
g. Repeat steps (a) to (g) to the entity “STUDENT” with corresponding attributes as illustrated in
Figure 9.
i. Fill up the corresponding attributes to obtain the three final tables as illustrated in Table 11.
j. You may edit the boxes to the left of the attribute to indicate if the attribute is a primary key
(PK) or foreign key (FK).
b. Adjust both ends by dragging one end to the COURSE entity and another end to the
STUDENT_COURSE entity. The relationship line will then connect the two entities together. You
can connect the primary key from the COURSE entity to the corresponding primary key/foreign
key in the STUDENT_COURSE entity.
c. Select the relationship line. On the right side, you may change the start and end symbols if need
be.
Figure 15: Set the cardinality symbols at both ends of the relationship type
Thus, the overall ER diagram depicts the many-to-many relationship between STUDENT and
COURSES, whereby “A student can register many courses.” and “Each course can be registered by
many students.”.
You are done! You can use Diagrams.net to draw ER diagrams for your group project. Hand-drawn
ERDs are not accepted.
As SecondStreet’s systems analyst, you are hired to create a database design that will improve the
record-keeping of SecondStreet’s business data specific to their new chain store. You decide to build
a logical database model using an ERD from the following business rules and data that you have
collected from interviews. Your plan is to use your ERD as a communication tool to show the
SecondStreet management team the data you plan to include in their new database.
Business Rules
1. An employee can be assigned only one position. A position can be assigned to many
employees.
2. A customer can be serviced by one employee. An employee can service zero or many
customers.
3. An employee can process many orders. An order can be processed by one employee.
4. A customer can place many orders. An order is can be placed by only one customer.
5. An order can list many products. A product can be listed in an order only once.
6. A product can be on many orders.
7. A product can be supplied by many vendors. A vendor can supply many products.
Data
Employee: employee ID, name, IC number, address, mobile phone number, basic salary, hire date
Customer: customer ID, name, address, mobile phone number, membership date, status
Order: order ID, order date, payment type, order total amount (sum of all the total product amounts
for a given order), order status
OrderProduct: order ID, line number, product ID, quantity, product unit price, total product amount
(quantity multiplied by unit price), back order status
Product: product ID, product name, product type, quantity on hand, product unit cost, product unit
price, inventory value (quantity on hand multiplied by product unit cost)
VendorProduct: vendor product id, vendor ID, product ID, quantity supplied
Instructions
Create your ERD Data Model in Crow’s Foot Notation using Diagrams.net. Include also the
cardinalities (e.g., (1,1), (1,M) or (0,M)) beside the entities in the diagram. You will need to
figure out how to add cardinalities to your ERD in Diagrams.net.
Page | 8 CMT221/CMM222: Database Organization and Design (LAB 02)
LSY, TJS
Note: To map one-to-many (1:M) relationships, the primary key on the “one side” of the
relationship is added to the “many side” as a foreign key.
Save all your ER diagrams in PDF format and submit in the Lab 02 assignment dropbox on
elearn@USM at the end of your lab session. Lab report submission will count towards your coursework
grade.