Er Model
Er Model
Entity Sets
Relationship Sets
Design Issues
Mapping Constraints
Keys
E-R Diagram
Extended E-R Features
Design of an E-R Database Schema
04/25/2024 1
Entity relationship model
o f e n t i t i e s of
n ti t y s et: Set r e s ome
E s ha
m e t yp es that What is entity set?
sa es
properti o n s,
: s e t o f all pers
e s
Exampl s, trees, holiday
ie
compan
Entity Sets customer and loan
customer-id customer- customer- customer- loan- amount
name street city number
04/25/2024 3
Attributes
An entity is represented by a set of attributes, that is descriptive
properties possessed by all members of an entity set.
Example:
customer = (customer-id, customer-name,
customer-street, customer-city)
loan = (loan-number, amount)
Domain – the set of permitted values for each attribute
Derive
Compo attribute d
Simple site Multi-
attribut
attribut attribut Single- valued
e
e e valued attribut
E.g.
Eg- Eg- attribut e.
age,
class- name(fi e (phone-
given
roll rst,mid, no)
date of
last)
birth
04/25/2024 4
Composite Attributes
04/25/2024 5
Relationship
A relationship is an association among several entities
Example:
Hayes borrower L-15
customer entity relationship loan entity
04/25/2024 6
Relationship Set borrower
A relationship set is a set of relationships of the same type.
04/25/2024 7
E-R Diagrams
04/25/2024 9
Relationship Sets (Cont.)
An attribute can also be property of a relationship set.
For instance, the depositor relationship set between entity sets
customer and account may have the attribute access-date
04/25/2024 10
Relationship Sets with Attributes
04/25/2024 11
Degree of a Relationship Set
Refers to number of entity sets that participate in a
relationship set.
Relationship sets that involve two entity sets are binary (or
degree two).
04/25/2024 12
E-R Diagram with a Ternary
Relationship
Employees of a bank may have jobs at multiple branches, with
different jobs at different branches. Then there is a ternary
relationship set .
04/25/2024 13
Mapping Cardinalities
Express the number of entities to which another entity can
be associated via a relationship set.
04/25/2024 17
Cardinality Constraints
We express cardinality constraints by drawing either a directed line
(), signifying “one,” or an undirected line (—), signifying “many,”
between the relationship set and the entity set.
E.g.: One-to-one relationship:
A customer is associated with at most one loan via the
relationship borrower
A loan is associated with at most one customer via borrower
04/25/2024 18
One-To-Many Relationship
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
04/25/2024 19
Many-To-One Relationships
04/25/2024 20
Many-To-Many Relationship
04/25/2024 21
Roles
Entity sets of a relationship need not be distinct
The labels “manager” and “worker” are called roles; they
specify how employee entities interact via the works-for
relationship set (recursive relationship).
Roles are indicated in E-R diagrams by labeling the lines that
connect diamonds to rectangles.
04/25/2024 22
Participation of an Entity Set in a
Relationship Set
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
04/25/2024 23
Keys
A super key of an entity set is a set of one or more
attributes whose values uniquely determine each entity.
04/25/2024 24
Weak Entity Sets
An entity set that does not have a primary key is referred to as a weak
entity set.
04/25/2024 25
Weak Entity Sets
The discriminator (or partial key) of a weak entity set is the set of
attributes that distinguishes among all the entities of a weak entity set.
The primary key of a weak entity set is formed by the primary key of
the strong entity set on which the weak entity set is existence
dependent, plus the weak entity set’s discriminator.
04/25/2024 26
Weak Entity Sets (Cont.)
We depict a weak entity set by double rectangles.
We underline the discriminator of a weak entity set with a dashed
line.
payment-number – discriminator of the payment entity set
Primary key for payment – (loan-number, payment-number)
04/25/2024 27
More Weak Entity Set Examples
04/25/2024 28
Extended ERD
04/25/2024 29
Super-class & Subclass
E.g. EMPLOYEE/SECRETARY,EMPLOYEE/TECHNICIAN
04/25/2024 30
Super-class & Subclass
An entity that is member of a subclass represents the same real-
world entity as some member of the super-class
The Subclass member is the same entity in a distinct specific
role
An entity cannot exist in the database merely by being a
member of a subclass; it must also be a member of the super-
class
A member of the super-class can be optionally included as a
member of any number of its subclasses
04/25/2024 31
Specialization
04/25/2024 33
Generalization
A bottom-up design process – combine a number of entity sets
that share the same features into a higher-level entity set.
04/25/2024 35
Design Constraints on a
Specialization/Generalization
Constraint on which entities can be members of a given lower-level
entity set.
condition-defined
E.g. all customers over 65 years are members of senior-citizen entity
set; senior-citizen ISA person.
user-defined
Constraint on whether or not entities may belong to more than one
lower-level entity set within a single generalization.
Disjoint
an entity can belong to only one lower-level entity set
Noted in E-R diagram by writing disjoint next to the ISA triangle
Overlapping
an entity can belong to more than one lower-level entity set
04/25/2024 36
Design Constraints on a
Specialization/Generalization
(Contd.)
Completeness constraint -- specifies whether or not an entity in the
higher-level entity set must belong to at least one of the lower-level
entity sets within a generalization.
total : an entity must belong to one of the lower-level entity sets
partial: an entity need not belong to one of the lower-level entity sets
04/25/2024 37
Constraints on
Specialization and
Generalization
Hence, we have four types of specialization/generalization:
Disjoint, total
Disjoint, partial
Overlapping, total
Overlapping, partial
Note: Generalization usually is total because the super-class is derived
from the subclasses.
Example of disjoint partial
Specialization
Specialization /
Generalization Lattice
Example (UNIVERSITY)
Aggregation
Consider the ternary relationship works-on, which we saw earlier
Suppose we want to record managers for tasks performed by an
employee at a branch
Aggregation (Cont.)
Relationship sets works-on and manages represent overlapping information
Every manages relationship corresponds to a works-on relationship
However, some works-on relationships may not correspond to any
manages relationships
So we can’t discard the works-on relationship
The use of aggregation – can treat the aggregate entity set as a single unit
without concern for the details of its internal structure.
04/25/2024 44
Summary of Symbols Used in E-R
Notation
04/25/2024 45
Summary of Symbols (Cont.)
04/25/2024 46
Alternative E-R Notations
04/25/2024 47
E-R Diagram for a Banking
Enterprise
04/25/2024 48