A Structural Model of ECA Rules in Active Database Xiaoou Li, Joselito Medina Mar´ın, and Sergio V. Chapa Secci´ on de Computaci´ on, Departamento de Ingenier´ia El´ectrica, CINVESTAV-IPN, Av.IPN 2508, A.P. 14-740, Col. Zacatenco, M´exico D.F., 07360, M´exico email:
[email protected]
Abstract. Active database systems have been developed for applications needing an automatic reaction in response to certain conditions being satisfied or certain event occurring. The desired behavior is expressed by ECA-rules (event-condition-action rules). Generally, ECA rules and their execution are represented by rule language, for example, defining TRIGGERs in an active database. Then, database behavior prediction or analysis can be realized through other approaches such as algebraic approach, trigger graph methods, etc.. Therefore, in such active databases, rule representation and processing are separated. In this paper we propose a structural model which integrates rule representation and processing entirely, it is called Conditional Colored Petri Net (CCPN). CCPN can model both rules themselves and their complicated interacting relation in an graphical way. If the rule base of an active database is modeled by CCPN, then rule simulation can be done. An example is illustrated in the paper. Keywords: active database, ECA rules, colored Petri net
1
Introduction
Traditional database management system (DBMS) stores data and information passively, and we just can perform actions implicit either by user programs or through interactive interfaces. In contrast, active database manager systems (ADBMS) have an active behavior. ADBMS not only stored data and information, also reacts to events and carry out actions according to these events (such as insert data, delete data, update data, etc.). Active database behavior is achieved through definition of Event-Condition-Action (ECA) rules as part of the database. Occurrence of events triggers the evaluation of a condition and if the condition evaluates to be true, then the action is executed [1], [2]. Active database systems are very powerful, but developing even small active rule applications can be a difficult task due to the unstructured and unpredictable nature of rule processing. During rule processing, rules can trigger and untrigger each other, and the intermediate and final states of the database can depend upon which rules are triggered and executed in which order. We say ECA rules execution is indeterministic, asynchronous, concurrent, parallel, etc. These features make it difficult to find a formal model for ECA rules execution and C.A. Coello Coello et al. (Eds.): MICAI 2002, LNAI 2313, pp. 486–493, 2002. c Springer-Verlag Berlin Heidelberg 2002
A Structural Model of ECA Rules in Active Database
487
analysis. For these reasons, rule languages or query languages are most widely adopted in existing ADBMSs. In almost all ADBMSs, the description of rules refers to how rules themselves are normally expressed using a database programming language, a query language, or as objects in an object-oriented database. Furthermore, programmer support is of paramount importance if active rules are to be adopted as a mainstream implementation technology in business environments. Important facilities for supporting the developers of rule bases include the ability to query the rule base and to trace or in some other way monitor rule system behavior. This means that several different models are needed for rule representation and processing. These approaches have disadvantages like the existence of redundant rule data and the need for combining all models. In this paper we develop an extended colored Petri net model in which rules can be represented, analyzed, and processed entirely. Furthermore, the model can be extended to be useful in temporal, object-oriented and other database systems. As to our knowledge, few researchers use Petri net theory in advanced database systems for rule processing [3],[4], [5],[6]. The most interesting one is [3]. The authors proposed an Action Rule Flow Petri Net (ARFPN) model, and a workflow management system was illustrated to verify the ARFPN model. However, their model has much redundant structure because of using many BEGIN OFs, END OFs to describe events, conditions and actions. In our approach this drawback will be overcome by using conditional transitions.
2
Active Database Systems
An active database management system integrates event-based rule processing with traditional database functionality. Generally, an event-condition-action rule has the following structure: on event if condition then action 1 else action 2 When there are changes in the database an event occurs, then one or more rules may be triggered. Once a rule fires, the conditions of this rule are checked and if the conditions are satisfied, the actions of the rule are executed. Active rule processing syntax includes two models: knowledge model and execution model. Knowledge model indicates what can be said about active rules in that system. Knowledge model essentially supports the description of active functionality, the features dealt with in this model often have a direct representation within the syntax of rule language. Execution model specifies how a set of rules is treated at runtime. Although the execution model of a rule system is closely related to aspects of the underlying DBMS (e.g., data model, transaction manager), there are number of phases in rule evaluation, illustrated in Fig. 1, and are the follows [1]:
488
Xiaoou Li, Joselito Medina Mar´ın, and Sergio V. Chapa
Fig. 1. Principal steps that take place during rule execution.
Signaling, it refers to the occurrence of an event caused by an event source. Triggering, fires a rule when an event specified in this rule takes place. Evaluation, verify the conditions of the triggered rules. Scheduling, determines what happens when multiple rules are triggered at the same time. Execution, carries out the actions of the triggered rule. It is not easy to monitor ECA rules execution based on rule language. However, if a formal model is developed to represent all rules in the rule base and their relations, then the management of ADBMS could be abstracted to operations or processes based on this model. Therefore, the management complexity of an ADBMS system will be greatly reduced. The objective of our research is to develop such a model which can both describe all above three features and reveal the structural relation between ECA rules.
3
Conditional Colored Petri Net
Petri Nets are a graphical and mathematical tool for modeling concurrent, asynchronous, distributed, parallel, indeterministic, and/or stochastic systems. Petri net may be extended widely and applied in every area with logic relations. Colored Petri net is suitable for systems in which communication, synchronization and resource sharing are important. ECA rule can be modeled by colored Petri nets such as in [3]. However, there exists much redundant Petri net structure for using “begin of”, “end of” events, conditions and actions. In order to express clearly and exactly the three components of an ECA rule, we need to analyze ECA rule execution again. When an ECA rule is executed, event detection is a process to get a result 0 or 1 (represent the event is detected or not), therefore, it is more convenient to model it as a place of Petri net. If the detection result is 1, then a token is deposited into this place. On the other hand, an action of one rule maybe an event of another rule, i.e., The conjunction of the set of actions and events is not empty. Modeling actions as places also obey human cognition. The condition part of an ECA rule will be evaluated after event detection, so it should be expressed by a downstream of the place representing the event. We can use a conditional transition to model it. If there are tokens in each upstream place, then the condition attached on the transition will be evaluated, then the transition fires provided the condition is completed. Our idea may be represented by a simple Petri net like Fig. 2
A Structural Model of ECA Rules in Active Database
489
Fig. 2. A simple Peri net explaination of two types of ECA rules
Based on above analysis, we give formal definitions of Conditional Colored Petri Net model (CCPN). Definition 1. A conditional colored Petri net is a tuple CP N = {Σ, P, T, A, N, C, Cond, E, I} where Σ is a finite set of non-empty types or color sets. P is a finite set of places. T is a finite set of transitions. A is a finite set of arcs, such that P ∩ T = P ∩ A = T ∩ A = Φ. N is a node function. It is defined from A into P × T ∪ T × P . C is a color function. It is defined from P into Σ. Cond is a condition function. It is defined from T into expressions such that ∀t ∈ T : Cond(t) = ß(V ar(Con(t))). I is an initialization function. It is defined from P into closed expressions such that ∀p ∈ P : [T ype(I(p)) = C(p)M S ].
490
Xiaoou Li, Joselito Medina Mar´ın, and Sergio V. Chapa
In CCPN, token represents data item in database, all information of a data item is carried by token color. Firing principle of CCPN is like an ordinary Petri net, conditional transition enabling and firing definitions are given as below. Definition 2. The marking of a place p is defined as the number of tokens in that place. denoted by M (p). In a place p, if there are three tokens, then M (p) = 3. But, it is possible that these three tokens belong to different types, or they don’t have the same color. For example, in Example 2, in insert-employee place there are three tokens, each token has its own color, i.e., (Joe Brown, 25, 500, M, single, Master, 8, X, 0), (Susan Hill, 34, 500, F, single, Phd, 8, X, 0) and (George Star, 30, 500, M, married, Bachelor, 8, X, 0). Definition 3. A transition t is active in a marking M iff ∀p ∈· T : M (p) ≥ 1. Definition 4. A transition t is enabled iff – t is active; – Cond(t) = 1. If t is enabled, token transition may be made. The token transition process is the same as in an ordinary Petri net, remove one token from each upstream place and add one token to each downstream place. However, the token color added to the downstream will correspond to the action in the rule. for example, in Fig.3, the transition t1 is enabled for the token (Susan Hill, 34, 500, F, single, Phd, 8, X, 0) in place p1, after t1 fires, the token (Susan Hill, 34, 500, F, single, Phd, 8, X, 0) will be removed from the place p1, a new token (Susan Hill, 34, 750, F, single, Phd, 8, “A”, 0) will be added to the downstream place p2.
4
An Example
Example 1. There are 6 rules in an active database. Rule 1 on insert employee if e.degree = “Phd” then modify e.status = “A” and e.salary = e.salary * 1.50 Rule 2 on insert employee if e.degree = “Master” then modify e.status = “B” and e.salary = e.salary * 1.25
A Structural Model of ECA Rules in Active Database
491
Fig. 3. CCPN model of Rule 1
Rule 3 on insert employee if e.degree = “Bachelor” then modify e.status =“C” and e.salary = e.salary * 1.10 Rule 4 on insert employee if e.salary > manager.salary then modify e.salary = manager.salary-100 Rule 5 on insert employee if e.sex = “F” then modify e.hours per day = e.hours per day - 2 Rule 6 on modify e.hours per day if e.marital status = “married” then e.bonus = 100 Note that this example is constructed by the authors, such problems as inconsistence may exist. Here we just want to illustrate the developed CCPN model. In fact, such problems could be resolved by PN based analysis or other approaches, which is not the content of this paper.
492
Xiaoou Li, Joselito Medina Mar´ın, and Sergio V. Chapa
Fig. 4. CCPN model of Rule 6
CCPN models of Rule 1, 4 are shown as Fig. 3, 4. CCPN model of all the six rules is shown as Fig. 5.
5
Conclusion and Future Work
In this paper we propose a modified colored Petri net model Conditional Colored Petri Net (CCPN) model for ECA rules in active database. CCPN is a structural model for active rules rather than a rule language. In an active database, relation between rules is very important, CCPN can model both rules themselves and this complicated relation in an graphical way. CCPN model development is the first step of our investigation on this direction. Based on this model, we will give methods to predict active rule behavior and analyze desired properties of active rules such as termination, confluence, etc.. A software platform on connecting our model and POSTGRES is being planned too.
References 1. Paton N.W., Diaz O., “Active Database Systems”, ACM Computing Surveys, Vol. 31, No. 1,1999, pp. 64-103 2. Chakravarthy S., “Early Active Database Efforts: A Capsule Summary”, IEEE Transactions on Knowledge and Data Engineering, Vol. 7, No. 6, 1995, pp. 1008-1010
A Structural Model of ECA Rules in Active Database
493
Fig. 5. CCPN model of all rules
3. Schlesinger M. and L¨ orincze G., Rule modeling and simulation in ALFRED, the 3rd International workshop on Rules in Database (RIDS’97) (or LNCS 1312), Sk¨ ovde, Sweden, June, pp. 83-99, 1997 4. Guisheng Y., Qun L., Jianpei Z., Jie L., Daxin L., “Petri Based Analysis Method For Active Database Rules”, IEEE International Conference on Systems, Man and Cybernetics, vol. 2, 1996, pp. 858-863 5. Li X. and Chapa S. V., Optimization of Deductive Database System by Adaptive Fuzzy Petri Net Approach, IASTED International Conference on Artificial Intelligence and Soft Computing (ASC2001), Cancun, Mexico, May 21-24, 2001, pp. 6-11 6. Barkaoui K. and Ma¨izi Y., Efficient answer extraction of deductive database modeled by HLPN, 8th International Conference on Database and expert systems applications (DEXA’97), Toulouse, France, September 1-5, 1997 (also LNCS vol. 1308), pp. 324336 7. Jensen K., “An Introduction to the Theoretical Aspects of Colored Petri Nets”. Lecture Notes in Computer Science: A Decade of Concurrency, vol. 803, edited by J. W. de Bakker, W.-P. de Roever, G. Rozenberg, Springer-Verlag, 1994, pp. 230-272