Course 6: Entity Relationship Diagrams: 1. Basic Elements and Rules
Course 6: Entity Relationship Diagrams: 1. Basic Elements and Rules
Course 6: Entity Relationship Diagrams: 1. Basic Elements and Rules
Universe
of Discourse
Description of requirements of users
data modelling, process modelling
Data modelling is expressed using a
REQUIREMENTS
high level model such as ENTITY-
COLLECTION
RELATIONSHIP (ER)
AND ANALYSIS The ER Model can be represented
pictorially (ER diagrams)
ER Model contains detailed
FUNCTIONAL
ANALYSIS
descriptions of:
What are the entities and
relationships in the enterprise?
APPLICATION
PROGRAM
What information about these
DESIGN
entities and relationships should we
store in the database?
What are the integrity constraints or
business rules that hold?
Data modelling vs Process
modelling
Process modelling (i.e. DFD) shows
data stores, how, where, n when data
r used or changed in an IS
Data modelling (i.e ER) shows
d’definition, structure, n relationship
within d’data
Y data model is d’most important part
of the statement of SW requirement?
Characteristics of data captured during data
modelling r crucial in d’design of DB, program,
computer screen, n reports
Data rather than processes r d’most complex
aspects of many modern IS so require a central
role in structuring system requirement
D’characteristics of data (length, format,
relationship) r reasonably permanen. D’paths
of data flow r quite dynamic
Structural information about data is essensial
for automatic generation of programs
Conceptual Data Modeling and
the E-R Diagram
Goal
Capture as much of the meaning of the data as
possible
If you know the rules of normalization,
10.6
10.6
Entity-Relationship (E-R) Modeling
Key Terms
Entity
A person, place, object, event or concept in the
user environment about which the organization
wishes to maintain data
Represented by a rectangle in E-R diagrams
Entity Type
A collection of entities that share common
properties or characteristics
Attribute
A named property or characteristic of an entity
that is of interest to an organization
10.7
10.7
Entity-Relationship (E-R) Modeling
Key Terms
Identifier
A candidate key that has been selected as the
unique identifying characteristic for an entity
type
Selection rules for an identifier
1. Choose a candidate key that will not change its
value
2. Choose a candidate key that will never be null
RELATIONSHIP TYPE
IDENTIFYING
RELATIONSHIP TYPE
… Notation Guide
ATTRIBUTE
MULTIVALUED
ATTRIBUTE
DERIVED ATTRIBUTE
1 N
CARDINALITY RATIO 1:N FOR
E1 R E2 E1:E2 IN R
STRUCTURAL CONSTRAINT
(min,max)
(min, max) ON PARTICIPATION
R E2 OF E IN R (Alternative
Notation)
… Notation Guide
E1 E2 E1 IS A SUBCLASS OF E2
E1 and E2 ARE
E1 SUBCLASSES OF E3
E3
E2
Overlapping specialization
o
Disjoint specialization
d
ER Diagram Basics
Entity
sname
Store Locations
Relationship
manager
qty Keeps
Attributes
pname
Product price
descrip
Entity
Real-world object distinguishable from other objects
(e.g a student, car, job, subject, building ...)
An entity is described using a set of attributes
EMPLOYEES
Notation
Key Attributes
Value Sets of Attributes
Null Valued Attributes
Attribute Types
– Composite Vs. Simple Attributes
– Single-valued Vs. Multi-valued Attributes
– Derived Vs. Stored Attributes
Key Attributes: Identifier
Key (or uniqueness)
constraints are applied to
entity types
Key attribute’s values are
distinct for each individual
entity in the entity set SSN
which is comprised of :
Aircraft-Latitude
Aircraft-Longitude Notation
Aircraft-Altitude
Notation
Age M-sal
B-days Y-sal
EMPLOYEE
Derived Vs. Stored Attributes
Order Total-Value
Some attribute
values can be
derived from
attributed values of
related entities qty
total-value ® sum
Item price
(qty * price)
Representing Attributes
Parenthesis ( ) for composite attributes
Brackets { } for multi-valued attributes
Assume a person can have more than one residence
and each residence can have multiple telephones
{AddressPhone
({ Phone ( AreaCode,PhoneNum ) },
Address (StreetAddresss (Number, Street,
AptNo), City,State,PostalCode) ) }
Examples
Identify a few entity types, instances,
attributes and candidate keys for:
Case at DFD course
To be continued ....
Entity-Relationship (E-R) Modeling
Key Terms
Relationship
An association between the instances of
one or more entity types that is of
interest to the organization
Association indicates that an event has
occurred or that there is a natural link
between entity types
Relationships are always labeled with
verb phrases
Cardinality
The number of instances of entity B that
can be associated with each instance of
entity A
Minimum Cardinality
The minimum number of instances of entity B
that may be associated with each instance of
entity A
This is also called “modality”.
Maximum Cardinality
The maximum number of instances of entity B
that may be associated with each instance of
entity A
Naming and Defining
Relationships
Relationship name is a verb phrase
Avoid vague names
Guidelines for defining relationships
Definition explains what action is being taken
and why it is important
Give examples to clarify the action
Optional participation should be explained
Explain reasons for any explicit maximum
cardinality
Naming and Defining
Relationships
Guidelines for defining relationships
Explain any restrictions on participation in
the relationship
Explain extent of the history that is kept
in the relationship
Explain whether an entity instance
involved in a relationship instance can
transfer participation to another
relationship instance
10.31
10.31
Relationships
Departments
The degree of a relationship type is
the number of participating entity
types
– 2 entities: Binary Relationship Works_In Binary
3 entities: Ternary Relationship
n entities: N-ary Relationship
– Same entity type could participate in Employees Multiple
multiple relationship types
Ternary
Part
Entity Roles
Departments
Each entity type that
participates in a relationship employer
type plays a particular role
in the relationship type
Role
Works_In
Names
The role name signifies the
role that a participating
worker
entity from the entity type
plays in each relationship
instance, i.e. it explains what Employees
the relationship means
Recursive Relationships
Same entity type can participate more than once in
the same relationship type under different “roles”
Employees
Supervision
Relationship Constraints
Participation Constraints
N Works_In 1
Employees Departments
1 Manages 1
N Works_In 1
Employees Departments
1 Manages 1