Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Entity Relationship
(ER) Modeling
2
The Entity Relationship (ER) Model
What is ER Model ?
Represents the conceptual database as viewed by the end
user
3
HeadDe Club
MemberOf
pt
MemberOf
Lead
Require
The Entity Relationship (ER) Model
Main components:
Entities
Attributes
Relationships
5
Entities
6
Example of entities
Studen
t
Entity Set symbol in E-R diagram
What should be an
ENTITY?
SHOULD BE:
An object that will have many instances in the
database
An object that will be composed of multiple attributes
An object that we are trying to model
SHOULD NOT BE:
A user of the database system
An output of the database system (e.g., a report)
Example of inappropriate
entities
System System
user output
Appropriate
entities
Entity Type
Strong Entity Type
Entity type that is not existence-dependent on some other
entity type
Referred as parent, owner, or dominant entities
has its own unique identifier
identifier underlined with single-line
10
Weak Entities
11
Relationship Strength
Weak (non-identifying) relationship
12
Figure 4.8 - A Weak (Non-Identifying)
Relationship between COURSE and
CLASS
13
Figure 4.9 - A Strong (Identifying)
Relationship between COURSE and
CLASS
14
Weak Entity
Example:
A company insurance policy insures an employee
and his/her dependents
EMPLOYEE might or might not have a dependent,
but the DEPENDENT must be associated with an
EMPLOYEE
the DEPENDENT cannot exist without the
EMPLOYEE; a person cannot get insurance
coverage as a dependent unless s(he) happens to
be a dependent of an employee
EMPLOYEE has DEPENDENT
Weak Entity type in ERD
The Entity Relationship (ER) Model
Main components:
Entities
Attributes
Relationships
17
Attributes
Characteristics of entities
Property of an entity or a relationship type
Chen notation: attributes represented by ovals
connected to entity rectangle with a line
Each oval contains the name of attribute it
represents
Crows Foot notation: attributes written in attribute
box below entity rectangle
18
Attributes
Attributes
Student
PK Stu_ID
Stu_name
Stu_birthdate
Stu_address
Stu_department
Stu_telephone_num
Stu_age
21
Attributes
Student
PK Stu_ID Required
Stu_name Attribute
Stu_birthdate
Stu_address
Stu_department
Stu_telephone_num
Stu_age
Optional
Attribute
The Attributes in E-R Model
Attributes
Composite identifier
24
Attributes
26
27
The Entity Relationship (ER) Model
Main components:
Entities
Attributes
Relationships
28
Relationships
Association between entities
Participants :: entities that participate in a
relationship
Relationships between entities always operate in
both directions
Relationship name: active or passive verb (takes,
teaches, employs, is managed by, is flown by)
Relationship classification is difficult to establish if
only one side of the relationship is known
29
Relationships
ERdiagramofStudentHasDepartmentrelationship
30
Relationship Degree
Indicates number of entities or participants associated with
a relationship
Unary relationship / recursive relationship
Association is maintained within single entity
Binary relationship
Two entities are associated
Ternary relationship
Three entities are associated
Quaternary relationship
31
Four entities are associated
Relationship degree
Relationship
constraints
Connectivity: Describes the relationship
classification
Cardinality: Expresses the minimum and maximum
number of entity occurrences associated with one
occurrence of related entity
Established by very concise statements known as
business rules
33
Relationship constraints
MultiplicityofStaffManagesBranch(1:1)relationship
36
SemanticnetofStaffOverseesPropertyForRentrelationshiptype
MultiplicityofStaffOverseesPropertyForRent(1:M)relationshiptype
37
SemanticnetofNewspaperAdvertisesPropertyForRentrelationshiptype
MultiplicityofNewspaperAdvertisesPropertyForRent(M:N)relationship
38
Relationship Participation
Optional participation
One entity occurrence does not require
corresponding entity occurrence in particular
relationship
Mandatory participation
One entity occurrence requires corresponding
entity occurrence in particular relationship
39
Relationship Participation
Minimum
Cardinality
If zero, then
optional
If one or more,
then
mandatory
Descriptive Attributes
41
TheM*NrelationshipbetweenStudentandClass
TheCompositeentityinanERD
Chapter 3:
Business
Rules
Distinctnon-redundant
Business-orientedunderstood by business people
Business Rules (3)
Example of business rules:
A customer may generate many invoices
An invoice is generated by only one
customer
A training session cannot be scheduled for
fewer than 10 employees or more than 30
employees
Business Rules (5)
Teac
Lecture h Course
r
50
Example:
University of
Engineering &
Technology
Example: UET
Business Rule 1:
Member
Lead
Of
Departme Hire Lecturer Declare Property
nt (1..1) (0..N)
(1..
1)
Has Teach
(0..
Student 3)Course
Registe Become
(0..N)r (2..5 Prerequisite
)
Require
Summary
58
Summary (continued)
59