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

2.CSI2004-ADBMS-Module1_ER Model_compressed

The document discusses the Entity-Relationship Model (E-R Model) used in database design, which includes entities, their attributes, and the relationships between them. It outlines the process of creating an E-R diagram, the types of attributes, relationship sets, and cardinality constraints. Additionally, it explains weak entity sets and provides examples of E-R diagrams in various contexts.

Uploaded by

roshika.s2022
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

2.CSI2004-ADBMS-Module1_ER Model_compressed

The document discusses the Entity-Relationship Model (E-R Model) used in database design, which includes entities, their attributes, and the relationships between them. It outlines the process of creating an E-R diagram, the types of attributes, relationship sets, and cardinality constraints. Additionally, it explains weak entity sets and provides examples of E-R diagrams in various contexts.

Uploaded by

roshika.s2022
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

CSI2004 - Advanced Database

Management Systems
Entity –Relationship Model
Entity –Relationship Model
 A database can be modeled as:
 a collection of entities,
 relationship among entities.
 An entity is an object that exists and is
distinguishable from other objects.
 Example: specific person, company, event, plant
 Entities have attributes
 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
Entity –Relationship Model

The design of any database is a lengthy and


involved task that can only be done through a
step-by-step process.

1. The first step normally involves interviewing


potential users of the database.
2. The second step is to build an entity-
relationship model (ERM) that defines the
entities, the attributes of those entities and
the relationship between those entities.

12/18/2024 4:37:37
PM
14.4
Entity –Relationship Model
•In this step, the database designer creates an
entity-relationship (E-R) diagram to show the
entities for which information needs to be stored
and the relationship between those entities.
• E-R diagrams uses several geometric shapes.
•A few of them
❑ Rectangles represent entity sets
❑ Ellipses represent attributes
❑ Diamonds represent relationship sets
 Lines link attributes to entity sets and link
entity sets to relationships sets
12/18/2024 4:37:37
PM
14.5
Entity –Relationship Model

 E-R model of real world


 Entities (objects)
E.g. customers, accounts, bank branch
 Relationships between entities
E.g. Account A-101 is held by customer
Johnson
Relationship set depositor associates
customers with accounts
 Widely used for database design
 Database design in E-R model usually converted
to design in the relational model which is used
for storage and processing
Entity –Relationship Model

Example of schema in the entity-relationship model


Entity –Relationship Model

Example of schema in the entity-relationship model


Entity –Relationship Model
Example
Very simple E-R diagram with three entity sets, their
attributes and the relationship between the entity sets.

12/18/2024 4:37:37
PM Entities, attributes and relationships in an E-R diagram
14.9
Entity – Relationship Model
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 – Set of permitted values for each attribute


 Attribute types:
 Simple and composite attributes.
 Single-valued and multi-valued attributes
 Example: multivalued attribute: phone_numbers
 Derived attributes
 Can be computed from other attributes
 Example: age date_of_birth , system date
E-R Diagrams
Double ellipses represent multivalued attributes.
Dashed ellipses denote derived attributes.
Underline indicates primary key attributes
Entity –Relationship Model

Composite Attributes
E-R Diagram With Composite,
Multivalued, and Derived Attributes
Relationship Sets with Attributes
Entity Sets customer and loan
customer_id customer_ customer_ customer_ loan_ amount
name street city number
Entity –Relationship Model
Relationship Sets
 A relationship is an association among several
entities
Example:
Hayes depositor A-102
customer entity relationship set account entity
 A relationship set 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, A-102)  depositor
Entity –Relationship Model

Relationship Set borrower


Entity –Relationship Model
Relationship Sets
 An attribute can also be a property of a relationship set.
 For instance, the depositor relationship set between entity
sets customer and account may have the attribute access-
date
Entity –Relationship Model

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). Generally, most relationship sets in a database system are
binary.
 Relationship sets may involve more than two entity sets.
Example: Suppose employees of a bank may have
jobs (responsibilities) at multiple branches, with
different jobs at different branches. Then there is a
ternary relationship set between entity sets
employee, job, and branch
 Relationships between more than two entity sets are rare. Most
relationships are binary. (More on this later.)
Entity –Relationship Model

Mapping Cardinality Constraints

 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
Entity –Relationship Model

Mapping Cardinalities

One to one One to many


Entity –Relationship Model
Mapping Cardinalities

Many to one Many to many


Entity –Relationship Model
Keys for Relationship Sets
 The combination of primary keys of the participating entity
sets forms a super key of a relationship set.
 (customer_id, account_number) is the super key of
depositor
 NOTE: this means a pair of entity sets can have at most
one relationship in a particular relationship set.
Example: if we wish to track all access_dates to each
account by each customer, we cannot assume a
relationship for each access. We can use a
multivalued attribute though
 Must consider the mapping cardinality of the relationship
set when deciding what are the candidate keys
 Need to consider semantics of relationship set in selecting
the primary key in case of more than one candidate key
Entity –Relationship Model

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.
 Roles are indicated in E-R diagrams by labeling the lines that
connect diamonds to rectangles.
 Role labels are optional, and are used to clarify semantics of the
relationship

24
Entity –Relationship Model

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.
 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
Entity –Relationship Model

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

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

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
Entity –Relationship Model
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
Example: participation of customer in borrower is partial
Entity –Relationship Model

Alternative Notation for Cardinality Limits

Cardinality limits can also express participation constraints


Entity –Relationship Model
E-R Diagram with a Ternary Relationship
Entity –Relationship Model
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 a total, one-to-
many relationship set from the identifying to the weak entity
set
 Identifying relationship depicted using a double diamond
 The
 (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.
Entity –Relationship Model
Weak Entity Sets
 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)
Entity –Relationship Model

Weak Entity Sets

 Note: the primary key of the strong entity set is not


explicitly stored with the weak entity set, since it is
implicit in the identifying relationship.
 If loan_number were explicitly stored, payment
could be made a strong entity, but then the
relationship between payment and loan would be
duplicated by an implicit relationship defined by the
attribute loan_number common to payment and loan
Entity –Relationship Model

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
E-R Diagram for a Banking Enterprise

36
Summary of Symbols Used in E-R Notation
Summary of Symbols

You might also like