0% found this document useful (0 votes)
19 views

Er Model

The document discusses the entity-relationship model including entity sets, relationship sets, attributes, E-R diagrams, keys, and mapping cardinalities. It also covers weak entity sets, composite attributes, multi-valued attributes, derived attributes, and participation constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Er Model

The document discusses the entity-relationship model including entity sets, relationship sets, attributes, E-R diagrams, keys, and mapping cardinalities. It also covers weak entity sets, composite attributes, multi-valued attributes, derived attributes, and participation constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 48

Entity-Relationship 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

 Comprises of entity and relationship


 What is entity?

Entity: Object/thing in the world


that is distinguishable from all
other object.
Example: specific person, company,
event, plant

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

 A relationship is a mathematical relation among n  2 entities, each


taken from entity sets
{(e1, e2, … en) | e1  E1, e2  E2, …, en  En}

where (e1, e2, …, en) is a relationship


 Example:
(Hayes, L-15)  borrower

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

 Rectangles represent entity sets.


 Diamonds represent relationship sets.
 Lines link attributes to entity sets and entity sets to relationship sets.
 Ellipses represent attributes
 Double ellipses represent multi-valued attributes.
 Dashed ellipses denote derived attributes.
 Underline indicates primary key attributes (will study later)
04/25/2024 8
E-R Diagram With Composite, Multi-
valued, and Derived Attributes

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).

 Relationship sets may involve more than two entity sets.

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.

 Most useful in describing binary relationship sets.

 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
04/25/2024 14
Mapping Cardinalities

One to One to many


one
Note: Some elements in A and B may not be mapped to any
elements in the other set
04/25/2024 15
Mapping Cardinalities

Many to one Many to many


Note: Some elements in A and B may not be mapped to any
elements in the other set
04/25/2024 16
Mapping Cardinalities affect ER Design
 Can make access-date an attribute of account, instead of a relationship
attribute, if each account can have only one customer
 I.e., the relationship from account to customer is many to one, or
equivalently, customer to account is one to many

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

 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

04/25/2024 20
Many-To-Many Relationship

 A customer is associated with several (possibly 0) loans via


borrower
 A loan is associated with several (possibly 0) customers via
borrower

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.

 A candidate key of an entity set is a minimal super key


Customer-id is candidate key of customer
account-number is candidate key of account

 Although several candidate keys may exist, one of the


candidate keys is selected to be the primary key.

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.

 The existence of a weak entity set depends on the existence of a


identifying entity set
 it must relate to the identifying entity set via one-to-many
relationship set from the identifying to the weak entity set
 Identifying relationship depicted using a double diamond

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

 In a university, a course is a strong entity and a course-offering


can be modeled as a weak entity

 The discriminator of course-offering would be semester (including


year) and section-number (if there is more than one section)

 If we model course-offering as a strong entity we would model


course-number as an attribute.

Then the relationship with course would be implicit in the course-


number attribute

04/25/2024 28
Extended ERD

 Includes all modeling concepts of basic ER

 Additional concepts: subclasses/super-classes,


specialization/generalization, categories, attribute inheritance

 The resulting model is called the enhanced-ER or Extended ER


(E2R or EER) model

 It is used to model applications more completely and accurately


if needed

 It includes some object-oriented concepts, such as inheritance

04/25/2024 29
Super-class & Subclass

 An entity type may have additional meaningful sub groupings of


its entities

 Example: EMPLOYEE may be further grouped into


SECRETARY, ENGINEER, MANAGER, TECHNICIAN,
SALARIED_EMPLOYEE, HOURLY_EMPLOYEE,…
 Each of these groupings is a subset of EMPLOYEE entities
 Each is called a subclass of EMPLOYEE
 EMPLOYEE is the super-class for each of these subclasses

 These are called super-class/subclass relationships.

 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

 An entity that is member of a subclass inherits all attributes of the


entity as a member of the super-class and all relationships also.

04/25/2024 31
Specialization

 The process of defining a set of subclasses of a super-class.


 Top-down design process; we designate sub groupings within an
entity set that are distinctive from other entities in the set.

 These sub groupings become lower-level entity sets that have


attributes or participate in relationships that do not apply to the
higher-level 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.
04/25/2024 32
Specialization Example

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.

 Several classes with common features are generalized into a


super-class; original classes become its subclasses

 Example: CAR, TRUCK generalized into VEHICLE; both CAR,


TRUCK become subclasses of the super-class VEHICLE

 Specialization and generalization are simple inversions of each


other; they are represented in an E-R diagram in the same way.
 The terms specialization and generalization are used
interchangeably.
04/25/2024 34
Specialization and Generalization
(Contd.)
 Can have multiple specializations of an entity set based on
different features.

 E.g. permanent-employee vs. temporary-employee, in addition to


officer vs. secretary vs. teller

 Each particular employee would be


 a member of one of permanent-employee or temporary-
employee,
 and also a member of one of officer, secretary, or teller
 The ISA relationship also referred to as super-class - subclass
relationship

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

 Eliminate this redundancy via aggregation


 Treat relationship as an abstract entity
 Allows relationships between relationships
 Abstraction of relationship into new entity

 Without introducing redundancy, the following diagram represents:


 An employee works on a particular job at a particular branch
 An employee, branch, job combination may have an associated manager
E-R Diagram With Aggregation
E-R Design Decisions
 The use of an attribute or entity set to represent an object.

 Whether a real-world concept is best expressed by an entity set or a


relationship set.

 The use of a ternary relationship versus a pair of binary relationships.

 The use of a strong or weak entity set.

 The use of specialization/generalization – contributes to modularity in the


design.

 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

You might also like