Chapter 3
Chapter 3
Chapter 3
DATABASE DESIGN
CHAPTER 3
ENTITY RELATIONSHIP MODEL (ER)
MODEL & NORMALIZATION
3.1 Apply the normalization concept
3.2 Apply ER diagrams in database development
Course Learning Outcome (CLO)
Apply fundamental of DBMS, relational data model and normalization concepts
in database development process.
The goal of normal forms is to allow you to take a table or collection of tables and produce
a new collection of tables that represents the same information but is free of problems.
Enables you to identify the existence of potential problems called anomalies, in the design of
a relational database.
Normalization reduces data dependency and helps to eliminate the anomalies that result from
those redundancies.
Does not eliminate data redundancies, instead it produces controlled redundancy, which is
needed to link the tables in a database.
NORMALIZATION
ANOMALIES
FUNCTIONAL
DEPENDENCY
PARTIAL
DEPENDENCY
TRANSITIVE
DEPENDENCY
RIDDLES
Which word in the dictionary is
spelled incorrectly?
Feed me and I live, yet give me
a drink and I die.
Take off my skin - I won't cry,
but you will! What am I?
NORMALIZATION PROCESS
• The existence of a
weak entity depends
WEAK on the existence of
strong entity.
ENTITY • Symbol = double
rectangle
EXAMPLE OF STRONG & WEAK ENTITY
Identifying relationship
http://techdifferences.com/difference-between-strong-and-weak-entity.html
TYPE OF ATTRIBUTE
SIMPLE Simple Attribute has only one component, exist independently and
cannot be broken up. Example: IC number, student ID
matricno
[ simple attribute]
studentname [ single attribute]
gender
houseno
STUDENT dateofbirth
road
[ composite attribute ]
address
garden
phoneno
postcode
specialty [ multi-valued
attribute]
age [ derived attribute]
Exercise: Identify entity and attribute.
◎ Customer
◎ Height
◎ Product
◎ Tomato
◎ Temperature
◎ manufactured part
◎ Account type
Exercise: Draw entity and attribute for the following
descriptions.
Recursive/Unary Relationship is a
relationship involving only one entity .
Binary
Ternary
Binary
Ternary
74
COMPOSITE ENTITY
a) M N
DOCTOR treat PATIENT
M 1
DOCTOR 1 M
give TREATMENT involve PATIENT
75
76
Copyright © ODL Jan 2005 Open University Malaysia
77
Guideline and Steps In Construction An E-R Model
rent
The correct model
78
Guideline and Steps In Construction An E-R Model
◎ There are entities with two different keys (not composite key).
◎ EG: In the University Library, BORROWER may refer to student or staff. The key for BORROWER entity is metric
number or staff number. If the BORROWER is a student the key is his/her metric number and the staff number
will be left blank (null value).
The correct model
Metric_no Staff_no
STUDENT Name Name STAFF
79
Guideline and Steps In Construction An E-R Model
Metric_no
a) name
STUDENT
college
An entity must contain description. As such, an object with only one characteristic is
referred to as attribute and not entity.
b)
STUDENT stay RES._COLLEGE
Metric_no Colege_name
name College_address
b) M N
DOCTOR has SPECIALTY
Staff_no spec,._code
name description
Eg: if a DOCTOR has more than one specialty, SPECIALITY need to be made an
entity.
81
Guideline and Steps In Construction An E-R Model
register
STUDENT COURSE
drop
Eg. STUDENT can register for a COURSE and STUDENT can also
drop a COURSE
82
TOP-DOWN METHODOLOGY
85
Abstraction Of The Relationship Scheme From the
Logical Data Model
• The process of abstracting the relationship scheme
requires several considerations as follows:
a. Strong Entity
b. Weak Entity
c. 1:M Relationship
d. 1:1 Relationship
86
Abstraction Of The Relationship Scheme
From the Logical Data Model
a) Strong Entity
• For each common entity (strong), you need construct a
relationship by inserting all the simple attributes of the
common entity into the relationship.
• In the case of composite attribute, you merely need to insert
simple attributes which form the composite attribute
mentioned.
87
a) Strong Entity
• Example, a Student relationship is produced and each attribute
of the Student entity will become a field for Student
relationship. The primary key of Student entity will become the
primary key of Student relationship.
name
no Student StudentNo
road address
DateOfBirth
city
postcode Student (StudentNo, name,DateOfBirth,
state
no, road, city, postcode, State)
88
b) Weak Entity
• For each weak entity, you need to produce a
relationship and insert all the simple attributes( or
simple attributes of the composite attribute) into the
relationship.
• Apart from that, an attribute representing the foreign
key is produced.
• This attribute is a copy of the primary key for the
common entity which is related to this weak entity.
89
b) Weak Entity
LiabilityNo
Name
DateOfBirth
WorkerNo
1 M
Name Worker has Liability
Address
DateOfBirth
90
c) 1:M Relationship
• For each 1:M relationship between entity E1 and Entity
E2, a copy of the primary key entity E1(parent) will be
placed in entity E2 (child) to represent a foreign key.
In this case, we represent the entity placed in
“position 1” as “parent” entity, whereas the entity
place in “many positions(M)” represent the child
entity.
91
d) 1:1 Relationship
• For each 1:1 binary relationship between Entity E1 and E2 in the
logical data model, a copy of a primary key for entity E1(parent)
will be placed in entity E2 (child) to represent the foreign key.
• The determination for parent entity and child entity depends on
the relationship participation between the entities involved.
• The entity with optional relationship participation is categorized as
the parent entity, and the entity with mandatory relationship
participation is categorized as child entity.
92
d) 1:1 Relationship
• As an example, consider the 1:1 relationship for Worker Manage
Department below, the Worker has optional participation in this
relationship. This mean not every Worker manage the Department,
whereas the Department has mandatory participation in the
relationship Manage :-
WorkerNo
DepartmentCode WorkerName
DepartmentName DateOfBirth
1 1
Department Manage Worker
93
d) 1:1 Relationship
• Whereas the Department has mandatory participation in the
relationship Manage. Department must be managed by Worker.
Because of this, the primary key attribute of the Worker entity is
copied into the Department entity as foreign key.
• However, if the involvement of both entities in the 1:1
relationship is optional or mandatory, the determination of parent
entity is the most frequently accessed or queried by users.
94
Write relationship schema for this ER diagram.
Exercise: Develop a logical ER diagram for this scenario and write
relationship schema from the new ER diagram.
The local city youth league needs a database system to help track children who sign
up to play soccer. Data needs to be kept on each team, the children who will play on
each team, and their parents. Also, data needs to be kept on the coaches for each
team.