B.3 Tablas de las FSMs de los NPCs
B.3.2 Tabla de la FSM de los NPCs Enemigos
We propose a generalization of the algebraic view maintenance approach that allows for maintaining dimension views using partial deltas. We proceed as follows: First, we explain how partial deltas can be represented by means of delete-insert sets used by the original algorithm. Second, we propose general- ized delta rules for projection, selection, and join. We show that partial deltas are closed under each of these operators. Third, we conclude that dimension views can be maintained by our algorithm.
It is common for view maintenance algorithms to model deltas by two sets, i.e. the set of deleted tuples and the set of inserted tuples. Updates are im- plicitly given by delete-insert pairs. We will therefore refer to this model as implicit delta model or implicit deltas for short. The implicit delta model does not directly match the model for partial deltas defined in Section 5.4.1. The latter uses seven distinct sets to explicitly distinguish between insertions, up- dates, partial updates, upsert, deletions, true partial deletions, and safe partial deletions. We will therefore refer to it as explicit delta model or explicit deltas for short.
While the explicit delta model allows for a natural representation of partial deltas, it is more complex to handle seven distinct sets during change propa- gation. We experienced that delta rules become rather complex. In particular, the join delta rules require a large number of joins to capture the interactions between the different delta sets.
Overly complex incremental expressions can be avoided by using the implicit delta model as the underlying model for change propagation. To do so, partial deltas need to be transferred to the implicit model. Furthermore, the result of the change propagation needs to be converted back into the explicit model for change data application. To do so, we extend the schema of the delta sets by
∆R(pk, a) :=Rins∪ πpk,aun(Run/uo)∪ Rpup∪ Rups
∇R(pk, a, flag) :=πpk,a,comp(Rdel)∪ πpk,auo ,comp(Run/uo)∪ πpk,NULL,pval(Rpup)∪ πpk,NULL,ptype(Rups)∪ πpk,NULL,pval(Rtpdel)∪ πpk,NULL,ptype(Rspdel) with flag∈ {comp, pval, ptype}
Figure 5.4: Conversion from explicit deltas to implicit deltas
adding a type flag column. This flag is used to indicate the type of individual delta tuples. Unknown attribute values (of partial deltas) are padded with null values. One could say that partial deltas are “encoded” as special kinds of complete deltas. We proceed by describing the conversion from the explicit delta model to the implicit delta model, and continue with the conversion in opposite direction.
Explicit delta model to implicit delta model The equations for converting from the explicit delta model to the implicit delta model are given in Figure 5.4. For a relation R it is straightforward to express the explicit delta sets Rins,
Run/uo, and Rdel in the implicit model, because these sets are non-partial. To
distinguish complete delta tuples from partial ones, they are assigned a type flag with the value comp.
The remaining delta sets are treated as follows: Partial update tuples Rpup
are added to the insert set ∆R. To distinguish them from insertions and complete updates, an additional tuple is added to the delete set∇R for each partial update. These additional tuples are assigned with the same primary key value, while all remaining attributes are padded with null values, because the initial attribute values before the update are unknown. Furthermore, a type flag with the value pval is assigned to indicate that the delta tuple is value-partial. Note that the schema of∇R is extended to accommodate the type flag.
Upserts are handled somewhat similarly. Like partial updates, upserts are added to the insert set ∆R and an additional tuple with the same primary key value and null-padded attributes is added to the delete set∇R. In contrast to partial updates, upserts are type-partial. This is indicated by assigning the value ptype to the type flag in the delete delta set.
Partial deletions are added to∇R. Because only the primary key value is known for partial deletions, all remaining attributes are again padded with null values. True partial deletions Rtpdelare assigned with a type flag with the
value pval, while safe partial deletions Rspdel are assigned with a type flag with
the value ptype. Note that partial deletions can be distinguished from partial updates and upserts, because the former do not have corresponding tuples in
∆C ∆A
CID CName CDiscnt AID AID ACity ACountry
1 Adam 5 1 1 Essen DE
2 Bob 0 4 4 Dresden DE
4 Dave 0 4
∇C ∇A
CID CName CDiscnt AID flag AID ACity ACountry flag
1 Adam 0 1 comp 1 - - pval
2 Bob 0 2 comp 3 - - pval
3 Carl 0 3 comp
Figure 5.5: Sample deltas converted to the implicit model
Rins:= ∆Rnpk∇R Rdel:=∇R npkσ(flag=comp)∆R Run/uo:= ∆R ◃▹pkσ(flag=comp)∇R Rpup:= ∆Rnpkσ(flag=pval)∇R Rups:= ∆Rnpkσ(flag=ptype)∇R Rtpdel:= πpk(∇R npkσ(flag=pval)∆R) Rspdel:= πpk(∇R npkσ(flag=ptype)∆R)
Figure 5.6: Conversion from implicit deltas to explicit deltas
the insert set ∆R while the latter do.
Example 5.1 Recall the running example introduced in Section 5.3 before.
Figure 5.1 depicts both, the old and the new state of the base relations C and A. Recall that non-partial deltas are captured at C while partial updates and partial deletions are captured at A. The deltas converted to the implicit model are depicted in Figure 5.5.
Implicit delta model to explicit delta model The equations for converting from the implicit delta model back to the explicit delta model are given in Figure 5.6. Note that the symbols n and n are used to denote semi join and anti join, respectively. The set of insertions Rinsconsists of those tuples in ∆R
that have a primary key value that does not exist in ∇R. Similarly, the set of deletions Rdel consists of those tuples in∇R that have a primary key value
that does not exist in ∆R and are complete, i.e. have a type flag with a value of comp.
The set of complete updates Run/uo consists of pairs of tuples in ∆R and
have a type flag with a value of comp. The set of partial updates Rpup and the
set of upserts Rups consist of tuples in ∆R that join to tuples in∇R having a
type flag with a value of pval or ptype, respectively.
The set of partial deletions consist of tuples in∇R having a primary key that does not exist in ∆R. The set of true partial deletions Rtpdel can be
distinguished from the set of safe partial deletions Rspdel based on the type
flag. Tuples in the former set have a type flag with a value of pval while tuples in the latter set have a type flag with a value of ptype.
In Chapter 4, we proposed adaptations to the original delta rules for algebraic differencing. In the following, we will generalize the adapted delta rules for projection, selection, and join for the propagation of partial deltas.