Lecture 4
Lecture 4
Lecture 4
• Basic literature
• [Barker II] Barker R., CASE*Method: Entity Relationship
Modelling, Addison-Wesley Pub. Comp., 1991
• Additional literature
• [Date] Date C.J., An introduction to database systems,
Addison-Wesley Pub. Comp., 1986
GHJ-PWR 1
DETAILED DEFINITION AND ADDITION TO
PRINCIPLES OF INFORMATION MODELING
GHJ-PWR 2
BUSINESS RULES ENFORCEMENT
GHJ-PWR 3
DETAILED DEFINITION OF ATTRIBUTE SUMMARY
1 number no N num 3 Y
2 name and name N char 25 N
surname
3 date of birth date N date 8 N
4 profession N char 20 N
5 address Y char 50 N 4
GHJ-PWR
DOMAIN DEFINITION
GHJ-PWR 5
DETAILED RELATIONSHIP DEFINITION SUMMARY
belongs to
ACCOUNT PERSON
# code
(5)
has got
# number
ORGANIZATION
owner of # code
owned by
GHJ-PWR 7
REFERENCE INTEGRITY CONSTRAINTS
GHJ-PWR 8
CASCADE DELETE
• Cascade delete
• when we lose all knowledge of something
EMPLOYEE assigned to
DEPARTMENT
# symbol # number
* name responsible for * name
* address * telephone number
C – deletes all children if a parent is deleted
EMPLOYEEs only exist within the context of a DEPARTMENT
Lynne
Dept 50 Robert
Harriet
before delete after delete
SEPARATE DELETION - EXAMPLE
EMPLOYEE assigned to
DEPARTMENT
# symbol # number
* name responsible for * name
* address * telephone number
EMPLOYEE assigned to
DEPARTMENT
# symbol # number
* name responsible for * name
* address * telephone number
EMPLOYEE assigned to
DEPARTMENT
# symbol # number
* name responsible for * name
* address * telephone number
Lynne
Dept 50 Robert Dept 48
Harriet
before update after update
GHJ-PWR 13
NON-TRANSFERABLE RELATIONSHIP
the owner of
CUSTOMER ACCOUNT
owned by
GHJ-PWR 14
Business cohesion rules - to enforce through
application code
PURCHASE ORDER
source at
# number # number
* date source of * from date
* value * total amount
GHJ-PWR 16
INHERITANCE – THE HIERARCHY
PROPERTY
GHJ-PWR 17
Illustrate the generalization
VEHICLE
BOAT Super-types
MOTORCAR
Sub-types are represented
as divisions of the entity TRACK
box, where each division Sub-types
corresponds to a sub-type. CAR
AEROPLANE
AIRCRAFT
[CASE*Method]
GLIDER
GHJ-PWR 18
SUB-TYPE RULES
GHJ-PWR 19
INSTANCES OF AN ENTITY IN A SUPER-
TYPE
GHJ-PWR 20
EXCLUSION AND EXHAUSTION IN
GENERALIZATION HIERARCHY
GHJ-PWR 21
Not exhaustion case
VEHICLE
BOAT
MOTORCAR
A non exhaustive hierarchy
is one where TRACK added sub-type
a super-type instance may exist
that is not an instance CAR
of one of the defined subtypes
OTHER VEHICLE
AEROPLANE
AIRCRAFT
GLIDER
CASE*Method
GHJ-PWR 22
Exclusive relationship and it’s representation
From the same entity type two or more relationship may be mutually exclusive.
An exclusive arc
belongs to
ACCOUNT PERSON
# code
has got
# number owned by
ORGANIZATION
# code
owner of
This means that each ACCOUNT must either belong to one and only one
PERSON or be owned by one and only one ORGANIZATION.
But never a combination [Barker II, pp. 4-3].
GHJ-PWR 23
RULES OF AN EXCLUSIVE ARC
GHJ-PWR 24
REDUNDANT RELATIONSHIP
• An Entity Relationship Diagram should not have any relationship that can, in all
circumstances, be derived from other relationship [Barker II, pp. 7-14]
• The relationship between a customer and a bank is derived from two relationships:
every customer must be the owner of one or more accounts and every account is
operated by one and only one bank.
the owner of
CUSTOMER ACCOUNT
owned by
operated by
BANK
the referenced for
GHJ-PWR 25
CLASSICAL STRUCTURES
GHJ-PWR 26
CHANGES OVER TIME: ATTRIBUTE CHANGES
[BARKER II, P.8.9]
a) before b) after
CONTRACT STATUS
# * date # * from date
* status * value
o to date
The attribute status
becomes an entity type of
Business questions:
shown in
What was the previous status of the contract?
CONTRACT
Can a contract ever be in various state on the same
# * number
day?
# * date
GHJ-PWR 27
CHANGES OVER TIME : RELATIONSHIP CHANGES
[BARKER II, P.8.10]
a) before b) after
for
COMPANY CAR CONTRACT COMPANY CAR
# * date # * symbol
# * symbol
o termination
* date the subject of
date
assigned to with
Adding a new entity to cater
for a relationship change – this
the driver of a party to
entity is the many to many
EMPLOYEE relationship solution through
EMPLOYEE
# code the intersection entity
# code
Business question:
Who was the previous driver of the company car?
GHJ-PWR 28
BILL OF MATERIALS: IMPLOSION/EXPLOSION
[BARKER II, P.8.10-8.11]
b) An intersection entity
a) Many to Many
STANDARD
CONSTITUENT
PART/PRODUCT made up of o quantity
# * code o fitting instruction
* name
* description on the parts
for use of
list for
used as made up of
used within
PART/PRODUCT
Business questions:
# * code
* name
Which parts are used in different products ?
* description
What are products and parts made of ?
GHJ-PWR 29
CLASSIFICATION
[BARKER II, PP. 8.12-8.13]
CLOTHES
a) simple
# * code Classification entity
Classification attribute * name implements coded
* size classification
b) coded classification
in
CLOTHES SIZE
# * code # * value
the classification
* name * description
for
ORGANIZATION
UNIT
# code within
Classification attribute * name
* type
made up of
The entity type ORGANIZATION UNIT with a recursive relationship fulfills the
disadvantages of the previous model:
direct links are possible between different organizational structures
the addition of any organization unit type
Business question:
Which type of organizational units is at the top of the hierarchy?
GHJ-PWR 32
HIERARCHY – ALTERNATIVE 2
ORGANIZATION UNIT
Sub-types of the # code
organization unit * name
within
STRUCTURE
ELEMENT
PRODUCT
# * code
for * name
INVOICE ITEM
* vat
# * number shown on
* net price GOODS
o quantity * unit of measure Sub-types for
two possible
part of SERVICE kinds of items
o comment
Intersection
entity made up of
placed on COMPANY
INVOICE # * symbol This entity can be
a party to divided into two
# * number * name
placed by sub-types: SUPPLIER
* date * city
and RECIPIENT
* zip code
the source of
* street
Two relationships o phone
showing both participants
GHJ-PWR in one sale 34
QUESTIONS TO HELP YOU L4 STUDY
GHJ - PWR 35
QUESTIONS TO HELP YOU L4 STUDY (CONT.)
12. Explain by example, an exclusion between sub - types in generalization
concept
13. Explain by example, an exhaustion of a super -type in generalization
concept
14. What are rules of an exclusive arc?
15. When the relationship between entity types non-transferable is?
16. If exists a requirement to remember all changing values of a price, how to
transform an entity model: (PRODUCT, code, name, price)?
17. If exists a requirement to remember all changing users of every computer,
how to transform an entity relationship model: Every EMPLOYEE is a user of
one or more COMPUTER?
18. What are different ways of the presentation of a formal entity classification
on the ERD? (CAR, brand)
19. What are the ways to represent hierarchical relationships between entity
types on an ERD? (SOLDIER, military degree). What are the typical
advantages and disadvantages of each of them?
GHJ - PWR 36