Ch 3 Conceptual Modeling – First Steps ORM is a method for

Ch 3 Conceptual Modeling – First Steps
ORM is a method for
• modeling an information system at the conceptual level
• querying an information system at the conceptual level
• mapping between conceptual and other levels.
Chapter 3
• overview of ORM’s conceptual schema design procedure
• detailed discussion of the first three steps in this procedure.
Winter 2015
ACS-4906
Ron McFadyen
1
Ch 3 Conceptual Modeling – First Steps
Some remarks:
One basic question is whether to use the attribute concept as a
primitive modeling construct.
ORM uses relationships instead of attributes in order to
facilitate capturing, validating, and evolving the conceptual
schema,
…while still allowing compact attribute-views to be
automatically derived for summary or implementation
purposes.
Winter 2015
ACS-4906
Ron McFadyen
2
Ch 3 CSDP
Overall approach:
•
Divide the universe of discourse into manageable subareas.
•
Apply the CSDP to each subarea.
•
Integrate the subschemas into a global conceptual schema.
Conceptual Schema Design Procedure (CSDP)
1.
2.
3.
4.
5.
6.
7.
Transform familiar examples into elementary facts.
Draw the fact types, and apply a population check.
Check for entity types to be combined, and note any arithmetic derivations.
Add uniqueness constraints, and check the arity of fact types.
Add mandatory role constraints, and check for logical derivations.
Add value, set-comparison, and subtyping constraints.
Add other constraints and perform final checks.
Winter 2015
ACS-4906
Ron McFadyen
3
Step 1: From Examples to Elementary Facts
If you want to get the data model right, start with examples
of the data to be delivered by the system.
By analogy with the UML term, we call these “data use
cases”, since they are cases of data being used.
If you ever do use UML’s process use cases to drive the
modeling process, you should at least flesh them out with
data samples before working on the class diagrams.
Winter 2015
ACS-4906
Ron McFadyen
4
Step 1: From Examples to Elementary Facts
examples of data use cases: output reports, input forms, and
sample queries.
These might appear as tables, forms, diagrams, or text.
Winter 2015
ACS-4906
Ron McFadyen
5
Step 1: From Examples to Elementary Facts
elementary fact : a simple assertion, or atomic proposition,
about the UoD.
The word “fact” indicates that the assertion is taken to be true
by users in that business domain.
Winter 2015
ACS-4906
Ron McFadyen
6
Step 1: From Examples to Elementary Facts
We think of the UoD as a set of objects playing roles.
Elementary facts are assertions that particular objects play
particular roles.
simplest … a single object plays a given role.
e.g. consider a small domain in which people are identified
by their first names. One fact about this domain might be:
1.
Winter 2015
Ann smokes.
ACS-4906
Ron McFadyen
7
Step 1: From Examples to Elementary Facts
Usually a relationship involves at least two roles.
example:
2.
3.
Ann employs Bob.
Ann employs Ann.
In general, an elementary fact asserts that a particular object
has a property, or that one or more objects participate
together in a relationship.
Winter 2015
ACS-4906
Ron McFadyen
8
Step 1: From Examples to Elementary Facts
Elementary indicates the fact cannot be split into smaller units
of information that provide the same information as the
original.
Elementary facts usually do not use logical connectives (e.g.,
not, and, or, if) or logical quantifiers (e.g., all, some).
For example, sentences (4)–(9) are not elementary facts.
4.
5.
6.
7.
8.
9.
Winter 2015
Ann smokes and Bob smokes.
Ann smokes or Bob smokes.
Ann does not smoke.
If Bob smokes then Bob is cancer prone.
All people who smoke are cancer prone.
If some person smokes then that person is cancer prone.
ACS-4906
Ron McFadyen
9
Step 1: From Examples to Elementary Facts
Initially we consider only basic objects: these are either
values or entities.
A value is a constant that is self-identifying in the sense that
when you see the constant written down in some context you
always know what is being referred to.
Values are constants (typically character strings or numbers).
As a result, values can be referenced directly, without
needing to identify them with a description.
Winter 2015
ACS-4906
Ron McFadyen
10
Step 1: From Examples to Elementary Facts
Entities
Since humans may misinterpret, and information systems lack
any creativity to add context, we play it safe by demanding that
entities be clearly identified by definite descriptions.
To begin with, the description must specify the kind of entity
being referred to: the entity type.
A type is the set of all possible instances.
Each entity is an instance of a particular entity type
(e.g., Person, Country).
Winter 2015
ACS-4906
Ron McFadyen
11
Step 1: From Examples to Elementary Facts
Note that some authors use the word “entity” for “entity
type”. We sometimes expand “entity” to “entity instance” to
avoid any confusion. Consider the sentence
12.
Lee is located in 10B.
This could be talking about a horse located in a stable, or a
computer in a room, and so on. By stating the entity types
involved, (13) avoids this kind of referential ambiguity.
Names of object types are highlighted here by starting them
with a capital letter.
13.
Winter 2015
The Patient ‘Lee’ is located in the Ward ‘10B’.
ACS-4906
Ron McFadyen
12
Step 1: From Examples to Elementary Facts
ORM uses logical predicates to specify objects and the roles
they play
In logic, a predicate is basically a declarative sentence
with object holes in it.
To complete the sentence, the object holes or
placeholders are filled in by object terms.
Winter 2015
ACS-4906
Ron McFadyen
13
Step 1: From Examples to Elementary Facts
Consider the following sentence:
17.
The Person with firstname ‘Ann’ smokes.
the object term is “The Person with firstname ‘Ann’”.
The predicate may be shown by itself as
“… smokes”
using an ellipsis “…” as a placeholder for an object instance.
Winter 2015
ACS-4906
Ron McFadyen
14
Step 1: From Examples to Elementary Facts
A binary predicate is a sentence with two object holes. Most
predicates in information models are binary.
example:
18. The Person with firstname ‘Ann’ employs the Person with firstname ‘Bob’.
the predicate may be shown by itself as “… employs …”
Winter 2015
ACS-4906
Ron McFadyen
15
Step 1: From Examples to Elementary Facts
Mixfix
For naturalness, we write predicates in mixfix (or distfix)
form, where the terms may be mixed in with the predicate.
For example, the following ternary fact uses the predicate
“… moved to … during …”.
19.
The Scientist with surname ‘Einstein’ moved to the
Country with code ‘USA’ during the Year 1933 CE.
Winter 2015
ACS-4906
Ron McFadyen
16
Step 1: From Examples to Elementary Facts
Example
In reports like Table 3.1, the column headings and table
names or captions often give a clue as to the object types and
predicates. The column entries provide the values.
Winter 2015
ACS-4906
Ron McFadyen
17
Step 1: From Examples to Elementary Facts
translating row 1 as an elementary fact:
20.
The Person with surname ‘Wirth’ designed the Language
named ‘Pascal’.
entity types and reference modes appear as nouns
the predicate as a verb phrase.
If we read it from right to left, we might say:
21.
The Language named ‘Pascal’ was designed by the Person
with surname ‘Wirth’.
Winter 2015
ACS-4906
Ron McFadyen
18
Step 1: From Examples to Elementary Facts
consider Table 3.2.
columns don’t have separate names
Winter 2015
ACS-4906
Ron McFadyen
19
Step 1: From Examples to Elementary Facts
Verbalizing:
23.
The Person with firstname ‘Terry’ is married to / is
married to the Person with firstname ‘Norma’.
Notice that the forward predicate is the same as the inverse.
This is an example of a symmetric relationship.
Such relationships create special problems (as discussed in a
later chapter).
To help avoid such problems, at the conceptual level no
asserted predicate should be the same as its inverse
24.
The Person with firstname ‘Terry’ is husband of / is
wife of the Person with firstname ‘Norma’.
Winter 2015
ACS-4906
Ron McFadyen
20
Step 1: From Examples to Elementary Facts
Ternaries
Winter 2015
ACS-4906
Ron McFadyen
21
Step 1: From Examples to Elementary Facts
We might at first consider expressing this information as sentence (25),
using the ternary predicate “… designed … in …”.
25.
The Person with surname ‘Wirth’ designed the Language named ‘Pascal’
in the Year 1971 CE.
with no information loss:
26.
27.
The Person with surname ‘Wirth’ designed the Language named ‘Pascal’.
The Language named ‘Pascal’ was designed in the Year 1971 CE.
Here “no information loss” means that if we know (26) and (27) then
we also know (25).
Winter 2015
ACS-4906
Ron McFadyen
22
Step 1: From Examples to Elementary Facts
facts (26) and (27) may be set out more concisely as (26a) and (27a).
26a.
27a.
Person (surname) ‘Wirth’ designed Language (.name) ‘Pascal’.
Language (.name) ‘Pascal’ was designed in Year (CE) 1971.
Winter 2015
ACS-4906
Ron McFadyen
23
Step 1: From Examples to Elementary Facts
If the reference schemes for entity types are declared earlier, they may
be omitted in setting out the facts.
For example, (26) and (27) may be specified as:
Reference schemes:
Person(surname); Language(.name); Year(CE)
Facts:
Person ‘Wirth’ designed Language ‘Pascal’.
Language ‘Pascal’ was designed in Year 1971.
Winter 2015
ACS-4906
Ron McFadyen
24
Step 1: From Examples to Elementary Facts
consider the two output reports in Figure 3.2.
Winter 2015
ACS-4906
Ron McFadyen
25
Step 1: From Examples to Elementary Facts
Re Figure 3.2.
We may read off the information for Figure 3.2 (a) and Figure
3.2(b), respectively, as shown in the following two facts.
30.
31.
The Politician ‘George W. Bush’ was born in the Country ‘US’
in the Year 1946.
The Politician ‘George W. Bush’ visited the Country ‘GB’ in the Year 2003.
only one of the above facts is elementary.
Winter 2015
ACS-4906
Ron McFadyen
26
Step 1: From Examples to Elementary Facts
Re Figure 3.2.
Connecting two sentences by “and” forms a logical conjunction
Intuitively, fact 30 is equivalent to the conjunction of facts 32 and
33, so fact 30 is splittable (non-elementary).
Formally, this is because of a uniqueness constraint on the politician column
each politician was born in only one country and in only one
year.
Winter 2015
ACS-4906
Ron McFadyen
27
Step 1: From Examples to Elementary Facts
Consider Figure 3.2.
Winter 2015
ACS-4906
Ron McFadyen
28
Step 1: From Examples to Elementary Facts
Consider Figure 3.2.
One tricky feature of this table is the final column – there are sets of
degrees.
Phrase your sentences to include only one degree at a time.
Step 1 applied to the first row results in four facts that may be set
out as follows.
34.
35.
36.
37.
Winter 2015
The Lecturer with name ‘Adams JB’ was born in the Year 1946 CE.
The Lecturer with name ‘Adams JB’ has the Age 42 years.
The Lecturer with name ‘Adams JB’ holds the Degree with code ‘BSc’.
The Lecturer with name ‘Adams JB’ holds the Degree with code ‘PhD’.
ACS-4906
Ron McFadyen
29
Step 1: From Examples to Elementary Facts
more difficult example - Table 3.5
Winter 2015
ACS-4906
Ron McFadyen
30
Step 1: From Examples to Elementary Facts
step 1a: verbalize the information (perhaps informally):
Tute group A meets at 3 p.m. Monday in Room CS-718.
Student 302156 belongs to group A and is named ‘Bloggs FB’.
step 1b: verbalize the information as elementary facts:
38.
39.
40.
41.
Winter 2015
The TuteGroup with code ‘A’ meets at the Time with dhcode ‘Mon 3 p.m.’.
The TuteGroup with code ‘A’ meets in the Room with roomNr ‘CS 718’.
The Student with studentNr 302156 belongs to the TuteGroup with code ‘A’.
The Student with studentNr 302156 has the StudentName ‘Bloggs FB’.
ACS-4906
Ron McFadyen
31
Step 1: From Examples to Elementary Facts
Some exercises, pages 80++
Perform step 1 of the CSDP for the following output reports. In verbalizing the
facts, you may restrict yourself to the top row of the table unless another row
reveals a different kind of fact.
Winter 2015
ACS-4906
Ron McFadyen
32
Step 1: From Examples to Elementary Facts
Athlete (.name) ‘Jones EM’ pole vaults a height of Length (cm:) 400.
OR
Athlete (.name) ‘Jones EM’ pole vaults Height 400 (cm: Length).
Person (.name) ‘Jones EM’ has height of Length (cm:) 166.
Person (.name) ‘Jones EM’ was born in Year (CE) 1955.
Could this be true?: each row contains just a ternary, elementary fact:
Person (.name) ‘Jones EM’ had a height of Length (cm:) 166 in Year (CE) 1995.
Winter 2015
ACS-4906
Ron McFadyen
33
Step 1: From Examples to Elementary Facts
Some exercises, pages 80++
Perform step 1 of the CSDP for the following output reports. In verbalizing the
facts, you may restrict yourself to the top row of the table unless another row
reveals a different kind of fact.
Winter 2015
ACS-4906
Ron McFadyen
34
Step 1: From Examples to Elementary Facts
The Student with StudentNr 1001 for the Course with CourseCode ‘CS112’ achieved
the Rating 7.
Winter 2015
ACS-4906
Ron McFadyen
35
Step 1: From Examples to Elementary Facts
Some exercises, pages 80++
Perform step 1 of the CSDP for the following output reports. In verbalizing the
facts, you may restrict yourself to the top row of the table unless another row
reveals a different kind of fact.
Winter 2015
ACS-4906
Ron McFadyen
36
Step 1: From Examples to Elementary Facts
Person (.firstname)
Person (.firstname)
Person (.firstname)
Person (.firstname)
Person (.firstname)
Person (.firstname)
Winter 2015
‘Ann’ is a parent of Person (.firstname) ‘Colin’.
‘Ann’ is a parent of Person (.firstname) ‘David’.
‘Ann’ is a parent of Person (.firstname) ‘Eve’.
‘Bill’ is a parent of Person (.firstname) ‘Colin’.
‘Bill’ is a parent of Person (.firstname) ‘David’.
‘Bill’ is a parent of Person (.firstname) ‘Eve’.
ACS-4906
Ron McFadyen
37
Step 2: Draw Fact Types and Populate
Draw a conceptual schema diagram that shows all the
fact types.
This illustrates the relevant object types, predicates and
reference schemes.
Once the diagram is drawn, we check it with a sample
population.
Winter 2015
ACS-4906
Ron McFadyen
38
Step 2: Draw Fact Types and Populate
Simplifying reference schemes:
(b) Simplifies the formal representation in (a)
Winter 2015
ACS-4906
Ron McFadyen
39
Step 2: Draw Fact Types and Populate
Entity types, reference schemes, fact types, predicates, roles,
sample populations
roles
predicate
A car plays this
role
A person plays
this role
…
…
sample population
Now, we’ll do this using VS/Norma …
Winter 2015
ACS-4906
Ron McFadyen
40
Step 2: Draw Fact Types and Populate
Reference modes may be
• popular
• unit-based (measurement)
• general
Winter 2015
ACS-4906
Ron McFadyen
41
Step 2: Draw Fact Types and Populate
Popular reference modes
An initial list includes name, code, title, nr, #, and id.
popular reference modes are preceded by a dot “.”
e.g. (.name) (.nr)
Now, let’s examine this in VS/Norma …
Winter 2015
ACS-4906
Ron McFadyen
42
Step 2: Draw Fact Types and Populate
Unit-based (or measurement) reference modes
built-in list of physical units (e.g., cm, kg, mile) and monetary units
(e.g., USD, XEU)
When parenthesized, unit-based reference modes are appended by
a colon “:”.
Each unit is based on a unit type (or dimension), which may
optionally be displayed after the colon.
example: (kg: Mass), (lb: Mass), (USD: Money), (XEU: Money)
Now, let’s examine this in VS/Norma …
Winter 2015
ACS-4906
Ron McFadyen
43
Step 2: Draw Fact Types and Populate
General reference modes
no added punctuation
example: ISBN, URL
Now, let’s examine this in VS/Norma …
Winter 2015
ACS-4906
Ron McFadyen
44
Step 2: Draw Fact Types and Populate
Multiple fact types
Now, let’s examine this in VS/Norma …
Winter 2015
ACS-4906
Ron McFadyen
45
Step 2: Draw Fact Types and Populate
Same UoD but different approaches
Winter 2015
ACS-4906
Ron McFadyen
46
Step 2: Draw Fact Types and Populate
Ring fact types – one object type, multiple roles
Winter 2015
ACS-4906
Ron McFadyen
47
Step 2: Draw Fact Types and Populate
Ternary fact type
Winter 2015
ACS-4906
Ron McFadyen
48
Step 2: Draw Fact Types and Populate
Nesting of fact types
Now, let’s examine this in VS/Norma …
Winter 2015
ACS-4906
Ron McFadyen
49
Step 2: Draw Fact Types and Populate
Bar charts, etc
Winter 2015
ACS-4906
Ron McFadyen
50
Step 2: Draw Fact Types and Populate
Bar charts, etc
Winter 2015
ACS-4906
Ron McFadyen
51
Step 3: Trim Schema; Note Basic Derivations
check to see
•if there are some entity types that should be combined.
•if some fact types can be derived from the others by arithmetic
computation
Winter 2015
ACS-4906
Ron McFadyen
52
Step 3: Trim Schema; Note Basic Derivations
Consider Table 3.11 and Figure 3.25
MovieStar and Director overlap and so these two entity types must be
combined 
Winter 2015
ACS-4906
Ron McFadyen
53
Step 3: Trim Schema; Note Basic Derivations
Combining MovieStar and Director yields a Person entity type:
Winter 2015
ACS-4906
Ron McFadyen
54
Step 3: Trim Schema; Note Basic Derivations
•shows that it is possible to be both a star and a director
•does not imply that every movie star is a director
•a later chapter discusses how to add subtypes later if necessary
•if some other facts are to be recorded only for directors, we
form a Director subtype of Person for those additional facts
Winter 2015
ACS-4906
Ron McFadyen
55
Step 3: Trim Schema; Note Basic Derivations
Similar case – someone is showing the Chair and Instructors as
different types
After further consideration we understand that one of the
instructors is chosen to be chair
headed by
DeptName
known as
Dept
(.code)
employs
Chair
(.name)
Instructor
(.name)
 Combine Chair and Instructor
Winter 2015
ACS-4906
Ron McFadyen
56
Step 3: Trim Schema; Note Basic Derivations
headed by [Chair]
DeptName
known as
Dept
(.code)
Chair
(.name)
Staff
(.name)
Instructor
(.name)
employs [Employee]
Winter 2015
ACS-4906
Ron McFadyen
57
Step 3: Trim Schema; Note Basic Derivations
With ORM unit-based reference schemes are implicitly all based on
the same entity type … so the following is ok (see Table 3.12 and
figure 3.27)
But we can compress these types into one and use role names
One other point … Markup is derivable and must be shown as such 
Winter 2015
ACS-4906
Ron McFadyen
58
Step 3: Trim Schema; Note Basic Derivations
With ORM unit-based reference schemes are implicitly all based on
the same entity type … so the following is ok (see Table 3.12 and
figure 3.27)
* is used to show that a fact type is derivable
Winter 2015
ACS-4906
Ron McFadyen
59
Step 3: Trim Schema; Note Basic Derivations
Example: consider the following class list generated at the UofW
Winter 2015
ACS-4906
Ron McFadyen
60
Step 3: Trim Schema; Note Basic Derivations
Summary
•
•
•
•
•
•
Winter 2015
Verbalize a data use case
Transform verbalization to elementary fact types
Draw the diagram
Create sample populations
Combine entity types if they overlap
Transform fact type to derivations if applicable
ACS-4906
Ron McFadyen
61