Professional Documents
Culture Documents
ERModel
ERModel
Enterprise
Scheme
Scheme
Real
RealWorld
World
Objects
Objectsofof
Interest
Interestto
tothe
the
Enterprise
Enterprise
Indira Thammishetty
Introduction
2
ER Model Basics
Entity
) Real world object distinguishable from other objects. An entity
in database is described using set of attributes.
) We represent entity as a rectangle. Person
Entity set
) Collection of similar entities. E.g. All employees
) All entities in an entity set have the same set of attributes.
) Each entity set has a key.
) Each attribute has a domain.
3
ER Model Basics (Contd.)
Student
Relationship
) Association among two or more entities.
) E.g. Mary works in IT Department Enrolls
) We represent relationship as rhombus.
Relationship set
) Collection of similar relationships. Courses
) An n-ary relationship set ‘R’ relates ‘N’ entity sets {E1, E2,
… EN}; each relationship in R involves entities e1 E1,
…en, EN.
) Same entity set could participate in different relationship
sets, or in different roles in same set.
4
ER Model Basics (Contd.)
Attribute
) This is a property of an entity.
) E.g. If there is an entity called as a person, then the attributes
can be name, age, date of birth etc.
) Pictorially an attribute is represented as an ellipse.
Person SSN
5
Keys
6
Types of Keys
Candidate keys
Super keys
Primary key
7
Foreign keys
8
Entity Sets customer and loan
customer-id customer- customer- customer- loan- amount
name street city number
9
Types of attributes
Simple and composite attributes
) Simple attributes are not divided into parts. Composite
attributes are those that can be divided into parts.
Ex: name of a person can be represented as first name,
last name, middle name
Single valued and multi valued attributes
) If an attribute has multiple values then it is called as multi
valued else it is a single valued attribute.
Ex: Person having a telephone (person can have many
telephone numbers)
Derived attributes
) Attributes that are derived from other attributes.
Ex: Age can be derived from the date of birth of a person.
10
Composite Attributes
11
E-R Diagram With Composite, Multivalued, and
Derived Attributes
12
Degree of a Relationship Set
13
E-R Diagrams
15
Cardinality Constraints
Since
SSN did
Figure 2
16
Cardinality Constraints (Contd.)
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
17
One-To-Many Relationship
18
Many-To-One Relationships
19
Many-To-Many Relationship
20
Participation of an Entity Set in a Relationship Set
21
Alternative Notation for Cardinality
Limits
Cardinality limits can also express participation constraints
22
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
23
Keys for Relationship Sets
24
E-R Diagram with a Ternary Relationship
25
Cardinality Constraints on Ternary
Relationship
We allow at most one arrow out of a ternary (or greater degree)
relationship to indicate a cardinality constraint
E.g. an arrow from works-on to job indicates each employee works
on at most one job at any branch.
26
Binary Vs. Non-Binary Relationships
Some relationships that appear to be non-binary may be better
represented using binary relationships
) E.g. A ternary relationship parents, relating a child to his/her father and
mother, is best replaced by two binary relationships, father and mother
Using two binary relationships allows partial information (e.g. only
mother being known)
) But there are some relationships that are naturally non-binary
E.g. works-on
27
Converting Non-Binary Relationships to
Binary Form
In general, any non-binary relationship can be represented using binary
relationships by creating an artificial entity set.
) Replace R between entity sets A, B and C by an entity set E, and three
relationship sets:
1. RA, relating E and A 2.RB, relating E and B
3. RC, relating E and C
) Create a special identifying attribute for E
) Add any attributes of R to E
) For each relationship (ai , bi , ci) in R, create
1. a new entity ei in the entity set E 2. add (ei , ai ) to RA
3. add (ei , bi ) to RB 4. add (ei , ci ) to RC
28
Weak Entity Sets
29
Weak Entity Sets (Cont.)
30
Weak Entity Sets (Contd.)
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
31
ISA (`is a’) Hierarchies
name
ssn lot
Employees
hourly_wages hours_worked
ISA
contractid
Hourly_Emps Contract_Emps
32
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
33
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
34
E-R Diagram With Aggregation
35
Summary of Symbols (Cont.)
36
E-R Diagram for a Banking Enterprise
37
Mail to: indira@msitprogram.net
Skype: indira_t
38