You are on page 1of 10

ER diagram of Branch user

Chapter 5. Entity Relationship views of DreamHome


Modeling

Introduction
Concepts of the ER Model
Structural Constraints
Problems with ER Models
Enhanced Entity Relationship Modeling

Copyright ® Arni Yusnita Abdul Rahman 2010

Introduction
high-level conceptual data model to facilitate
high- used to describe data in external level.
database design.
independent of the particular DBMS & hardware
developed by Peter Chen (1976).
platform.
purpose :-:-
using UML (Unified Modeling Language) notations.
a) support a user’s perception of data.
UML à modeling language created to represent
b) to conceal the more technical aspects project areas developed using the object-
object-oriented
associated with database design. method.
c) identify the processes and constraints. extended ER Model ---->
> Enhanced Entity
d) to implement the database. Relationship Modeling (EER).
e) produce consistent and non-
non-redundancy
model.

Concepts of the ER Model Entity types


“group of objects with same properties,
based on a real event in an organization.
identified by enterprise as having an
3 basic concepts of E-E-R model :-
:-
independent existence.”
existence.”
a) entity types
b) relationship types represents a set of ‘objects’ in the ‘real world’
c) attributes (physical) @ conceptual (abstract) with same
properties.
ENTITY – an object or concept that is uniquely
identifiable.
important objects in information system.

1
Examples of Entity Types entity notation à
e.g::-
e.g
Ali,
Amin, event
Raju,
Chong

modelled as

Staff
Entity

divided to 2 types of entities :-


:- e.g. :-
:-
a) strong entity type Next_
Student has
- an entity type that is not existence
existence--dependent of_kin

on some other entity type. in UML notation, there is no difference between


- e.g. : employee, student, patient, client strong and weak entities.
- known as parents @ dominant.
b) weak entity type
- an entity type that is existence-
existence-dependent on
some other entity type.
- known as child @ subordinate.
- e.g. : next_of_kin
next_of_kin,, preferences

Relationship Types e.g :


“set of meaningful associations among entity
types.”
types .”
relationship occurrence – uniquely identifiable relationship above known as ‘HAS
‘HAS--A’ relationship.
relationship.
association, which includes one occurrence
shown using the semantic net.
from each participating entity type.
type. semantic net – an object-
object-level model, which uses
• each relationship is given a name that describe its the symbol • to represent entities and the symbol
function and shown as a line connecting the • to represent relationships.
associated entity types.
• a relationship is named using a verb (Supervises
(Supervises
or Manages
Manages)) or short phrase including a verb
(LeasedBy
LeasedBy)) written on the top of the relationship
line.

2
Relationship Types l two is binary

Degree of a Relationship
Number of participating entities in relationship.

Relationship of degree :
l recursive relationship l three is ternary
relationship type where same entity type
participates more than once in different
roles.

Entities associated through two


distinct relationships with role
l four is quaternary.
names

Attributes using the UML notation, the attributes’ name are


written in a rectangle below the entity’s name.
“a property of an entity or a relationship type.”
type.” for attribute chosen as a primary key, will be
tagged as PK at the end of the attribute’s name.
the name given must be unique. also known as key attribute.
attribute.
e.g. : name, IC_no
IC_no,, address, date_of_birth etc. other tags such as : PPK(Partial
PPK(Partial Primary Key),
Key),
5 types of attributes:-
attributes:- AK(Alternate
AK( Alternate Key
Key))

AD

SA SVA

CA MVA
DA
Diagram
Representation

3
Attribute Domain Simple Attribute
“set of allowable values for one or more “attribute composed of a single component with
attributes. “
an independent existence.
existence.”
e.g.: domain for staff_no is integer range from
1 - 5000; domain for name is text 1 - 25. e.g. : sex, name, salary etc.
different attribute can share same domain. known as atomic attributes.
e.g.: name & department
domain for date_of_birth
à subdomain : day, months, year.

Composite Attribute Derived Attribute


“attribute composed of multiple components, “attribute that represents a value that is derivable
each with an independent existence.” from value of a related attribute, or set of
house no
attributes, not necessarily in the same entity
e.g : address street name
type..”
type
town
state district
symbol used is ‘ / ’ before the attribute name.
e.g. : age can be derived from date of birth

Derived attribute
Basic attribute

Multi--valued Attribute
Multi Single--valued Attribute
Single

“attribute that holds multiple values for each “attribute that holds a single value for each
occurrence of an entity type.”
type.” occurrence of an entity type.”
type.”

have a set of numbers with upper and lower limit. can consists of simple attribute/composite.
put in a square bracket at the end of the attribute’s e.g. : student_no, ICno, staff_no etc.
name.
e.g. :-
:- no_tel [1..3]

4
Attributes on Relationships
Student
can have attribute to describe the relationship.
studNo {PK} represented by dotted line.
Primary Key -
name Alternate Key -
icNo {AK} Composite Attribute -
Derived Attribute -
dob Multi-Valued Attribute -

address
houseNo
street
city
telNo [1..3]
course
/age

Relational keys b) primary key


“a data item that allows us to uniquely identify - an entity type may have one or more possible
individual occurrences of an entity type.”
type.” candidate keys, one of which is selected to
be the primary key.
the value must be unique and not null.
- e.g.: staffno and ICno
underline the key in E-
E-R model. alternate key
primary key
divided to 3 type of keys :-
:-
- the choice of primary key based on :- :-
a) candidate key i) consideration of attribute length
- minimal set of attributes that uniquely (minimal number of attributes required)
identifies each occurrence of an entity type. ii) current and future certainty of uniqueness
- e.g. : branch_no
branch_no,, staffno and ICno
ICno..

c) composite key Structural Constraints


- attribute composed of multiple components,
each with an independent existence.
existence. main type of constraint on relationships is called
- e.g. : multiplicity.
multiplicity - number (or range) of possible
Advertisement (property_no
(property_no,, newspaper_name
newspaper_name,, occurrences of an entity type that may relate
date, cost) to a single occurrence of an associated entity
property_no,, newspaper_name
property_no newspaper_name,, date type through a particular relationship.
relationship.
stated in a form of numbers @ range at the end of
composite keys
the relationship.
represents policies (called business rules)
established by user or company.

5
Semantic net of Staff Manages Branch
the most common degree for relationships is
binary. relationship type
binary relationships are generally referred to as
being:
l one
one--to
to--one (1:1)
l one
one--to
to--many (1:*)
l many
many--to
to--many (*:*)

Semantic net of Staff Oversees Semantic net of Newspaper Advertises


PropertyForRent relationship type PropertyForRent relationship type

Semantic net of ternary Registers


relationship with values for Staff and
multiplicity for Complex Relationships Branch entities fixed
l number (or range) of possible occurrences of

an entity type in an n-ary relationship when


other (n
(n-1) values are fixed.

6
Summary of multiplicity constraints
multiplicity is made up of two types of restrictions
on relationships: cardinality and participation
participation..
cardinality
l describes maximum number of possible
relationship occurrences for an entity
participating in a given relationship type.
most common degree for relationship - binary.
cardinality ratio – determine the number of
possible relationships for each participating entity.
ratio :-
:- 1:1 , 1:* & *:*

participation ii) partial (optional)


l determines whether all or only some entity - the existence of an entity does not require the
l occurrences participate in a relationship. occurrence of an associated entity in a
l divided to 2 parts : particular relationship.
i) total (mandatory) - will be represented by value of 0.
- if only parts of the entity in E participates in
- if an entity’s existence requires the
relationship H, therefore the participation of
occurrence of an associated entity in a
entity set E in H is partial.
particular relationship.
relationship.
- will be represented by value of 1.
- participation a set of entity E in a set of
relationship H is total if each entity in E
participates in at least one relationship of H.

Problems with ER Models An Example of a Fan Trap

problems may arise when designing a conceptual


data model called connection traps.
traps.
often due to a misinterpretation of the meaning of
certain relationships. there are 2 1:* relationships (Has and Operates)
two main types of connection traps are called fan emanating from the same entity called Division.
traps and chasm traps
traps.. problem arises when we want to know which
Fan Trap members of staff work at a particular branch.
l where a model represents a relationship
examine some occurrences of the Has and
Operates relationships using values for the
between entity types, but pathway between
primary key attributes of the Staff, Division and
certain entity occurrences is ambiguous. Branch entity types.
l exists where two or more 1:* relationships fan
out from the same entity.

7
Semantic Net of ER Model with Fan resolve the problem by restructuring the original
Trap ER model to represent the correct association
between the entities.

SG37 works at branch


B003 which is part of
At which branch office does staff number SG37 division D1.
work?

Chasm Trap examine some occurrences of the Has and


l where a model suggests the existence of a Oversees relationships using values for the primary
relationship between entity types, but pathway key attribute of the Branch, Staff and
does not exist between certain entity PropertyForRent entity types.
occurrences.
l occur when there are one or more relationships
with a minimum multiplicity of zero forming part
of the pathway between related entities.
l e.g. :-
:-

At which branch office is property PA14 available?


l problem occurs when we want to know which
properties are available at each branch.

to solve the problem, need to identify the missing Enhanced Entity-


Entity-Relationship Model
relationships between two entities which in this
case is the Offers relationship between the Branch since 1980s there has been an increase in
and PropertyForRent entities. emergence of new database applications with
more demanding requirements.
basic concepts of ER modeling are not sufficient
to represent requirements of newer, more
complex applications.
response is development of additional ‘semantic’
modeling concepts.
PA14 is available semantic concepts are incorporated into the
at branch number original ER model and called the Enhanced
B007.
Entity--Relationship (EER) model.
Entity
examples of additional concept of EER model is
called specialization / generalization.
generalization.

8
Specialization / Generalization
Superclass Attribute Inheritance
l An entity type that includes one or more distinct l An entity in a subclass represents same ‘real
subgroupings of its occurrences. world’ object as in superclass, and may
possess subclass-
subclass-specific attributes, as well as
Subclass those associated with the superclass.
l A distinct subgrouping of occurrences of an Specialization
entity type. l Process of maximizing differences between
members of an entity by identifying their
Superclass/subclass relationship is (1:1). distinguishing characteristics.
l e.g. subclass professor has the car allowance
Superclass may contain overlapping or distinct attribute while the subclass administrator has
subclasses. bonus attribute.
Not all members of a superclass need to be a
member of a subclass.

Specialization/generalization of Staff
entity into subclasses representing
job roles
Generalization
l Process of minimizing differences between
entities by identifying their common
characteristics..
characteristics
l e.g. subclass professor & subclass

administrator have the same attribute


à staffno

Constraints on Specialization / Constraints on Specialization /


Generalization Generalization
Two constraints that may apply to a Disjoint constraint
specialization/generalization: l Describes relationship between members of the

l participation constraints
subclasses and indicates whether member of a
superclass can be a member of one, or more
l disjoint constraints.
than one, subclass.
l May be disjoint or nondisjoint
nondisjoint..
Participation constraint
There are four categories of constraints of
l Determines whether every member in
specialization and generalization:
superclass must participate as a member of a
l mandatory and disjoint
subclass.
l optional and disjoint
l May be mandatory or optional
optional..
l mandatory and nondisjoint
l optional and nondisjoint.
nondisjoint.

9
DreamHome worked example - Owner
Superclass with PrivateOwner and
BusinessOwner subclasses

10

You might also like