You are on page 1of 24

WHAT IS AN ENTITY - RELATIONSHIP

DIAGRAM (ER-D)?

An entity-relationship diagram is


a data modeling technique that
creates a graphical
representation of the entities, and
the relationships between entities,
within an information system.
EXAMPLE OF AN ER DIAGRAM
PERSON

father of/
child of
The diagram above indicates that
a person may be the father of
zero or many persons, and that a
person may have zero or one
father.
SYMBOLS USED IN AN ERD
 A circle (  ) indicates that the
relationship is optional

 A stroke ( | ) indicates that the


relationship is mandatory

 A “crows-foot” ( ) indicates that many


such relationships between instances of
the related entities might exist.
ENTITY

RELATIONSHIP
OPTIONALITY and CARDINALITY
 Symbols at the ends of the relationship
lines indicate the optionality and the
cardinality of each relationship.

 “Optionality” expresses whether the


relationship is optional or mandatory.
“Cardinality” expresses the maximum
number of relationships.
The following diagrams indicate all of the possible
combinations

Each instance of A is related to a minimum of


A B
zero and a maximum of one instance of B

Each instance of B is related to a minimum of


A B
one and a maximum of one instance of A

Each instance of A is related to a minimum of


A B
one and a maximum of many instances of B

Each instance of B is related to a minimum of


A B
zero and a maximum of many instances of A
AN ERD EXPLAINED
STUDENT
Each school enrolls Each student attends

at least zero at least one

and at most many and at most one

students school
SCHOOL
THE MAIN COMPONENTS OF AN
ERD:
 The entity is a person, object,

place or event for which data is


collected. For example, if you
consider the information system
for a business, entities would
include not only customers, but
the customer's address, and
orders as well. The entity is
represented by a rectangle and
labeled with a singular noun
 Therelationship is the
interaction between the
entities. A relationship
may be represented by a
diamond shape, or more
simply, by the line
connecting the entities. In
either case, verbs are used
to label the relationships.
 The cardinality defines the relationship
between the entities in terms of numbers. An
entity may be optional: or mandatory.
 There are several different types of cardinality

notation; crow's foot notation, . In crow's foot


notation, a single bar indicates one, a double
bar indicates one and only one, a circle
indicates zero, and a crow's foot indicates
many. The three main cardinal relationships
are: one-to-one, expressed as 1:1; one-to-
many, expressed as 1:M; and many-to-many,
expressed as M:N.
Steps involved in creating ER Diagrams
 Identify the entities.

 Determine all significant interactions.

 Analyze the nature of the interactions.

 Draw the ERD.


BRIDGE ENTITY/LINKING TABLE
When an instance of an entity may be
related to multiple instances of
another entity and vice versa, that is
called a “many-to-many relationship.”
In the example below, a supplier may
provide many different products, and
each type of product may be offered
by many suppliers:

provides/
SUPPLIER PRODUCT
offered by
While this relationship model is
perfectly valid, it cannot be
translated directly into a relational
database design. In a relational
database, relationships are expressed
by keys in a table column that point
to the correct instance in the related
table. A many-to-many relationship
does not allow this relationship
expression, because each record in
each table might have to point to
multiple records in the other table.
 
In order to build a relational database that
captures this relationship, it is necessary to
build a bridge between the two entities that
uniquely expresses each relationship
instance. This can be modeled in an ERD
with a “bridge entity,” an entity box
containing a diamond, which may replace
the many-to-many relationship. (The
diamond is used in other ER modeling
systems to indicate relationships, or may be
viewed as the joining—the bridge—of the
many-to-many “crows-feet”).
PROVIDES/
SUPPLIER PRODUCT
OFFERED BY

This diagram expresses the


same relationship as the
diagram above. Each instance
of the “provides” bridge entity
indicates that a certain
supplier can provide a certain
product.
 
is licensor
is licensee

negotiates

negotiates
ORGANIZATION CONSORTIUM
vends

PROCESSING
WORKFLOW RULES
WORKFLOW
CONSORTIAL
LOCATION USER GROUP ACQUISITION
PARTICIPATION

publishes

provides

LIBRARY
AVAILABLE AT AVAILABLE TO PARTNER LIBRARY
PARTICIPATION

TRIAL

ELECTRONIC PRODUCT

LIBRARY

ACCESS INTERFACE TERMS DEFINED


INFO

delivers

ADMIN
E-RESOURCE PREVAILING TERMS
INFO CONTACT
CONTACT
RESPONSIBILITIES

includes/
is part of
WORK

LICENSE

E-PRODUCT/
PRINT VERSION
LICENSE
ER DIAGRAMMING TOOLS
 There are many ER diagramming tools. Some of the
proprietary ER diagramming tools are ARIS, Avolution,
dbForge Studio for MySQL, DeZign for Databases,
ConceptDraw, ER/Studio, Devgems Data Modeler,
ERwin, MEGA International, Metastorm ProVision,
OmniGraffle, Oracle Designer, PowerDesigner,
Rational Rose, SmartDraw, Sparx Enterprise Architect,
SQLyog, System Architect, Toad Data Modeler,
SQL Maestro, Microsoft Visio, and Visual Paradigm
SCENARIO 1
 DRAW AN E-R DIAGRAM TO
ILLUSTRATE THE RELATIONSHIP
BETWEEN EACH ENTITY.
 (A) TEACHER AND FORM

 (B) FORM AND STUDENT

 (C) STUDENT AND SUBJECT


SCENARIO 2
ASCHOOL WISHES TO
DEVELOP A DATABASE TO
HOLD DETAILS ON ITS
STAFF, STUDENTS, FORMS,
SUBJECTS AND GRADE.
DRAW AN E-R DIAGRAM TO
REPRESENT THIS SYSTEM.
A
SCENARIO 3
HOSPITAL KEEPS INFORMATION ON
HOW ITS OPERATIONS. EACH WARD
HAS SEVERAL BEDS AND IS STAFFED BY
NURSES. A NURSE IS ASSIGNED TO A
SINGLE WARD.

 EACHPATIENT IS ASSIGNED TO A
SINGLE BED AND IS UNDER THE CARE
OF A SINGLE CONSULTANT. EACH
CONSULTANT IS RESPONSIBLE FOR A
NUMBER OF PATIENTS.
A publisher uses a
relational database to
record details of articles it
publishes in a monthly
magazine
Two relations (tables)

MAGAZINE EDITION and


MAGAZINE ARTICLE are
used for this database.
 MAGAZINE EDITION (Magazine
EditionId, Month, Year)
 MAGAZINE ARTICLE (ArticleId,

Article Type, Article Title, Content,


AuthorName, Magazine EditonId)

 Each Article is assigned a unique


ArticleId
 (a) What is a relational database?

 (b) State a suitable primary key


for the Magazine Edition relation.
Justify your choice

 (c)(i) Explain what is meant by


foreign key.
 (ii) Name the attribute which is
the foreign key in the relation
Magazine Article.

You might also like