ENTITY RELATIONSHIP
MODELING
BCA20
Engr. Florence B. Reyes
STUDY OBJECTIVES
Understand concepts of data modeling
and its purpose
Learn how relationships between entities
are defined and refined, and how such
relationships are incorporated into the
database design process
Learn how ERD components affect
database design and implementation
Learn how to interpret the modeling
symbols
WHY DATA MODELING?
Represent “reality” of the actual database
Blue print: documentation
Effective Communication Tool
User involvement
Represent abstraction of requirements
Identify the business rules to be stored in
the database
Independence from a particular DBMS
CONCEPTUAL DATA MODELING
The conceptual data modeling revolves
around discovering and analyzing
organizational and users data
requirements.
What data is important
What data should be maintained
The major activity of this phase is
identifying entities, attributes, and
their relationships to construct model
using the Entity Relationship Diagram
methodology.
DEFINITIONS
Entity Relationship Modelling (ERM)
A technique used to analyze & model the data in
organizations using an Entity Relationship (E-R)
diagram.
Entity-Relationship Diagram (ERD)
Data modeling methodology
A detailed, logical representation of the entities,
associations and data elements for an organization
or business.
DEFINITIONS
Entity
A person, place, object, event or concept in the user
environment about which the organization wishes
to maintain data
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
DEFINITIONS
Relationship
an association between two or more entities
that is of particular interest
Relationship Types
While entity types are the nouns of a data
model, relationships are the verbs that connect
those nouns.
A set of meaningful associations among entity
types.
BACKGROUND
Developed by Peter Chen in 1976
ERD is commonly used to:
Translate different views of data among
managers, users, and programmers to fit into
a common framework.
Define data processing and constraint
requirements to help us meet the different
views.
Help implement the database.
WHY USE ER DIAGRAM ?
Itprovides a global quick reference to an
organization’s data structures.
Can be used individually to design an
Information System’s (IS) data structure
Can be used with Data Flow Diagrams to
provide a more comprehensive IS logical
design.
BASIC ERD ELEMENTS
Entity: a collection of people, places,
objects, events, concepts of interest (a
table)
Entity instance – a member of the Entity : a
person, a place, an object … (a row in a table)
Attribute - property or characteristic of
interest of an entity (a field in a table)
Relationship – association between
entities (corresponds to primary key-
foreign key equivalencies in related
tables)
IDENTIFY THE ENTITIES
“A fundamental THING of relevance to the
enterprise about which data may be kept”
What should be an Entity: both tangible &
intangible
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
What should NOT be an Entity:
A user of the database system
An output of the database system (e.g. a report)
IDENTIFY THE ENTITIES
Any entity can be classified in one of the
following categories:
Regular Entity:
any physical object, event, or abstract concept
that we can record facts about.
Weak Entity:
any entity that depends on another entity for
its existence.
ERD USING IE NOTATION (MOST
POPULAR)
ENTITY INSTANCE
Entity instance: a single occurrence of an entity.
6 instances
Entity: student Student Last First
ID Name Name
2144 Arnold Betty
3122 Taylor John
3843 Simmons Lisa
instance
9844 Macy Bill
2837 Leath Heather
2293 Wrench Tim
ENTITY INSTANCE
15
DETERMINE THE ATTRIBUTES
Every Entity has attributes.
Attributes are characteristics that allow
us to classify/describe an entity
e.g., entity STUDENT has the attributes:
student number
name
date of birth
course number
CLASSES OF ATTRIBUTES
Simple attribute
Composite attribute
Derived attributes
Single-valued attribute
Multi-valued attribute
SIMPLE/COMPOSITE ATTRIBUTE
A simple attribute cannot be subdivided.
Examples: Age, Gender, and Marital status
A composite attribute can be further
subdivided to yield additional attributes.
Examples:
ADDRESS -- Street, City, State, Zip
PHONE NUMBER -- Area code, Exchange number
DERIVED ATTRIBUTE
Itis not physically stored within the
database
Instead, it is derived by using an
algorithm.
Example: AGE can be derived from the date of
birth and the current date.
MS Access: int(Date() – Emp_Dob)/365)
SINGLE-VALUED ATTRIBUTE
Can have only a single (atomic) value.
Examples:
A person can have only one social security number.
A manufactured part can have only one serial
number.
A single-valued attribute is not
necessarily a simple attribute.
Part No: CA-08-02-189935
Location: CA, Factory#:08, shift#: 02, part#: 189935
MULTI-VALUED ATTRIBUTES
Can have many values.
Examples:
A person may have several college degrees.
A household may have several phones with different
numbers
A car color
EXAMPLE - “MOVIE DATABASE”
Entity:
Movie Star
Attributes:
SS#: “123-45-6789” (single-valued)
Cell Phone: “(661)123-4567, (661)234-5678” (multi-
valued)
Name: “Harrison Ford” (composite)
Address: “123 Main Str., LA, CA” (composite)
Birthdate: “1-1-50” (simple)
Age: 50 (derived)
KEY ATTRIBUTES
Certainattributes identify particular facts
within an entity, these are known as KEY
attributes.
The different types of KEY attribute are:
Primary Key
Composite Primary Key
Foreign Key
KEY DEFINITIONS
Primary Key:
One attribute whose value can uniquely
identify a complete record (one row of data)
within an entity.
Composite Primary Key
A primary key that consists of two or more
attribute within an entity.
Foreign Key
A copy of a primary key that exists in another
entity for the purpose of forming a relationship
between the entities involved.
Notation Guide
ENTITY TYPE
rectangle containing the
entity’s name.
WEAK ENTITY TYPE
RELATIONSHIP TYPE
diamond containing the
relationship’s name
IDENTIFYING
RELATIONSHIP TYPE
… Notation Guide
ATTRIBUTE
oval containing the attribute’s
name.
_____
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
DERIVED ATTRIBUTE
... COMPOSITE ATTRIBUTE
A Sample ER Diagram
Entity
Entity
sname
Store Locations
Relationship
manager
qty Keeps
Attributes
pname
Product price
descrip
DEGREES OF A RELATIONSHIP
One-to-one (1:1)
1 1
Man Woman
One-to-many (1:n)
1 M
Customer Order
Many-to-many (n:m)
M M
Course Subject
NOTE: Every many to many relationship consists of two one to
many relationships working in opposite directions
DEGREES OF RELATIONSHIP, ALTERNATIVE
REPRESENTATION
One-to-one (1:1)
Man Woman
One-to-many (1:n)
Customer Order
Many-to-many (n:m)
Course Subject
NOTE: Every many to many relationship consists of two one to
many relationships working in opposite directions
NOTATION FOR MANDATORY/OPTIONAL
ATTRIBUTES
1 M
Person Car
A person must own at least one car. A car
doesn’t have to be owned by a person, but if
it is, it is owned 1by at least one person. A
person may own many cars.
optional relationship mandatory relationship
RECURSIVE RELATIONSHIPS
emp-name
emp-id
manager
employee works-for
worker
emp-street
emp-city
Must be declared with roles
WEAK ENTITY SETS
Still need to be able to distinguish between different
weak entities associated with the same strong entity
number trans-date
trans-number
account has Transaction
trans-type
balance trans-amt
A Sample ER Diagram
TRY THIS! (ASSIGNMENT: DUE 12/6/17)
Draw an ER Diagram of the situation
stated on the next slide. Take note of the
key attributes, degrees of relationships,
and mandatory/optional relationships.
Use ½ crosswise yellow paper for your
illustration.
TRY THIS! (ASSIGNMENT: DUE 12/6/17)
STUDENTs attend COURSEs that consist of
many SUBJECTs.
A single SUBJECT (i.e. English) can be studied
in many different COURSEs.
Each STUDENT may only attend one COURSE.
STUDENT can be characterized by StudID,
StudName, StudCourse.
COURSE can be characterized by CCode and
CDescription
SUBJECT can be characterized by SCode, and
SDescription
TRY THIS! (ASSIGNMENT: DUE 12/6/17)
Grading:
Entities correctly identified and illustrated: 5
Attributes correctly identified and illustrated: 5
Relationships correctly identified and illustrated: 5
Primary keys, degrees, mandatory/optional
relationships correctly identified and illustrated: 5