PSG1 - U of W ACS Homepage

Schema Equivalence
Two schemas are equivalent iff a state or transition in one
can be modeled in the other
ACS-4906
R McFadyen
1
Schema Equivalence
Consider Figure 14.1:
Smoking/drinking generalized to vices
Vices specialized to smoking/drinking predicates
Any state of (a) can be
represented in (b)
And
Any state of (b) can be
represented in (a)
ACS-4906
R McFadyen
2
Schema Equivalence
What does rmap produce?
Consider Figure 14.3:
ACS-4906
R McFadyen
3
Schema Equivalence / Transformations
Predicate Specialization/Generalization (PSG) Theorem 1:
(in diagram form)
S1
{b1, … bn}
A1
Am
A1
B
...
Am
Sn
R
where m>=1, and each Si corresponds to R where B=bi
PSG1: R may be specialized into S1 , … Sn by absorbing B
ACS-4906
R McFadyen
4
Schema Equivalence / Transformations
Corollary 1:
If a UC in R spans a combination of B’s role and other roles, a UC spans the
specialization of these other roles in S1 , … Sn ; and conversely.
(in diagram form)
S1
{b1, … bn}
A1
Am
A1
B
...
Am
Sn
R
… won … gold
Review slide 2 …
ACS-4906
R McFadyen
5
Schema Equivalence / Transformations
Corollary 1:
If a UC in R spans a combination of B’s role and other roles, a UC spans the
specialization of these other roles in S1 , … Sn ; and conversely.
(in diagram form)
S1
{b1, … bn}
A1
Am
A1
B
Am
...
Sn
R
… won … gold
{‘gold’, ‘silver’, ‘bronze’}
Quantity
(.nr)
Country
(.name)
Quantity
(.nr)
Medal
Kind
… won … silver
Country
(.name)
… won … bronze
R
ACS-4906
R McFadyen
6
Schema Equivalence / Transformations
Corollary 2:
If a UC spans all roles in R except for B’s role then S1 , … Sn are mutually
exclusive; and conversely.
S1
(in diagram form)
{b1, … bn}
A1
Am
A1
B
...X
Am
Sn
R
ACS-4906
R McFadyen
7
Schema Equivalence / Transformations
Corollary 2:
If a UC spans all roles in R except for B’s role then S1 , … Sn are mutually
exclusive; and conversely.
S1
(in diagram form)
{b1, … bn}
A1
Am
A1
B
Am
...X
Sn
R
authored
{‘authored’, ‘reviewed’}
Person
Book
Person
Task
X
Book
reviewed
R
Ternary  Binaries
ACS-4906
R McFadyen
8
Schema Equivalence / Transformations
Corollary 2:
If a UC spans all roles in R except for B’s role then S1 , … Sn are mutually
exclusive; and conversely.
Example from a sport such as hockey, soccer …
Consider that a player plays one position on a team, but other players can
play that position too.
Over their career a player may play on several teams.
… plays lw on …
{‘lw’, ‘rw’, … }
Team
Player
Position
...
Player
X
Team
… plays goalie on …
… plays on … as a …
Ternary  Binaries
ACS-4906
R McFadyen
9
Schema Equivalence / Transformations
Corollary 2:
If a UC spans all roles in R except for B’s role then S1 , … Sn are mutually
exclusive; and conversely.
Example
Consider an employee has one position.
Binary  Unaries
Note: text example uses Rank as the entity type for position
ACS-4906
R McFadyen
10
Schema Equivalence / Transformations
Corollary 3:
If Ai’s role in R is mandatory then the disjunction of its specialized roles is
mandatory; and conversely.
Ai
A1
{b1, … bn}
Am
A1
B
Am
...
Sn
R
… won … gold
{‘gold’, ‘silver’, ‘bronze’}
Country
(.code)
Medal
Kind
Country
(.name)
Quantity
(.nr)
… won … silver
Quantity
(.nr)
… won … bronze
R
name
name
A country must have at least one medal count
ACS-4906
R McFadyen
11
Schema Equivalence / Transformations
Corollary 4:
If R is a ternary with a UC spanning just B’s role and one other role, then
adding a frequency constraint of n to this other role is equivalent to adding an
equality constraint over the specialized versions of that role.
Example 1: if a country participates in ‘…won medals of … in …’ then it must
participate with all 3 medals
{‘gold’, ‘silver’, ‘bronze’}
=
Medal
Kind
(.code)
Country
(.code)
… won … gold
3
Country
Quantity
… won … silver
Quantity
(.code)
… won … bronze
ACS-4906
R McFadyen
12
Schema Equivalence / Transformations
Corollary 4:
Example 3:
Suppose a game is played by exactly two teams where the result is one
winner and one loser
game … has status of … for team …
{‘winner’, ‘loser’ }
=
Status
game … won by …
2
Game
game
Team
Team
game … lost by …
A game, if it participates, must
participate in all of the predicates
ACS-4906
R McFadyen
13
Schema Equivalence / Transformations
Corollary 5:
If R is a ternary with a UC spanning just B’s role and one other role, then
adding a mandatory role constraint and frequency constraint of n (the number
of possible values for B) to this other role is equivalent to making each
specialized version of that role mandatory.
Example 1. a country must participate in ‘…won medals of … in …’ and it must
participate 3 times (all 3 medals)
{‘gold’, ‘silver’, ‘bronze’}
Medal
Kind
(.code)
Country
(.code)
… won … gold
3
Country
Quantity
… won … silver
Quantity
(.code)
… won … bronze
ACS-4906
R McFadyen
14
Schema Equivalence / Transformations
Corollary 5:
Example 2: a department … has … instructors of rank …
{‘I’, ‘II’, ‘III’}
Rank
… has … instructors of rank I
… has … instructors of rank II
3
Department
Department
Qty
Qty
… has … instructors of rank III
ACS-4906
R McFadyen
15