Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 71

DFC20123 – Database

Design
 
LECTURER : PN. NOOR HAFIZZAH | DEC 2020
Chapter 3 :
Entity-Relationship (E-R) Model &
Normalization
 
Synopsis
DATABASE DESIGN course engages students to analyze
business scenarios and create a data model - a conceptual
representation of an organization’s information. Students
implement their database design by creating a physical database
using SQL (Structured Query Language). Basic SQL syntax and
the rules for constructing valid SQL statements are reviewed.
This course culminates with a case study that challenges
students to design, implement, and demonstrate a database
solution for a business or organization.
COURSE LEARNING
OUTCOMES
CLO
 Upon completion of this course, students should be able to:
 CLO 1 : Apply fundamental of DBMS, relational data model
and normalization concepts in database development process.
( C3, PLO 2 )
 CLO 2 : Show a well-structured database using the database
query to manipulate a database with an appropriate
commercial Database Management System (DBMS) in solving
an organization’s requirements. ( P2, PLO 3 )
3.2 Apply E-R Diagrams (ERD) in database development

3.2.1 Define entity, attribute and d. Key attribute


relationship e. Multivalued attribute
3.2.2 Interpret relationship cardinality f. Derived attribute
a. One to one (1:1) g. Relationships
b. One to many (1:M) h. Cardinality
c. Many to many (M:N) 3.2.5 Identify the steps in creating E-R diagram
3.2.3 Relate entities by applying the rules 3.2.6 Construct ER diagram components that
of cardinality represent entities and attributes according to
3.2.4 Identify the E-R diagram notations diagramming conventions based on a given
for: scenario or problem statement
a. Entity 3.2.7 Transform an E-R diagram into physical
b. Weak entity database design
c. Attributes
Entity Relationship Diagram
(ERD)
An entity-relationship (ER) diagram is a
specialized graphic that illustrates the
interrelationships between entities in a
database.
Entity Relationship Diagram
(ERD)
 ER diagrams often use symbols to represent
three different types of information.
 Boxes/ Rectangle are commonly used to
represent entities.
 Diamonds are normally used to represent
relationships, and

Graphical Representation
Entity Relationship Model
 Traditional approach to Conceptual
Modeling
o Entity-Relationship Models (ER-Models)
 Also known as Entity-Relationship
Diagrams (ERD), ER Diagram, E-R
Diagram, entity-relationship model.
 Introduced in 1976 by Peter Chen
 Graphical representation
ER Modeling
ER Notations
o Chen notation - by
Peter Chen
o Crow’s Foot Notation
- developed by Gordon
Everest
Elements of ERD
Element Symbol Details for Entity Relationship
Diagram Symbols. Professional ERD
  Drawing :
Entity http://www.conceptdraw.com/How-To
-Guide/erd-entity-relationship-diagra
  m-symbols
Attribute
http://www.conceptdraw.com/diagram
/er-diagram-of-a-bank-business-scena
  rio
Relationship
 
A simple, example ERD
Define entity, attribute and relationship
Entity
o an entity is an object of interest to the end user.
o In both the Chen and Crow’s Foot notations, an
entity is represented by a rectangle containing the
entity’s name.
o The entity name, a noun, is usually written in all
capital letters.
An entity is an object that exists and which is distinguishable from
other objects. An entity can be a person, a place, an object, an event,
or a concept about which an organization wishes to maintain data.
The following are some examples of entities:
Person: STUDENT, EMPLOYEE, CLIENT
Object: COUCH, AIRPLANE, MACHINE
Place: CITY, NATIONAL PARK, ROOM, WAREHOUSE
Event: WAR, MARRIAGE, LEASE
Concept: PROJECT, ACCOUNT, COURSE
Attributes
Attributesare characteristics of entities.
Some attributes of common entity types include the following:
STUDENT = {Student ID, SSN, Name, Address, Phone, Email, DOB}
ORDER = {Order ID, Date of Order, Amount of Order}
ACCOUNT = {Account Number, Account Type, Date Opened, Balance}
CITY = {City Name, State, Population}
In the original Chen notation, attributes are represented by ovals and are
connected to the entity rectangle with a line. Each oval contains the name of
the attribute it represents.
In the Crow’s Foot notation, the attributes are written in the attribute box
below the entity rectangle.
Entities
An entity is represented by a rectangle which contains the entity’s name.
Attribute
Types of Attributes
Types of Attributes
Types of Attributes
Types of Attributes
Types of Attributes
Types of Attributes
Relationship
Relationship
Cardinality
Cardinality
Cardinality
Read the business scenario of a fast-food
restaurant below:
We are a small fast food business. Our menu features food items
that can be ordered by a customer. A customer places an order at
the counter and indicates what food items he/she would like on
that order.
Lately we’ve noticed that we have some regular customers, so we
started asking them for information – such as name and address,
so we can mail them coupons when we have specials.
a. Using the restaurant entities ORDER, FOOD ITEM and
CUSTOMER, identify the attributes for each entity.
b. Where possible, indicate whether the attribute is mandatory
Solution:
 This restaurant business scenario is an offshoot version of the progressive
project, Global Fast Foods, which students will be building throughout the
course. A definitive solution for this activity is not provided, but the solution
can be similar to the Global Fast Foods model. Some students may want an
entity called MENU, with food item as an attribute. Be careful with this one:
although MENU could be a valid entity, food item as an attribute would be
repeating: there would be many different food items on a menu. Therefore,
even with MENU as an entity, you would still need FOOD ITEM as another
entity. Attributes of menu could be name, hours served, etc.
 Ask students why they would choose to make an attribute mandatory or
optional. This makes them start thinking about business rules.
 UID for ORDER could be number, UID for FOOD ITEM could be name (or
Interpret relationship optionality
What is Optionality in a Relationship?
Relationships are either mandatory or optional. Consider the
two entities EMPLOYEE and JOB. Based on what you know
about instances of the entities, you can determine optionality by
answering two questions:
• Must every employee have a job? In other words, is this a mandatory
or optional relationship for an employee?
• Must every job be done by an employee? In other words, is this a
mandatory or optional relationship for a job?
Optionality and Cardinality
Examples:

Each EMPLOYEE must hold one and only one JOB


Each JOB may be held by one or more EMPLOYEEs

PRODUCT must
Each be classified by one and only one
PRODUCT TYPE
PRODUCT TYPE may
Each classify one or more
PRODUCTs
34
Relate (connect or join) entities by applying
the rules of cardinality and optionality.

Examples….
Business Scenario 1
Business Scenario 2
A relationshipcan join one entity to itself. Examine the
following scenario:
“We need to keep track of our employees
and their managers. Every employee has
one manager, including the managing
director who manages him/herself. Each
manager can manage several employees.”
Since managers are also employees, both are
listed in the same entity: EMPLOYEE.
RELATIONSHIP
1. An EMPLOYEE manages EMPLOYEEs
2. An EMPLOYEE is managed by one
EMPLOYEE
Interpret relationship cardinality
What is Cardinality in a Relationship?
 Cardinality measures the quantity of something. In a relationship,
it determines the degree to which one entity is related to another
by answering the question, “How many?”
 For example:
• How many jobs can one employee hold? One job only? Or more than one
job?
• How many employees can hold one specific job? One employee only? Or
more than one employee?
 Note: The cardinality of a relationship only answers whether the
Interpret relationship cardinality
What is Cardinality in a Relationship?
a) One to one ( 1:1 )
b) One to many ( 1:M )
c) Many to many ( M:N )
Cardinality.This specifies the number of each entity that is involved in the relationship.
There are 3 types of cardinality for binary and unary relationships:

1. One to one (1:1). For example, 1 man is married to 1 woman.

2. One to many (1:M). For example, 1 manager manages many employees, each
employee is managed by 1 manager.

3. Many to many (M:N). For example, Each students take many modules, each module
is taken by many students.

How many is many? It doesn't matter! If it's 0, 10 or 100, the way you implement the
relationship is the same.
Relate entities by applying the rules of cardinality and
optionality.
The Components
1. EACH
2. Entity A
3. OPTIONALITY (must be/may be)
4. RELATIONSHIP NAME
5. CARDINALITY (one and only one/one or more)
6. Entity B
 Since each relationship has two sides, first read
relationship from left to right (or top to bottom,
depending on the ERD layout).
read relationship from right to left

1.EACH
2.Entity A
3.OPTIONALITY (must be/may be)
4.RELATIONSHIP NAME
5.CARDINALITY (one and only one/one
or more)
6.Entity B
Now we read the second relationship
from right to left.
Now bring it together.
1.EACH
2.Entity A
3.OPTIONALITY (must be/may be)
4.RELATIONSHIP NAME
5.CARDINALITY (one and only
one/one or more)
6.Entity B
Test your knowledge

47
Try It / Solve It
1. The goal of this practice is to read a relationship. Which text corresponds to
the diagram?

a. Each EMPLOYEE may be assigned to one or more DEPARTMENTs.


Each DEPARTMENT must be responsible for one or more EMPLOYEEs.
b. Each EMPLOYEE must be assigned to one and only one DEPARTMENT.
Each DEPARTMENT must be responsible for one or more EMPLOYEEs.
c. Each EMPLOYEE must be assigned to exactly one DEPARTMENT.
Each DEPARTMENT may be responsible for exactly one EMPLOYEE.
Try It / Solve It
1. The goal of this practice is to read a relationship. Which text corresponds to
the diagram?

a. Each EMPLOYEE may be assigned to one or more DEPARTMENTs.


Each DEPARTMENT must be responsible for one or more EMPLOYEEs.
b. Each EMPLOYEE must be assigned to one and only one DEPARTMENT.
Each DEPARTMENT must be responsible for one or more EMPLOYEEs.
c. Each EMPLOYEE must be assigned to exactly one DEPARTMENT.
Each DEPARTMENT may be responsible for exactly one EMPLOYEE.
2. In the diagram for #1 identify the symbols for
cardinality.
3. In the diagram for #1 identify the symbols for
optionality.
4. Read the relationship in the diagram below.
Write the ERD statement for the relationship.
5. Read each relationship in
the model below. For each
relationship, write the ERD
statement and your
comments. Use your
knowledge of normal people
and towns in your
comments.
After looking at the diagram, choose the sentence below that could be
"read" from the existing relationship (even though you're missing
relationship labels!)

a. Each Student must have one or more Activities.


b. Each Student may participate in one or more Activities.
c. Each Activity may be performed by one or more Students.
d. Each Activity must belong to one and only one Student.
After looking at the diagram, choose the sentence below that could be
"read" from the existing relationship (even though you're missing
relationship labels!)

a. Each Student must have one or more Activities.


b. Each Student may participate in one or more Activities.
c. Each Activity may be performed by one or more Students.
d. Each Activity must belong to one and only one Student.
Identify the steps in E-R modelling.
1. Create a detailed narrative of the organization’s description of
operations.
2. Identify the business rules based on the description of operations.
3. Identify the main entities and relationships from the business rules.
4. Develop the initial ERD.
5. Identify the attributes and primary keys that adequately describe the
entities.
6. Revise and review the ERD.

eBook - E N T I T Y R E L A T I O N S H I P ( E R ) M O D E L I N
G pg.127
Steps to Develop ER Diagram:

1 :
EP Y 2 :
T
S NTI F E P Y A W
E T Y ST NTIF HIP: DR
ID TI E NS 3
R D
EN ID TIOTEP E E
L A S TH
RE
STEP 1 : IDENTIFY ENTITY
Example - Entities
A university consists of a number of departments.
Each department offers several courses. A number
of modules make up each course. Students enrol in
a particular course and take modules towards the
completion of that course. Each module is taught
by a lecturer from the appropriate department, and
each lecturer tutors a group of students.
STEP 2 : IDENTIFY
RELATIONSHIP Example - Relationships
A university consists of a number of departments.
Each department offers several courses. A number
of modules make up each course. Students enrol in
a particular course and take modules towards the
completion of that course. Each module is taught
by a lecturer from the appropriate department, and
each lecturer tutors a group of students.
STEP 3 : DRAW THE ERD
Example - ER Diagram
Entities:Department, Course, Module,
Lecturer, Student
Relationship: Each department offers several courses
Relationship: A number of modules make up
each courses
Relationship: Students enrol in a
particular course

[*ignore the symbols used]


Students enrol in a particular course and
take modules

[*ignore the symbols used]


Each module is taught by a lecturer

[*ignore the symbols used]


A lecturer from the appropriate department

[*ignore the symbols used]


Each lecturer tutors a group of
students

[*ignore the symbols used]


The result

[*ignore the symbols used]


Redraw the ER Diagram using the correct symbol on
Chen Notation
m p l
Exa Business Explanation
e
Koperasi PSP situated in Permatang Pauh, Pulau Pinang.

It has a members of staff that manage the operation of the
Koperasi PSP like update orders. The function of the
Koperasi PSP is to receive list of order that is placed by
customer who want to make a corporate shirts or t-shirts.
All the product are supply by the supplier appointed by PSP
management.
All the details of customer will be kept in the system.
Business Rules
1. Each CUSTOMER must place one or more ORDERs.
Each ORDER must be placed by one and only one
CUSTOMER.
2. Each ORDER must have one or many PRODUCT.
Each PRODUCT may be placed by one or more ORDERs.
3. Each SUPPLIER must supply one or many PRODUCT.
Each PRODUCT must be placed by one and only one
SUPPLIER.
4. Each STAFF must update one or many ORDERs.
Each ORDER must be updated by one and only one STAFF.
Entity Relationship Diagram (ERD)
Chen Notation

1 1

M M
1 M M N
71

You might also like