Conceptual / semantic modelling 1 Conceptual / semantic modelling
Mar 28, 2015
Conceptual / semantic modelling
1
Conceptual / semantic modelling
Conceptual / semantic modelling
2
Overview
design; conceptual design; ER model
• concepts;
• semantic aspects;
• problems;
• Enhanced ER (EER) modelling;
transforming an ER (EER) model into a relational model
Conceptual / semantic modelling
3
Design
you know the mechanics for building a database
system, but don’t know how to design it
Conceptual / semantic modelling
4
Design
requirements specification conceptual (semantic) design logical design physical design and implementation testing and validation maintenance
Conceptual / semantic modelling
5
Conceptual (semantic) design
constructing a model of the information used in an organisation
• independently of any targeted DBMS and of any physical considerations - high level of abstraction
• conceptual model - a more structured description (as opposed to a NL description)
• try to capture as much meaning as possible
model - constructed within a theory• terminology (ambiguity): model
most popular conceptual data model (theory)• ER (or E/R) model (theory) - Chen (1976)
• UML notation
Conceptual / semantic modelling
6
ER model
Concept Brief explanation Examples
entityany real world object(anything that has an individualexistence)
student, tutor, department,module, exam, project, plan,task
property something that describes an entity
(for student) name, address,age, fees paid, level of study;(for task) description,deadline;
relationshipa link that exist between twoentities
(student is) taught (module)by (tutor);(student) takes (exam);(project) includes (task)
attribute
Conceptual / semantic modelling
7
Concepts of the ER model
semantic, not formal• may be understood differently (by designers); results: different
models of the same real life system
• however, an ER model is a semi-formal description (see below)
not directly implementable• needs to be translated into an implementable model (e.g. the
relational model)
• why, then, doing it in the first instance?
symbolic level• formal description based on a set of informally defined concepts
• most popular: ER diagram
Conceptual / semantic modelling
8
Entity
entity type• a concept identified as having an independent existence
entity instance strong/regular entity type weak entity type
• its existence is dependent on some other entity types
examples• think ...
Conceptual / semantic modelling
9
ER diagram - entity (UML)
Student
Book-Loan
Student
studNo
Conceptual / semantic modelling
10
ER diagram - entity (before)
Student
Book-Loan
Customer
Account
Conceptual / semantic modelling
11
Attributes
a property/characteristic of an entity (or relationship) type instances of the same type have properties in common attribute domain
• should be included in a fully developed data model
attributes• simple / composite
• single-valued / multi-valued
• derived
• candidate key / primary key / composite key (note: no foreign key!)
Conceptual / semantic modelling
12
ER diagram - attributes (UML)
Student
name {PPK}dOB {PPK} day month yearsex/ageaddress no code city telNo[1..*]course/fees
Conceptual / semantic modelling
13
ER diagram - attributes (before)
year month day
date-of-birthname sex age
personal-details
Student
address
no code city tel-no
course fees
Conceptual / semantic modelling
14
Relationships
do not mistake with relation (in the relational model) relationship type
• a (meaningful) association between entity types
• participants - the entities involved in the relationship
relationship instance degree
• number of participating entities (types)
• binary
• ternary, quaternary …
• recursive
Conceptual / semantic modelling
15
ER diagram - binary relationships (UML)
Student
name dOB
Book
TitleAuthorEdition
Borrows
Department
name
Belongs To
Conceptual / semantic modelling
16
ER diagram - binary relationships (before)
Student
Book-Loan Department
has belongs to
Conceptual / semantic modelling
17
ER diagram - ternary relationship (UML)
Student
name dOB
Module
code
Lecturer
name
Teach
Conceptual / semantic modelling
18
ER diagram - recursive relationships (UML)
Represents
Representative
Represented
Student
name dOB
Conceptual / semantic modelling
19
ER diagram - more than one relationship between two entities
Staff
name dOB
Department
name
HeadofDepartment
Member
Manages
BelongsTo
Conceptual / semantic modelling
20
ER diagram - relationships with attributes (UML)
Staff
name dOB
Department
name
IsAffiliatedTo
dateposition
Conceptual / semantic modelling
21
ER diagram - relationships with attributes (before)
Staff Departmentis affiliated to
member of staff
date duration position
Conceptual / semantic modelling
22
Structural constraints on relationships
cardinality constraints multiplicity
• cardinality
• participation
relevant to all possibilities - i.e., not to a certain extension
Conceptual / semantic modelling
23
Structural constraints on relationships (UML)
Student
name dOB
Room
hallno
Tutor
name
Rents
Advises
Teaches
0..1 0..1
0..*
1
0..*
1..*
Conceptual / semantic modelling
24
ER diagram - structural constraints (before)
rented_house
tenant
rents
1
M
landlord
owns
M
N
house history
has
1
1
Conceptual / semantic modelling
25
Problems with ER models
connection traps• a link between two entities seems to have been represented via
another entity, but the actual model does not capture that
fan traps• symbolically: two (1:M) relationships fan out of an entity
• it is not always a trap
chasm traps• symbolically: a pathway representing a link contains a
relationship with a partial participation
a good understanding of the application is required
Conceptual / semantic modelling
26
ER diagram - fan trap
Student
name dOB
Course
code
Project
name
Attends
1..*
1
Proposes
1..*
1
Conceptual / semantic modelling
27
ER diagram - fan trap explanation
Fine Arts
Ann Boyle
Chris Evans
Monica Black
Colour and Depth
Mixed Media in Modern Art
Humour in Modern Art
has members proposes
these relationships are not represented
Conceptual / semantic modelling
28
ER diagram - solution to a fan trap
Student
name dOB
Course
hallno
Project
name
Attends Takes
1..* 1..*
11
can you think of another solution?
Conceptual / semantic modelling
29
ER diagram - chasm trap
Project
name
Course
hallno
Student
namedOB
Proposes Takes
1..* 0..1
0..*1
Conceptual / semantic modelling
30
ER diagram - solution to a chasm trap
why not always represent all the relationships?
Project
name
Course
hallno
Student
namedOB
Proposes Takes
1..* 0..1
0..*1
Attends 1..*1
Conceptual / semantic modelling
31
The Enhanced ER model (EER)
additional semantic modelling concepts• for “richer” (more comprehensive) representations
type hierarchies specialisation / generalisation subclass / superclass attribute inheritance
aggregation hierarchies aggregation composition
Conceptual / semantic modelling
32
Specialisation / generalisation
equivalent names:• specialisation hierarchy, generalisation hierarchy or IS-A
hierarchy
specialisation• identifying classes among the instances of an entity type, by
identifying distinguishing properties (attributes);
• a top down approach
generalisation• grouping entity types into one single class, by disregarding
differentiating properties (attributes)
• a bottom up approach
attribute inheritance
Conceptual / semantic modelling
33
Specialisation / generalisation
Staff
empNo {PK}namesalaryposition
Manager
experiencebonus
Developer
languageprojects
Support
area
SalesStaff
specialitysales
Conceptual / semantic modelling
34
Specialisation / generalisation
Staff
empNo {PK}namesalaryposition
Manager
experiencebonus
Developerlanguageprojects
Supportarea
SalesStaff
specialitysales
FullTime
notice
PartTime
workLoadjobLevel
Conceptual / semantic modelling
35
Constraints
overlapping of the child subclasses• disjoint - {OR}
• overlapping - {AND}
participation of the parent superclass• total - {Mandatory}
• partial - {Optional}
Conceptual / semantic modelling
36
Constraints
Staff
empNo {PK}namesalaryposition
Manager
experiencebonus
Developerlanguageprojects
Supportarea
SalesStaff
specialitysales
FullTime
notice
PartTime
workLoadjobLevel
{Optional, OR} {Mandatory, OR}
Conceptual / semantic modelling
37
Specialisation / generalisationmore than one parent
Manager
experiencebonus
SalesStaff
specialitysales
SalesManager
target
{Optional}
child inherits attributes of both parents
Conceptual / semantic modelling
38
Aggregation
Course
code
Module
code
Staff
name
Student
namedOB
Supports IsRegisteredFor
0..*
1..* 1..*
0..* 1..1
0..*
Conceptual / semantic modelling
39
Composition
Account
no
Agreement
textdate
Overdraft
dateValidUntilamount
Transaction
datetypeamount
1..1
1..1 1..*
1..1 1..1
0..*
Conceptual / semantic modelling
40
Summary
conceptual model ER Model
entity attribute relationship
• multiplicity
traps
EER model generalisation/specialisation
• constraints
aggregation