1-Data Modeling-ER Diagrams
1-Data Modeling-ER Diagrams
1
Entity-Relationship Modelling
1. Entities
2. Attributes
3. Relationships
4. Constraints
Keys
Mapping Cardinality
5. ER Notations
6. Roles
7. Participation
8. Strong & Weak Entity Sets
2
Entity-Relationship (ER) Modeling.
1976 proposed by Peter Chen
ER diagram is widely used in database design
1/9/2020 3
3
ER Modeling.
ER Modeling is a top-down approach to
database design.
Entity Relationship (ER) Diagram
A detailed, logical representation of the entities,
associations and data elements for an organization
or business
Notation uses three main constructs
Data entities
Chen Model &
Relationships Crow’s Foot Model
Attributes
4
ER Diagrams
The authors current version is somewhat UML-like, but previously used Chen’s
notation.
5
Chen Notation
Association
between the
instances of one or
more entity types
6
Crow’s Foot Notation
EntityName
EntityName Verb phrase
List of
Attributes
7
1. Entities
Examples of entities:
Person: EMPLOYEE, STUDENT, PATIENT
Place: STORE, WAREHOUSE
Object: MACHINE, PRODUCT, CAR
Event: SALE,REGISTRATION, RENEWAL
Concept: ACCOUNT, COURSE
8
2. Attributes
9
Attributes
The set of permitted values for an attribute is call the domain of that attribute.
10
Composite Attributes
11
Attributes - Chenn
12
13
Attributes - UML
composite
customer
simple ID
name
first
middle
last
address
strieet
number
name
apt-number
city multi-valued
derived state
zip-code
{ phone_number }
date-of-birth
age ()
Notes:
In many applications the terms are much more ambiguous (e.g., function designators)
An ER diagram is typically accompanied by a document that defines all the terms
Much harder to do than it appears (e.g., what is an “orbit” for a satellite?)
14
3. Relationships
Relationship name:
writes
Author Book
15
Relationships
16
Relationships
since
name dname
ssn lot did budget
17
Degree of Relationships
18
E-R Diagram with a Ternary Relationship
19
Relationship
20
Relationship Sets with Attributes
access-date
customer
account
ID depositor number
name balance
strieet
city
21
4. Constraints
Keys
Cardinalities
22
Keys
customer
loan
ID borrower number
name amount
strieet
city
23
Mapping Cardinalities
24
Cardinalities Examples
25
Mapping Cardinalities
28
Cardinality Constraints
customer
loan
ID borrower number
name amount
strieet
city
29
One-To-Many Relationship
customer
loan
ID borrower number
name amount
strieet
city
30
Many-To-One Relationships
customer
loan
ID borrower number
name amount
strieet
city
31
Many-To-Many Relationship
customer
loan
ID borrower number
name amount
strieet
city
32
5. ER NOTATIONS – Chenn Model
33
ER Notations
customer
loan
ID borrower number
name amount
strieet
city
35
ER Notations
36
ER Notations
37
6. Roles
38
Roles
1. Director
2. Manager
3. Secretary
4. Worker
39
7. Participation of an Entity Set
in a Relationship Set
customer
loan
ID borrower number
name amount
strieet
city
40
8. Strong Entity Sets
For most entity sets, a primary key is specified in terms of its immediate
attributes.
41
Weak Entity Sets
42
Weak Entity Sets, Cont.
In such a case, a primary key for the weak entity set can be constructed
with two parts:
primary key of the strong entity set on which the weak entity set is
existence dependent
The weak entity set’s discriminator
43
Weak Entity Sets (Cont.)
44
More Weak Entity Set Examples
course
section
ID sec-course sec_id
title semester
credits year
45
E-R Diagram for a Banking
Enterprise (Chen’s Notation)
46
E-R Diagram
for a University
47
Exercise -1
48
Exercise 2
49
Thank You!
50