You are on page 1of 28

Database

Management
ER MODELING AND
RELATIONSHIP SCHEMA
Introduction to Entity-Relationship (E-R) Modeling
Relationships
Cardinalities in Relationships
Conceptual Data Modeling and the E-R Model
Logical Design
Data Modeling
Data Modeling Notations:

Contents The Entity Relationship (E-R) Model:


Relationships:
Cardinality in Relationships:
Ordinality in Relationships
Cardinality and Ordinality in Relationships:
Relationships Explained
References
Introduction to Entity-
Relationship (E-R) Modeling

■The E-R model is expressed in terms of:


◻Data entities in the business environment.
◻Relationships or associations among those
entities.
◻Attributes or properties of both the entities and
their relationships.
Introduction to E-R Modeling
(Cont.)

■Entity: a person, place, object, event or


concept in the user environment about
which data is to be maintained
■Entity type: collection of entities that
share common properties or characteristics
■Entity instance: single occurrence of an
entity type

Chapter 8 © 2014 Pearson Education, Inc. Publishing as Prentice Hall 4


Relationships

■Relationship: an association between the


instances of one or more entity types that is
of interest to the organization
■Degree: the number of entity types that
participate in a relationship
Figure 8-10
Relationship type and
instances
(a) Relationship type
(Completes)
(b) Relationship
instances

Chapter 8 © 2014 Pearson Education, Inc. Publishing as Prentice Hall 6


Cardinalities in Relationships
■Cardinality: the number of instances of
entity B that can (or must) 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
■Maximum Cardinality
◻The maximum number of instances of entity B
that may be associated with each instance of
entity A

Chapter 8 © 2014 Pearson Education, Inc. Publishing as Prentice Hall 7


Cardinalities in Relationships
(Cont.)
■Mandatory vs. Optional Cardinalities
◻Specifies whether an instance must exist or can
be absent in the relationship

Chapter 8 © 2014 Pearson Education, Inc. Publishing as Prentice Hall 8


Sample conceptual data model
FIGURE 8-14 Examples of cardinality constraints

(a) Mandatory cardinalities

(b) One optional, one mandatory cardinality

(c) Optional cardinalities


Chapter 8 © 2014 Pearson Education, Inc. Publishing as Prentice Hall 10
Conceptual Data Modeling and
the E-R Model

■Unary relationship: a relationship between the


instances of one entity type
◻Also called a recursive relationship
■Binary relationship: a relationship between
instances of two entity types
◻Most common type of relationship encountered in data
modeling
■Ternary relationship: a simultaneous relationship
among instances of three entity types

Chapter 8 © 2014 Pearson Education, Inc. Publishing as Prentice Hall 11


Unary relationships

Binary relationships

FIGURE 8-11
Examples of relationships of different
Ternary relationships degrees

Chapter 8 © 2014 Pearson Education, Inc. Publishing as Prentice Hall 12


Logical Design
Logical Database Design
• The process of deciding how to arrange the attributes of
the entities in the business environment into database
structures, such as the tables of a relational database.
• The goal is to create well structured tables that properly
reflect the company’s business environment.

13
Data Modeling
Data Modeling is a creative, dynamic and evolving
process for:
◦ Exploring the different ways that entities can
relate to each other as they would in the real
world
◦ Recording or drawing entities as they would
behave in a business environment

14
Data Modeling Notations:
A set of symbols used to
construct the ERD
There are many different
notations available but they
all communicate the same
idea
We will follow Barker’s
notation in this course

15
The Entity Relationship (E-R)
Model:
◦ Is a diagramming technique best known as ERD
◦ Is a series of Diagrams listing entities (with
attributes) and the relationships between
entities
◦ Is subject to many variations of representing
entities and relationships

16
The Entity Relationship (E-R)
Model:
An entity is drawn as a
rounded rectangle
Entity’s name appears singular - at
top - in capital letters
Entity’s attributes are
shown below its Name
The primary key attribute is
indicated by a solid underline

17
Relationships:
• The process of connecting any two entities in a
data model.
• The Associations between entities to enforce
Business Rules or Organizational Policies
• Different kinds:
◦ Binary relationships
◦ Unary relationships
◦ Ternary relationships

18
Binary Relationships

Simplest kind of relationship


Relationship between two entity types
A salesperson “sells” products
A product “sold by” by salespersons

19
Relationships Types
▪ 1-1 (1:1)
▪ A single occurrence of one entity type can be associated with a
single occurrence of the other entity type and vice versa
▪ 1-M or M-1 (1:M, M:1)
▪ Use “Barker’s Notation” to represent the multiple association
▪ “many” = the maximum number of occurrences that can be
involved; means a number that can be: 1,2...N
▪ Sometimes the “M” can be represented by “N”
▪ M-N (M:N)
▪ “many” can be either an exact number or have a known
maximum
▪ Sometimes the “M” can be represented by “N”

20
C.Cardinality in Relationships:

Cardinality specifies how many instances of an entity relate


to one instance of another entity.
(“outer” symbol is cardinality)

21
Ordinality in Relationships
▪Ordinality ( = Modality = Optionality )
▪ The minimum number of entity occurrences that can be
involved in a relationship.
▪ “inner” symbol on E-R diagram
▪Mandatory relationship: each instance from an entity
must be related to another instance.
▪ Represented by a straight line
▪Optional Relationship each instance from an entity may be
related to another instance
▪ Represented by a dashed line

22
C.Cardinality and Ordinality in
Relationships:
▪ Ordinality is closely coupled with Cardinality.
▪ While Cardinality specifies the occurrences of a
relationship, Ordinality describes the relationship as
either mandatory or optional.
▪ Cardinality specifies the maximum number of
occurrences.
▪ Ordinality specifies the absolute minimum number of
occurrences.
▪ When the minimum number is zero, the relationship is
usually called optional and when the minimum
number is one or more, the relationship is usually
called mandatory.
23
Relationships: One to many

Each SALESPERSON must sell to one or many CUSTOMERs


Each CUSTOMER must buy from one SALESPERSON

24
Relationships: many to many

Each SALESPERSON must sell one or many PRODUCTs


Each PRODUCT must be sold by one or many SALESPERSONs

25
C.Relationships: one to one –
in action:

Each SALESPERSON must work in one OFFICE


Each OFFICE may be occupied by one SALESPERSON

26
Relationships Explained

27
References
1. Fundamentals of Database Systems, Seventh
Edition, Elmasri and Navathe(Copyright@ 2017)
2. Modern Systems Analysis and Design, Seventh
Edition. Jeffrey A. Hoffer Joey F. George Joseph
S. Valacich, Chap 8

You might also like