6.5 Transformation Rules
6.5.2 Shifting Attributes
The second group of rules deals with the shifting of attributes. This will also be used in the homogenisation step 1 of our method. Rule 9 allows to shift a synonymous attribute occurring in two subtypes, i.e. whenever tuples agree on the key they also agree on that attribute, to be shifted to a supertype. This rule leads to a dominating schema. Conversely, Rule 10 allows to shift an attribute from a supertype to subtypes, in which case schema equivalence can be verified.
Rule 9. Forcomp(Ri) = {ri :R}andA∈attr(Ri)−key(Ri) (i= 1,2) together with the
constraint∀t, t0 ∈R
1∪R2.t[r] =t0[r]⇒t[A] = t0[A]∧∀t∈R.∃t0 ∈R1∪R2.t0[r] = treplace the typesR,R1 andR2 such thatattr(Rnew) =attr(R)∪{A},comp(Ri,new) = {ri :Rnew}
and attr(Ri,new) = attr(Ri)− {A} hold.
MB R=r:id×t → {1l} R1 =A:ta×t1×r :ref → {1l} R2 =A:ta×t2×r :ref → {1l} M∗ B R new =r :id×A:ta×t→ {1l} R1,new =t1×r:ref → {1l} R2,new =t2×r:ref → {1l} ϕ
with the side conditionϕ:
∀t, t0 ∈R1∪R2.t[r] =t0[r]⇒t[A] = t0[A] ∧ ∀t∈R. ∃t0 ∈R1∪R2.t0[r] =t[r] The corresponding abstraction predicateA:
∀a, x1, x2, x.((∃r.Rnew(r, a, x) = 1∧R1,new(x1, r) = 1 ⇔ ∃r.(R(r, x) = 1∧R1(a, x1, r) = 1)∧
(∃r.Rnew(r, a, x) = 1∧R2,new(x2, r) = 1 ⇔ ∃r.(R(r, x) = 1∧R2(a, x2, r) = 1)) The corresponding computable queriesf and g:
R1,new :={(x1, r)| ∃a.(a, x1, r)∈R1}k R2,new :={(x2, r)| ∃a.(a, x2, r)∈R2}k Rnew :={(r, a, x)|(r, x)∈R∧(∃x1.(a, x1, r)∈R1∨ ∃x2.(a, x2, r)∈R2))} and R1 :={(a, x1, r)| ∃x.(r, a, x)∈Rnew∧(x1, r)∈R1,new}k R2 :={(a, x2, r)| ∃x.(r, a, x)∈Rnew∧(x2, r)∈R2,new}k R :={(r, a)| ∃x.(r, a, x)∈Rnew}
R R1 R2 A A Rnew R1,new R 2,new A
Figure 6.2: The relationship types before and after application of Rule 9
respectively.
Example 6.9. An example is shown in Figure 6.2.
Rule 10. For comp(Ri) = {ri : R} (i = 1, . . . , n) and A ∈ attr(R)−key(R) together
with the constraint ∀t ∈ R.∃t0 ∈ R
i.t0[ri] = t replace the types such that attr(Rnew) = attr(R)− {A}, comp(Ri,new) ={ri :Rnew} and attr(Ri,new) =attr(Ri)∪ {A} hold.
MB R=r :id×A :ta×t→ {1l} R1 =r:ref ×t1 → {1l} . . . Rn =r :ref ×tn→ {1l} M∗ B R new=rnew :id×t→ {1l}
R1,new =rnew :ref ×t1×A:ta → {1l}
. . .
Rn,new =rnew :ref ×tn×A:ta→ {1l}
ϕ
with the side conditionϕ being:
A∈attr(R)−key(R) and ∀t∈R.∃t0 ∈R
i.t0[r] =t[r]
The corresponding predicate A:
∀x, a, x1, . . . , xn
((∃r.Rnew(r, x) = 1∧R1,new(r, x1, a) = 1
⇔ ∃r.(R(r, a, x) = 1∧R1(r, x1) = 1)∧ · · · ∧ (∃r.Rnew(r, x) = 1∧Rn,new(r, xn, a) = 1
⇔ ∃r.(R(r, a, x) = 1∧Rn(r, xn) = 1))
The corresponding computable queriesf and g:
Rnew:={(r, x)| ∃a.(r, a, x)∈R}k
R1,new :={(r, x1, a)|(r, x1)∈R1∧ ∃x.(r, a, x)∈R}k. . .k Rn,new :={(r, xn, a)|(r, xn)∈Rn∧ ∃x.(r, a, x)∈R}
6.5. TRANSFORMATION RULES Jane Qiong Zhao R A R1 ... Rn Rnew R1,new ... Rn,new A A
Figure 6.3: The relationship types before and after application of Rule 10
and R := {(r, a, x) |(r, x)∈Rnew∧ ∃x1.(r, x1, a)∈R1,new ∧ · · · ∧ ∃xn.(r, xn, a)∈Rn,new}k R1 := {(r, x1) | ∃a.(r, x1, a)∈R1,new}k. . .k Rn := {(r, xn) | ∃a.(r, xn, a)∈Rn,new} respectively.
Example 6.10. An example is shown in Figure 6.3.
The next two rules Rule 11 and 12 concern the reorganisation of paths and the shifting of attributes along paths. In both cases we obtain a dominating schema. Rule 11 could be split into two rules dealing separately with binary and unary relationship types Rn.
Rule 11. For a pathP ≡R1−· · ·−Rnand a relationship typeRwithrn:Rn ∈comp(R)
together with path cardinality constraints card(P, R1) ≤ (1,1) ≤ card(P, Rn) replace R
such that comp(Rnew) = comp(R)− {rn:Rn} ∪ {r1,new :R1}with a new role r1,new holds.
MB R=rn:ref ×t → {1l} R1 =r1 :id×[r2 :ref]×t1 → {1l} R2 =r2 :id×[r1 :ref]×[r3 :ref]×t1 → {1l} . . . Rn =rn :id×[rn−1 :ref]×tn → {1l} M∗ B R new =r1 :ref ×t→ {1l} R1 =r1 :id×[r2 :ref]×t1 → {1l} R2 =r2 :id×[r1 :ref]×[r3 :ref]×t1 → {1l} . . . Rn=rn:id×[rn−1 :ref]×tn→ {1l} ϕ
where [ri : ref](1 ≤ i ≤ n) models a possible reference to type Ri, due to the path
definition P ≡ R1− · · · −Rn covering all possible path directions, as depicted in Figure
6.4. We say that [ri : ref] is realised, denoted by [ri+1 : ref] ≡ ri+1 : ref iff [ri : ref]
models an actual reference to Ri.
Ri Ri-1 Ri+1 Ri Ri-1 Ri+1 Ri Ri-1 Ri+1 Ri Ri-1 Ri+1
Figure 6.4: The possible path directions
• card(P, R1)≤(1,1)≤card(P, Rn), and
• P ≡R1− · · · −Rn holds, which means:
∀i(1≤i < n).([ri+1 :ref]≡ri+1 :ref in Ri) xor ([ri :ref]≡ri :ref inRi+1)
The corresponding predicate A: ∀rn, x.(R(rn, x) = 1⇔
∃r1, . . . rn−1, x1, . . . , xn.(Rnew(r1, x) = 1)∧R1(πT1(r1, r2, x1)) = 1∧
R2(πT2(r2, r1, r3, x2)) = 1∧ · · · ∧Rn(πTn(rn, rn−1, xn)) = 1)
where Ti is the source type of Ri, i.e. we have Ri = Ti → {1l}. πTi(ri, ri−1, ri+1, xi) projects the tuple (ri, ri−1, ri+1, xi) onto Ti.
The corresponding computable queriesf and g:
Rnew :={(h(Sr1), x)|Sr1 ={r1 | ∃r2, . . . , rn, x1, . . . , xn.(πT1(r1, r2, x1)∈R1∧
πT2(r2, r1, r3, x2)∈R2∧ · · · ∧πTn(rn, rn−1, xn)∈Rn∧(rn, x)∈R)} 6=∅} and
R :={(rn, x)| ∃r1, . . . rn−1, x1, . . . , xn−1.((r1, x)∈Rnew∧πT1(r1, r2, x1)∈R1∧
πT2(r2, r1, r3, x2)∈R2∧ · · · ∧πTn(rn, rn−1, xn)∈Rn)}
respectively, for some fixed computable selection function h with the propertyh(S)∈ S.
6.5. TRANSFORMATION RULES Jane Qiong Zhao R Rn ... . R1 Rnew R1 ... . Rn
Figure 6.5: The relationship types before and after application of Rule 11
Rule 12. For a path P ≡ R1 − · · · − Rn with A ∈ attr(Rn), A /∈ key(Rn), and
path cardinality constraints card(P, R1)≤(1,1)≤card(P, Rn) replace R1, Rn such that attr(R1,new) = attr(R1)∪ {A} and attr(Rn,new) =attr(Rn)− {A} hold.
MB R1 =r1 :id×[r2 :ref]×t1 → {1l}
R2 =r2 :id×[r1 :ref]×[r3 :ref]×t1 → {1l} . . .
Rn =rn :id×[rn−1 :ref]×A:ta×tn→ {1l}
M∗ B R
1,new =r1,new :id×[r2 :ref]×A:ta×t1 → {1l} R2 =r2 :id×[r1 :ref]×[r3 :ref]×t1 → {1l} . . .
Rn,new =rn,new :id×tn→ {1l}
ϕ
where [ri : ref](1 ≤ i ≤ n) models a possible reference to type Ri, due to the path
definition P ≡ R1− · · · −Rn covering all possible path directions, as depicted in Figure
6.4. We say that [ri : ref] is realised, denoted by [ri+1 : ref] ≡ ri+1 : ref iff [ri : ref]
models an actual reference to Ri.
The side condition ϕ:
• A /∈key(Rn), and
• card(P, R1) = (1,1)≤card(P, Rn), and
• P ≡R1− · · · −Rn,which means:
∀i(1≤i < n).([ri+1 :ref]≡ri+1 :ref inRi) xor ([ri :ref]≡ri :ref in Ri+1); The corresponding predicate A:
∀r1, . . . , rn, a, x1, . . . , xn.
R1 Rn ... A R1,new Rn,new A ...
Figure 6.6: The relationship types before and after application of Rule 12
[R1(πT1(r1, r2, x1)) = 1∧Rn(πTn(rn, rn−1, a, xn)) = 1⇔
R1,new(πT1,new(r1, r2, a, x1)) = 1∧Rn,new(πTn,new(rn, rn−1, xn)) = 1])
where Ti is the source type of Ri, i.e. we have Ri = Ti → {1l}. πTi(ri, ri−1, ri+1, xi) projects the tuple (ri, ri−1, ri+1, xi) onto Ti.
The corresponding computable queriesf and g:
Rn,new :={πTn,new(rn, rn−1, xn)| ∃a.πTn(rn, rn−1, a, xn)∈Rn}k R1,new :={πT1,new(r1, r2, a, x1)| ∃r3, . . . , rn, x2, . . . , xn. (πT1(r1, r2, x1)∈R1∧πT2(r2, r1, r3, x2)∈R2∧ · · · ∧ πTn(rn, rn−1, a, xn)∈Rn} and Rn :={πTn(rn, rn−1, a, xn)| ∃r1, r2, . . . , rn−2, x1, . . . , xn−1. (πT1,new(r1, r2, a, x1)∈R1,new∧πT2(r2, r1, r3, x2)∈R2∧ · · · ∧ πTn,new(rn, rn−1, xn)∈Rn,new}k
R1 :={πT1(r1, r2, x1)| ∃a.πT1,new(r1, r2, a, x1)∈R1,new} respectively.
Example 6.12. An example is shown in Figure 6.6.