You are on page 1of 32

# DATA MODELING WITH

ENTITY RELATIONSHIP
DIAGRAM
PART 1
ARDI NUGRAHA, BCS, MIT

## Data Modeling with

Entity Relationship Diagrams
Entities!
Attributes!
Relationships !
Connectivity and Cardinality
Existence Dependence!
Associative Entities!

Data
Modeling
with !
ERD

Relationship
Objectives

components

Data
Modeling
with !
ERD

Relationship
ERD

## ERD represents conceptual database

as viewed by end user
STUDENT TABLE

STUDENT

STUDENT_ID

STUDENT_NAME

STUDENT_ID

B03139289

ZAINAB

## TAMAN BAHAGIA , JOHOR BHARU

B03182781

MARIAM

TAMAN KEMBOJA, KL

B03167281

SHIKIN

B03123222

TAMAN AMAN , JB

STUDENT_NAME

Data
Modeling
with !
ERD

Relationship
ERD

## STRONG & WEAK

COMPOSITE, SIMPLE, SINGLE-VALUED, MULTIVALUED, DERIVED
(1:1) , (1:M) , (M:N)

Data
Modeling
with !
ERD

MODEL
ENTITIES
&
ATTRIBUTES

ERD

STEP by STEP

CHOOSE PK

MODEL
DETERMINE
RELATIONSHIP CARDINALITIES

CHECK THE
MODEL

Data
Modeling
with !
ERD

ERD
Entity

Data
Modeling
with !
ERD

ERD
Entity

## Refers to entity set and not to single entity occurrence

Corresponds to table and not to row in relational
environment
In Chen and Crows Foot models, entity is represented
by rectangle with entitys name
The entity name, a noun, is written in capital letters
STUDENT TABLE
STUDENT_ID

STUDENT_NAME

B03139289

ZAINAB

## TAMAN BAHAGIA , JOHOR BHARU

B03182781

MARIAM

TAMAN KEMBOJA, KL

B03167281

SHIKIN

## TAMAN BUAYA MELAKA

TAMAN AMAN , JB

B03123222

Data
Modeling
with !
ERD

ERD

Attributes

Characteristics of entities
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
5

Data
Modeling
with !
ERD

ERD
Model

Data
Modeling
with !
ERD

ERD

Attribute

## Required attribute: must have a value

Optional attribute: may be left empty
Domain: set of possible values for an attribute
- Attributes may share a domain
Examples:
A field for gender may have the domain {male, female, unknown} where those three
values are the only permitted entries in that column.

## Identifiers: one or more attributes that uniquely

identify each entity instance
Composite identifier: primary key composed of more
than one attribute

Data
Modeling
with !
ERD

ERD

Attribute
HOUSE_NUMBER

POSTCODE

HOUSE_NUMBER

POSTCODE

## Multivalued attributes can have many values :

staff_number phone_ext
s_01

345
234
333

Data
Modeling
with !
ERD

ERD

Attribute

10

2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.
May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.

Data
Modeling
with !
ERD

ERD

Attribute

Data
Modeling
with !
ERD

ERD

Attribute

## M:N relationships and multivalued attributes should

not be implemented
- Create several new attributes for each of the original
multivalued attributes components
- Create new entity composed of original multivalued
attributes components

## Derived attribute: value may be calculated from

other attributes
- Need not be physically stored within database
11

Data
Modeling
with !
ERD

ERD
Keys

## Keys are indicated in ER diagrams by underlining the key attributes

UNIQUE VALUES
NO CHANGE OVER TIME
PREFERABLY SINGLE ATTRIBUTE

Data
Modeling
with !
ERD

ERD
Keys

## Keys are indicated in ER diagrams by underlining the key attributes

Data
Modeling
with !
ERD

ERD
Entity and Attribute

Data
Modeling
with !
ERD

ERD
Connectivity and Cardinality

## Association between entities

Participants are entities that participate in a
relationship
Relationships between entities always operate in
both directions
Relationship can be classified as 1:M
Relationship classification is difficult to establish if
only one side of the relationship is known
13

Data
Modeling
with !
ERD

ERD
Connectivity and Cardinality

## CUSTOMER purchase PRODUCT

Data
Modeling
with !
ERD

ERD
Connectivity and Cardinality

Connectivity
- Describes the relationship classification

Cardinality
- Expresses minimum and maximum number of entity
occurrences associated with one occurrence of
related entity

## Established by very concise statements known as

14

Data
Modeling
with !
ERD

ERD
Connectivity and Cardinality

Data
Modeling
with !
ERD

ERD
Connectivity and Cardinality

Data
Modeling
with !
ERD

ERD

MAX CARDINALITY

MIN CARDINALITY

## CUSTOMER purchase one or many PRODUCT

(CONNECTIVITIES)
purchase
(1,1)

(1,4)

(CARDINALITIES)

15

Data
Modeling
with !
ERD

ERD
Existence Dependence

Existence dependence
- Entity exists in database only when it is associated
with another related entity occurrence

Existence independence
- Entity can exist apart from one or more related entities
- Sometimes such an entity is referred to as a strong or
regular entity
16

Data
Modeling
with !
ERD

ERD
Associative (Composite) Entities

## Also known as bridge entities

Used to implement M:N relationships
Composed of primary keys of each of the entities
to be connected
May also contain additional attributes that play no
role in connective process

13

Data
Modeling
with !
ERD

ERD
Associative (Composite) Entities

14

Data
Modeling
with !
ERD

ERD
Associative (Composite) Entities

To create a relationship, a "child" entity must inherit the primary key of a "parent" entity.
However, in a many-to-many relationship, neither entity is the "parent" or the "child"; the
relationship is "unresolved".

EMP

handle/handled by

PRO

EMPLOYEE_ID

EMPLOYEE_NAME

PROJECT_ID_1

PROJECT_ID_2

PROJECT_ID_3

E1

P10

P13

P11

E2

E3

P10

E4

P12

PROJECT

P13
P11

## a project must be handled at least one or more employee

PROJECT_ID

PROJECT_NAME

EMPLOYEE_ID_1 EMPLOYEE_ID_2

P10

AB

E1

E3

P11

JS

E1

E3

P12

KL

E4

P13

YU

E1

E2

## at least one or more

Data
Modeling
with !
ERD

ERD
Associative (Composite) Entities

## A CUSTOMER can purchase

clothes as much as they want
at Pumpkin Patch Boutique.
How ever, it is also an optional
for a CUSTOMER to buy any
product from the boutique.
There are4 managers who
work there and they must
belong to only on department.
As a manager, it is a daily
routine for them to update
stock information. Therefor
any product should not be left
unmanaged and a manager is
responsible to handle at least
one or more product at one
time.

SUMMARY
Entity relationship (ER) model
- Uses ERD to represent conceptual database as viewed
by end user
- ERMs main components:
Entities
Relationships
Attributes

## - Includes connectivity and cardinality notations

- Connectivities and cardinalities are based on business
rules
23