0% found this document useful (0 votes)
346 views51 pages

ERModel

The document describes key concepts of the entity-relationship (E-R) model, which is a popular conceptual model for database design. It discusses the different levels of abstraction in databases, as well as the main components of the E-R model including entities, attributes, relationships, keys, and structural constraints like cardinality and participation. The E-R model provides a way to conceptualize data and how different data elements are related to each other at a high level.

Uploaded by

deepaksunona
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
346 views51 pages

ERModel

The document describes key concepts of the entity-relationship (E-R) model, which is a popular conceptual model for database design. It discusses the different levels of abstraction in databases, as well as the main components of the E-R model including entities, attributes, relationships, keys, and structural constraints like cardinality and participation. The E-R model provides a way to conceptualize data and how different data elements are related to each other at a high level.

Uploaded by

deepaksunona
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 51

ENTITY-RELATIONSHIP MODEL

Levels of Abstraction

 Physical level: describes how a record (e.g., customer) is stored.


 Logical level: describes data stored in database, and the relationships among
the data.
type customer = record
customer_id : string;
customer_name : string;
customer_street : string;
customer_city : integer;
end;
 View level: application programs hide details of data types. Views can also hide
information (such as an employee’s salary) for security purposes.
View of Data
An architecture for a database system
Entity-Relationship Model

 Most popular conceptual model for database


design
 Basis for many other models
 Describes the data in a system and how that
data is related
 Describes data as entities, attributes and
relationships

4
The Pieces

 Objects
– Entity (including weak entities)
– Attribute
– Relationship
 “Structural” Constraints
– Cardinality
– Participation

5 3753 X1
Entities

 Entity – basic object of the E-R model


– Represents a “thing” with an independent existence
– Can exist physically or conceptually
 a professor, a student, a course

6
Entity Types

 Entity Set: A collection of similar entities. E.g.,


all employees.
– All entities in entity set have same set of attributes.
– Each entity set has a key.
– Each attribute has a domain
Roles

 Function of any entity set in a relationship is ROLE of entity


 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
Attributes

 Each entity has a set of associated properties


that describes the entity. These properties are
known as attributes.
 Attributes can be:
– Simple or Composite
– Single or Multi-valued
– Stored or Derived

9
Attributes
 Attribute: A properity of an entity or a relationship
type. For example: staffNo, name, position... To
describe the entity Staff.
 Attribute Domain: The set of allowable values for one
or more attributes.
 Attributes can be classified as being: simple or
composite; single-valued or multi-valued; or derived.
Simple and Composite Attributes

 Simple Attribute: An attribute composed of a


single component with an independent
existence. E.g position and salary of the Staff
entity.
 Composite Attribute: An attribute composed
of multiple components, each with an
independent existence. E.g adress attribute of
the branch entity that can be subdivided into
street, city and postcode attributes.
Attributes (cont’d)

Simple Professor Start Date

First
Professor
Composite Name
Last

12
Single-Valued and Multi-Valued
Attributes

 Single-Valued Attribute: An attribute that


holds a single value for each occurrence of an
entity type. E.g branchNo.
 Multi-Valued Attributes: An attribute that
holds multiple values for each occurrence of an
entity type. E.g telephoneNo.
Attributes (cont’d)

Single Professor Employee ID#

Multi-Valued Professor Email

14
Derived Attributes

 Derived Attributes: An attribute that


represents a value that is derivable from the
value of a related attribute or set of attributes,
not necessarily in the same entity type.
E.g attribute duration which value is derived
from the rentStart and rentFinish attributes.
Attributes (cont’d)

Stored Professor Start Date

Derived Professor Years Teaching

16
Keys
 Candidate Key (never NULL): The minimal set of
attributes that uniquely identifies each occurrence of an
entity type. E.g: branchNo in entity Branch.
 Primary Key: The candidate key that is selected to
uniquely identify each ocurrence of an entity type.
E.g:National Insurance Number.
 Composite Key: A candidate key that consist of two or
more attributes.
Primary Keys

Professor Employee ID

 Employee ID is the primary key


 Primary keys must be unique for the entity in
question

18
Relationship Types
 Relationship Type: A set of meaningful associations
among entity types.
 Relationship Occurrence: A uniquely identifiable
association, which includes one occurrence from each
participating entity type.

•First capital letter.


Has
Staff Branch •Only labeled in one
direction.
Branch has a Staff •Arrow symbol
Degree of Relationship Type
 Degree of Relationship type: the number of participating entity types in
a relationship.
 A relationship of degree two is called binary, a relationship of degree
three is called ternary...

Staff Solicitor
Registers Branch

Arranges Financial
Buyer Institution
Client
Bid
“Staff registers a client at a branch”
“A solicitor arranges a bid on behalf of a
buyer supported by a financial institution”
Recursive Relationship
 Recursive Relationship: A relationship type where
the same entity type participates more than once in
different roles.

Manages
Staff Branch
Has
Diagramatic Representation of
attributes
Primary Key

Staff Branch
satffNo {PK} Manages branchNo {PK}
Area to list name Address
attributes position street Composite
Has
salary/totalStaff city attribute
postcode
telNo[1..3]
Derived attribute

Multi-valued attribute
Strong and Weak Entity Types
 Strong Entity Type: An entity type that is not existence-
dependent on some other entity type.
 Weak Entity Type: An entity type that is existence-
dependent on some other type.
STRONG ENTITY WEAK ENTITY

Client Preference
States
clientNo {PK} prefType
name maxRent
fName
lName
telNo
Weak entity

 Weak entities do not have key attributes of their own.


 Weak entities cannot exist without another a relationship to
another entity.
 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

24
Weak entity

 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.
 Weak entities always have total participation as they cannot exist
without the identifying relationship.

25
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)
Weak Entity (cont’d)

Section
Section ID

Identifying Relationship part of

Number
Course
27
Cardinality and Participation
Constraints
 Cardinality: Describes the maximum number of
possible relationship occurrences for an entity
participating in a given relationship type. E.g: 1..1, 1..*,
*..*, etc,etc.
 Participation: Determines whether all or only some
entity occurrences participate in a relationship
(mandatory or optional).
Branch
Staff
Manages
staffNo 1..1 0..1 branchNo
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
Participation of an Entity Set in a
Relationship Set
Attributes on Relationships

since
name dname
ssn lot did budget

Employees Works_In Departments


Attributes on Relationships
 Attributes can also be assigned to relationships.

Newspaper Advertises ProperityForRent


newspaperName properityNo

•Dashed line!!

dateAdvert
cost

Cardinality Constraints
Multiplicity: The number (or range) of possible occurrences of an entity type that may relate to a single occurrence of
an associated entity type through a particular relationship.

 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 (1:1)
· One-to-many (1:*)
· Many-to-many (*:*)
One-to-One (1:1)
 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
One-to-Many (1:*)

Staff ProperityForRent
Oversees
staffNo 0..1 0..* properityNo

“Each properity for rent is “Each member of staff


overseen by zero or one oversees zero or more
member of staff” properitys for rent”
One-to-One (1:1)

Staff Branch
Manages
staffNo 1..1 0..1 branchNo

“Each branch is managed by “A member of staff can


manage zero or one branch”
One member of the staff”
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
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
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
Many-to-Many (*:*)

Newspaper ProperityForRent
Advertises
newspaperName 0..* 1..* properityNo

“Each properity for rent is “Each newspaper advertises


advertised in zero or more one or more properties for
newspapers” rent”
Specialization

 Top-down design process; we designate subgroupings within an


entity set that are distinctive from other entities in the set.
 These subgroupings 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.
Specialization Example
Generalization
 A bottom-up design process – combine a number of entity sets that share the
same features into a higher-level entity set.
 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.
Aggregation

name
 Used when we have to
ssn lot
model a relationship
involving (entity sets
Employees
and) a relationship set.
– Aggregation allows
us to treat a Monitors until
relationship set as an
entity set for
purposes of
participation in started_on since
dname
(other) relationships. pid pbudget budget
did

Projects Sponsors Departments


E-R Diagram With Aggregation
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
Aggregation (Cont.)

 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
Summary of Symbols Used in E-R Notation
Summary of Symbols (Cont.)
Alternative E-R Notations
E-R Diagram for a Banking Enterprise

You might also like