jarrar: subtype relations and constraints
DESCRIPTION
Lecture video by Mustafa Jarrar at Birzeit University, Palestine. See the course webpage at: http://jarrar-courses.blogspot.com/2011/09/knowledgeengineering-fall2011.html and http://www.jarrar.info and on Youtube: http://www.youtube.com/watch?v=3_-HGnI6AZ0&list=PLDEA50C29F3D28257TRANSCRIPT
Jarrar © 2011 1
Subtype Relations and Constraints
Knowledge Engineering (SCOM7348)
© Mustafa JarrarLecture Notes, Knowledge Engineering (SCOM7348)
University of Birzeit1st Semester, 2011
Dr. Mustafa JarrarUniversity of [email protected]
www.jarrar.info
(Chapter 6)
Jarrar © 2011 2
Conceptual Schema Design Steps
1. From examples to elementary facts
2. Draw fact types and apply population check
3. Combine entity types
4. Add uniqueness constraints
5. Add mandatory constraints
6. Add subtype relations and other constraints
7. Final checks, & schema engineering issues
Jarrar © 2011 3
Outline
• Quick Math background
• Value Constraints
• Set Constrains
o Subset
o Equality
o Exclusion
• Subtype relations
• Frequency constraints
Jarrar © 2011 4
Mathematical Background
Hypothetical Euler diagrams for set comparisons.
Jarrar © 2011 5
Venn diagrams for three set-forming operations.
Mathematical Background
Jarrar © 2011 6
Mathematical Background
Venn diagrams for (a) A is a proper subset of B and (b) four sets.
Jarrar © 2011 7
Outline
• Quick Math background
• Value Constraints
• Set Constrains
o Subset
o Equality
o Exclusion
• Subtype relations
• Frequency constraints
Jarrar © 2011 8
Value Constraint
Called Value Constraint
A set of values, from which the value of the MedalKind is limited to
Jarrar © 2011 9
Value Constraint
The value of sex should be one of {‘M’, ‘F’}
Jarrar © 2011 10
Value Constraint
Value constraints may list the possible values of a value type.
Who can give more examples?
Jarrar © 2011 11
Outline
• Quick Math background
• Value Constraints
• Set Constrains
o Subset
o Equality
o Exclusion
• Subtype relations
• Frequency constraints
Jarrar © 2011 12
Role subset/equality constraint
Subset constraint:Every Member booked an Hour should play sport.
Equality constraint:Every Member ‘has’ ReactionTime should ‘has’ HeartRate, and every Member ‘has’ HeartRate should ‘has’ ReactionTime.
Jarrar © 2011 13
Role subset constraint
Notice that this subset constraint is implied, and should be removed.
That is, there is no need to say that every A playing r2 must also play r1 (subset), because the mandatory constraint here means that every A must play r1 (the Mandatory implies the subset).
Jarrar © 2011 14
Role equality constraint
Also this quality constraint is implied, and should be removed.
Jarrar © 2011 15
Implication
Who can explain the difference?
The two constraints in the first model says: each A must play r1 or r2 (or both), and that if A plays r2 then it must play r1. This means that r1 must be always played (which is the second model)
Jarrar © 2011 16
Role Exclusion Constraint
Exclusion constraint:Every Employee is allocated a ParkingSpace should not claim MoneyAmt.
Jarrar © 2011 17
Role Exclusion Constraint
Jarrar © 2011 18
Role Exclusion Constraint
Each partner must be either a husband or wife (but not both at the same time).
Called “Exclusive-or”
Jarrar © 2011 19
Exclusive-or (another example)
Each Account must be OwnedBy a Person or a Company, but not both.
Jarrar © 2011 20
Role Exclusion Constraint
Each person has at most one of three vices. i.e., from 0 to 3 vices.
It can be written also as
Jarrar © 2011 21
Pair Exclusion Constraint
How can we restrict that a person can drive a car only if he owns that car.
Jarrar © 2011 22
Pair-subset constraint
An example of a tuple-subset constraint between sequences of three roles.
Jarrar © 2011 23
Equality Constraint
Jarrar © 2011 24
Pair Exclusion Constraint
Same person can ‘own’ and ‘wants to buy’ the same car?
Jarrar © 2011 25
What is Wrong?
Implies
ImpliesImplies
Jarrar © 2011 26
Outline
• Quick Math background
• Value Constraints
• Set Constrains
o Subset
o Equality
o Exclusion
• Subtype relations
• Frequency constraints
Jarrar © 2011 27
Subtypes
Person
Male Female
• Generalization/Specialization hierarchy.• Subtype inherits the properties of its supertype.
Jarrar © 2011 28
Subtypes
Person
Australian Female
FemaleAustralian
*
* The indirect subtype connection is implied, so it should be omitted
Jarrar © 2011 29
Subtypes
Jarrar © 2011 30
Subtypes
Person
Male Female
There is no person that can be Male and Female at the same time.
Person
Male Female
Every person must be a Male or a female.
Every person must be either a Male or a Female
Person
Male Female
Jarrar © 2011 31
Subtypes
What is Inherited?
Jarrar © 2011 32
What is Wrong?
Jarrar © 2011 33
Outline
• Quick Math background
• Value Constraints
• Set Constrains
o Subset
o Equality
o Exclusion
• Subtype relations
• Frequency constraints also called “Occurrence constraints”
Jarrar © 2011 34
Frequency constraints
To indicate that each entry in a fact column must occur there exactly n times, the number n is written beside the role.
Each city in the first column must occur
three times.each drive kind in the Second column must appear there twice
A compound transaction is needed to initially populate this fact type requiring at least six facts to be added.
Jarrar © 2011 35
Frequency constraints
Each member of pop(r) occurs there exactly n times.
n must be a positive integer.
A r
n
A r
1
A r
If n = 1, this is equivalent to a uniqueness constraint
Jarrar © 2011 36
Compound Frequency Constraint
The values of (Year and City) must occur exactly three times
Jarrar © 2011 37
Ranged Frequency Constraint
Examples of minimum and maximum frequency constraints.
Each name of Panl must occur at least 4 and at most 7 times. That is, each Expert must on 4 to 7 Panels
Each Expert can referee 5 papersEach Paper can be refereed by at least two Experts.
Jarrar © 2011 38
Discussion
Summarize what you learned? And what you think about it?
Compare what you learned with EER and UML?
Questions & Suggestions?