Topic4 ERM
Topic4 ERM
SECD2523 Database
Semester 1 2020/2021
SCSD2523 Database - Entity Relationship Modeling
Learning Objective
• At the end of the topic, students will be able to:
• Define basic concepts associated with ER diagram
• Produce ER model to represent information to application system.
14-Oct-21 2
SCSD2523 Database - Entity Relationship Modeling
ORGANIZATIO N
o EMAIL
* NAME
o POSTAL CODE
at o REGION
o STREET
o TOWN p aren t o rga nizatio n o f
o TELEPHONE N UMBER
TITLE MOV IE o CO NTACT NAME
# PRODUCT CODE * CATEGORY o CO NTACT EXTENSION
* TITLE o AGE RATING
• Is a well-established technique
o DESCRIPTION * DUR ATION the
* MON OCHROME GAME
o AUD IO * CATEGORY distributo r fo
o PREVIEW * MEDIUM SUPPL IER
o MINIMUM MEMORY r # SUPPLIER CODE
o EMAIL
available * APPROVED
fo r * REFERENCE
from
PRICE HISTO RY
the source of
# EFFECTIVE DATE re viewed in available as on
* PRICE
* DEFAULT DAYS
* OVERDUE RATE
PUBL ICATION
# REFER ENCE CATALO G the holder o
* TITLE # REFER ENCE
o VOLUME o CATALOG DATE f
o ISSUE o DESCRIPTION CUSTOME R
o PUBLISH DATE o EMAIL
ma na ge d by
* DESIGNATION
* FIRST NAME
COPY
at first sight
held by the typ e o
held by f
in of
in of
MEMBERS HIP
REVIEW # NU MBER
# SEQ UENCE o TERMINATIO N REASON
* ARTICLE o TERMINATIO N DATE
* HOT
o AUTHO R approved by
o UR L
re ne wed f o use d fo
the reservatio n fo r r r
cancelle d by
fo r
re quested authorized by of
against
the
BOO KING MEMBERS HIP PERIOD
* BOOK DATE re questor # START DATE
o EXPIRE D ATE o ACTUAL FEE PAID
o NO TIFY DATE of
o RESERVE DATE
o STAFF R EMARKS
approved by fo r
fulf illed as
RENTAL
* RENTAL DATE
o STAFF R EMARKS
o CO MPLETED
composed o f
14-Oct-21 3
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 4
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 5
SCSD2523 Database - Entity Relationship Modeling
ER Modelling Notations
UML Notation Chen’s Notation Crow’s Feet Notation
14-Oct-21 6
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 7
SCSD2523 Database - Entity Relationship Modeling
Entity Types
• Entity types
• Group of objects with same properties, identified by enterprise as having an independent existence.
• “Something” of significance to the business about which data must be known
• A name for the things that you can list
• Usually a noun
• Entity occurrence/instances
• Uniquely identifiable object of an entity type.
14-Oct-21 8
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 9
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 10
SCSD2523 Database - Entity Relationship Modeling
Set of instances of
manager entity JOB
JOB cook
waitress
dish washer
financial controller
porter
entity waiter piano player
14-Oct-21 11
SCSD2523 Database - Entity Relationship Modeling
ELECTION
• Name singular
• Name inside TICKET
• Neither size, ORDER
RESERVATION
nor position
has a special JOB ASSIGNMENT
meaning
During design, entities usually lead to tables.
14-Oct-21 12
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 13
SCSD2523 Database - Entity Relationship Modeling
Relationship
• Relationship type
• Set of meaningful associations among entity types.
• Express how entities are mutually related
• Always exist between two entities (or one entity twice)
• Relationship occurrence
• Uniquely identifiable association, which includes one occurrence from each participating entity type.
14-Oct-21 14
SCSD2523 Database - Entity Relationship Modeling
Relationship Examples
• BRANCH has STAFF
STAFF belongs to BRANCH
• EMPLOYEES have JOBS
JOBS are held by EMPLOYEES
• PEOPLE make TICKET RESERVATIONS
TICKET RESERVATIONS are made by PEOPLE
14-Oct-21 15
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 16
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 17
SCSD2523 Database - Entity Relationship Modeling
Numerical observation:
Whether all these are true, it all
• All EMPLOYEES have a JOB
depends on business rules
• No EMPLOYEE has more than one JOB
• Not all JOBS are held by an EMPLOYEE
• Some JOBS are held by more than one EMPLOYEE
14-Oct-21 18
SCSD2523 Database - Entity Relationship Modeling
HAVE
EMPLOYEES JOBS
14-Oct-21 19
SCSD2523 Database - Entity Relationship Modeling
Relationship Types
• Degree of a Relationship
• Number of participating entities in relationship.
• Degree of relationship:
• two entities binary;
• three entities ternary;
• four entities quaternary.
14-Oct-21 20
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 21
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 22
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 23
SCSD2523 Database - Entity Relationship Modeling
Relationship Types
• Recursive Relationship
• Relationship type where same entity type participates more than once in different roles.
• Relationships may be given role names to indicate purpose that each participating entity
type plays in a relationship.
14-Oct-21 24
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 25
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 26
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 27
SCSD2523 Database - Entity Relationship Modeling
Attributes
• Attribute
• Also represents something of significance to the business
• Is a specific piece of information that:
• Describes
• Quantifies
• Qualifies
• Classifies
• Specifies an entity
• Is a property of an entity or a relationship type.
• Attribute Domain
• Set of allowable values for one or more attributes.
14-Oct-21 28
SCSD2523 Database - Entity Relationship Modeling
Attribute examples
14-Oct-21 29
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 30
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 31
SCSD2523 Database - Entity Relationship Modeling
Attribute (Derived)
• Derived Attribute
• Attribute that represents a value that is derivable from value of a related attribute, or set of
attributes, not necessarily in the same entity type.
• E.g.: the value for the duration attribute of the Lease entity is calculated from the rentStart and
rentFinish attributes, also of the Lease entity type.
14-Oct-21 32
SCSD2523 Database - Entity Relationship Modeling
Practice 2 (Problem 1)
• Identify all attributes for each entity identified in Practice 1.
• Can you determine the type of each attribute?
14-Oct-21 33
SCSD2523 Database - Entity Relationship Modeling
Attribute: Keys
• Candidate Key
• Minimal set of attributes that uniquely identifies each occurrence of an entity type.
• Composite Key
• A candidate key that consists of two or more attributes.
• Primary Key
• Candidate key selected to uniquely identify each occurrence of an entity type.
14-Oct-21 34
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 35
SCSD2523 Database - Entity Relationship Modeling
Practice 3 (Problem 1)
• Identify the primary key for each entity.
14-Oct-21 36
SCSD2523 Database - Entity Relationship Modeling
Entity Type
• Strong Entity Type
• Entity type that is not existence-dependent on some other entity type.
• Characteristic:
• Each entity occurrence is uniquely identifiable using PK attribute of the entity type
• Weak Entity Type
• Entity type that is existence-dependent on some other entity type.
• Characteristic:
• Each entity occurrence cannot be uniquely identified using attributes associated with the entity type
14-Oct-21 37
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 38
SCSD2523 Database - Entity Relationship Modeling
When to have
relationship with
attributes?
14-Oct-21 39
SCSD2523 Database - Entity Relationship Modeling
Structural Constraints
• Main type of constraint on relationships is called multiplicity.
• Multiplicity: 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.
• Constrains the way the entities are related in the relationship
• Represents policies (called business rules) established by user or company.
14-Oct-21 40
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 41
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 42
SCSD2523 Database - Entity Relationship Modeling
Multiplicity of Manages relationship is one-to-one (1:1) shown through the maximum range value
on the multiplicities at both ends of relationship
14-Oct-21 43
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 44
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 46
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 47
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 48
SCSD2523 Database - Entity Relationship Modeling
Semantic Net: Ternary Registers Relationship with Values for Staff and Branch
Entities Fixed
14-Oct-21 49
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 50
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 51
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 52
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 53
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 54
SCSD2523 Database - Entity Relationship Modeling
Practice 4: Problem 1
• Complete the ERD for the problem by:
• Determine whether the entities are strong entity or weak entity;
• Determine the multiplicity and structural constraints (cardinality and participation) for each
relationship in the diagram
14-Oct-21 55
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 56
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 57
SCSD2523 Database - Entity Relationship Modeling
14-Oct-21 58