ENTITY RELATIONSHIP
MODEL
1
ENTITY SETS
2
 An entity is an “thing” or “object” that exists in
the real world and is distinguishable from other
objects.
 Example: specific person, company, event,
plant
 Every entity has a set of properties i.e. the
attributes and values for those properties.
 Example: people have names and addresses
 An entity set is a set of entities of the same type
that share the same properties.
 Example: set of all persons, companies, trees,
holidays
REPRESENTING ENTITIES
3
ENTITY_NAME
EXAMPLE OF ENTITIES
4
CUSTOMER
CUSTOMER_
ID
CUSTOMER_NA
ME
CUSTOMER_STR
EET
CUSTOMER_CIT
Y
5
customer-id customer- customer- customer- loan- amount
name street city number
Entity Sets customer and loan
TYPES OF ATTRIBUTES
6
 SIMPLE:
 COMPOSITE
 MULTI VALUED:
 DERIVED:
EXAMPLE OF ATTRIBUTES
7
CUSTOMER
CUSTOMER_
ID
CUSTOMER_STR
EET
CUSTOMER_DAT
E_OF_BIRTH
NAME
LNAME
MNAME
FNAME
AGE
TELNO
EXAMPLE OF ATTRIBUTES
8
CUSTOMER
CUSTOMER_
ID
CUSTOMER_STR
EET
CUSTOMER_DAT
E_OF_BIRTH
NAME
LNAME
MNAME
FNAME
TELNO
AGE
RELATIONSHIP SETS
9
 A relationship is an association among several
entities
 EXAMPLE: CUSTOMER HAS ACCOUNT
CUSTOMER ACCOUNT
HA
S
DEGREE OF A RELATIONSHIP
SET
10
 Refers to number of entity sets that participate in
a relationship set.
 Relationship sets that involve two entity sets are
binary (or degree two). Generally, most
relationship sets in a database system are binary.
MAPPING CARDINALITIES
11
 Express the number of entities to which
another entity can be associated via a
relationship set.
 For a binary relationship set the mapping cardinality must be
one of the following types:
 One to one
 One to many
 Many to one
 Many to many
ONE TO ONE ONE TO
MANY
12
MANY TO ONE MANY TO
MANY
13
CARDINALITY CONTRAINTS
14
 ONE TO ONE RELATIONSHIP
ONE TO MANY RELATIONSHIP
15
 In the one-to-many relationship a loan is
associated with at most one customer via
borrower, a customer is associated with
several (including 0) loans via borrower
MANY TO ONE RELATIONSHIP
16
 In a many-to-one relationship a loan is associated
with several (including 0) customers via borrower,
a customer is associated with at most one loan via
borrower
RELATIONSHIP
17
 A customer is associated with several (possibly 0)
loans via borrower
 A loan is associated with several (possibly 0)
customers via borrower
18
PARTICIPATION OF ENTITY IN
RELATIONSHIP
 Total participation (indicated by double line): every
entity in the entity set participates in at least one
relationship in the relationship set
 E.g. participation of loan in borrower is total
 every loan must have a customer associated to it
via borrower
 Partial participation: some entities may not participate
in any relationship in the relationship set
 E.g. participation of customer in borrower is partial
19
KEYS
 PRIMARY KEY:
 SUPER KEY: A super key of an entity set is a set
of one or more attributes whose values uniquely
determine each entity.
 CANDIDATE KEY:A candidate key of an entity set
is a minimal super key
20
ER DIAGRAM FOR
UNIVERSITY DATABASE
Draw E-Rdiagram for university database
consisting of four entities: Student, department,
Class,faculty
- student has a unique id,the student can enroll for
multiple classes
- Faculty must belong to department and faculty
can teach multiple classes
- Each class is taught by only one faculty
- Every student will get grade for the class he/she
has enrolled.
21
WEAK ENTITY SET
 An entity set that does not have a primary key is
referred to as a weak entity set.
22
WEAK ENTITY SET
23
Identifying
relationshi
p
Identifying
or owner
entity set
discriminator
SPECIALIZATION
 The process of designating subgroupings within
an entity set.
 Depicted by a triangle component labeled ISA
(E.g. customer “is a” person).
 Attribute inheritance – a lower-level entity set
inherits all the attributes and relationship
participation of the higher-level entity set to which
it is linked.
 The ISA relationship also referred to as
superclass - subclass relationship
24
25
TERNARY RELATIONSHIP
26
EXAMPLE
 Construct an E-R diagram for a
hospital with a set of patients and a
set of medical doctors. Associate
with each patient a log of the various
tests and examinations conducted.
27

THE ENTITY RELATIONSHIP MODEL IN DBMS.ppt