On Active Deductive Databases
Total Page:16
File Type:pdf, Size:1020Kb
On Active Deductive Databases: ? The Statelog Approach Georg Lausen Bertram Ludascher Wolfgang May Institut fur Informatik, Universitat Freiburg, Germany flausen,ludaesch,mayg@info rmat ik.un i-fr eibur g.de Abstract. After brie y reviewing the basic notions and terminology of active rules and relating them to pro duction rules and deductive rules, resp ectively,we survey a number of formal approaches to active rules. Subsequently,we present our own state-oriented logical approach to ac- tive rules which combines the declarative semantics of deductive rules with the p ossibility to de ne up dates in the style of pro duction rules and active rules. The resulting language Statelog is surprisingly simple, yet captures many features of active rules including comp osite event de- tection and di erent coupling mo des. Thus, it can b e used for the formal analysis of rule prop erties like termination and expressivepower. Finally, we showhow nested transactions can b e mo deled in Statelog, b oth from the op erational and the mo del-theoretic p ersp ective. 1 Intro duction Motivated by the need for increased expressiveness and the advent of new appli- cations, rules have b ecome very p opular as a paradigm in database programming since the late eighties [Min96]. Today, there is a plethora of quite di erent appli- cation areas and semantics for rules. From a bird's-eye view, deductive and active rules may b e regarded as two ends of a sp ectrum of database rule languages: Deductive Rules Production Rules Active Rules \higher" level \lower" level RDL1, pro- strati ed, well- A-RDL Ariel Starburst Postgres :::::: :: :::: :::::: :::::: :::::: : : cedural Datalog founded Datalog Fig. 1. Sp ectrum of database rule languages adapted from [Wid93 ] On the one end of the sp ectrum, deductive rules provide a concise and elegant representation of intensionally de ned data. Recursive views and static integrity constraints can be sp eci ed in a declarative and uniform way using deductive rules, thereby extending the query capabilities of traditional relational languages like SQL. Moreover, the semantics develop ed for deductive rules with negation are closely related to languages from the eld of knowledge representation and ? In: Transactions and Change in Logic Databases, B. Freitag, H. Decker, M. Kifer, and A. Voronkov, editors, LNCS 1472, Springer, 1998 nonmonotonic reasoning, which substantiates the claim that deductive rules are rather \high-level" and mo del a kind of natural reasoning pro cess. However, deductive rules do not provide enough expressiveness or control to directly sup- p ort the sp eci cation of up dates or active b ehavior. Since up dates play a crucial role even in traditional database applications, numerous approaches have b een intro duced to incorp orate up dates into deductive rules. In contrast to deductive rules, active rules supp ort reactive b ehavior like triggering of up dates as a resp onse to external or internal events. Conceptually, most rule languages for active database systems ADBs are comparatively \low- level" and often allow to exert explicit control on rule execution. While such additional pro cedural control increases the expressive power of the language considerably, this is also the reason why the b ehavior of active rules is usually much more dicult to understand or predict than the meaning of deductive rules. Not surprisingly, researchers continue to complain ab out the unpredictable b ehavior of active rules and the lack of a uniform and clear semantics. Production rules constitute an intermediate family of languages and provide facilities to express up dates and some asp ects of active b ehavior, yet avoid overly detailed control features of active rules at the right end of the sp ectrum. Contributions and Overview. In this pap er, we intro duce to the di erent rule paradigms in databases in Figure 1, and survey a number of formal and logical approaches to active rules. We then present a sp eci c state-oriented logical approach to active rules called Statelog, which yields a precise formal semantics for active rules. It can b e shown that certain pro duction rules and deductive rules are sp ecial cases of Statelog rules, and that many but not all features of active rules like comp osite event detection and di erent coupling mo des can b e sp eci ed in Statelog. Thus, Statelog can serveas a uni ed logical framework for active and deductive rules, in which fundamental prop erties of rules like termination b ehavior, complexity, and expressiveness can b e studied in a rigorous way. The main technical contribution of this pap er is the continuation and re nement of [LML96], where a mo del-theoretic Kripke-style semantics for Statelog in the context of a nested transaction mo del has b een presented. The pap er is organized as follows: In Section 2, we rst intro duce the basic terminology and features of active rules, and then brie y relate them to pro- duction rules and deductive rules, resp ectively. Section 3 is a short survey on some formal approaches to active rules. In Section 4, we intro duce Statelog, a state-oriented extension of Datalog and summarize the main results. A key idea of the approach is to add a state argument to every predicate: for example, [s] px; y intuitively means that px; y holds in state [s] this idea has come up several times; see Section 3.2. Starting from a simple mo del for at transac- tions, the framework is extended subsequently to incorp orate nested transactions Section 5. Section 6 develops an abstract, conceptual mo del for Statelog with nested transactions by a mo del-theoretic Kripke-style semantics. Some conclud- ing remarks are given in Section 7. 2 2 Rules in Databases Rules in database programming languages come in many di erent avors. In this section, we discuss language issues of the ab ove-mentioned rule sp ectrum and highlight di erences b etween the paradigms. 2.1 Active Rules Active rules are typically expressed as Event-Condition-Action ECA rules of the form on heventi if hcondition i then haction i. Whenever the sp eci ed event o ccurs, the rule is triggered and the corresp onding action is executed if the condition is satis ed in the current database state. Rules without the event part are sometimes called production rules, rules without the condition part are sometimes referred to as triggers. Events. Events can be classi ed as internal or external. Internal events are caused by database op erations like retrieval or up date insertion, deletion, mo d- i cation of tuples, or transactional events like commit or ab ort. In ob ject- oriented systems, such internal events may take place through metho d invo- cations. External events o ccurring outside the database system may also be declared and have to b e monitored by the ADB. Starting from primitive external or internal events, more complex composite events can b e sp eci ed using an event algebra ;typical op erators are disjunction E jE , sequence E ; E , conjunction E ;E , etc. cf. [CKAK94,Sin95]. 1 2 1 2 1 2 Alternatively, logics like past temp oral logic see e.g., [LS87,Cho95b] may be used for the sp eci cation of comp osite events. Several event detection algorithms have b een develop ed which allow to detect comp osite events without storing the complete database history, for instance by applying temp oral reduction rules [LS87,Cho95b] or residuation [Sin95]. A question arising from the use of comp osite events is which of the constituent events \take part" in the comp osite event and how they are \consumed" by the comp osite event. This event consumption policy is elab orated using parameter contexts, whichwere intro duced for the SNOOP algebra in [CKAK94,CM94]. In order to illustrate the di erent parameter contexts, consider the comp osite event E := F; G; H , which o ccurs if H o ccurs after b oth F and G have o ccurred. Assume the following event history is given: G F F G F H H 1 1 2 2 3 1 2 j j j j j j j t Here, the F 's denote several o ccurrences of the same primitiveevent F , similarly j for G and H . k l 3 Di erent parameter contexts are motivated by applications where constituent events should b e consumed by the comp osite event in a certain way. The following parameter contexts have b een prop osed [CKAK94]: Recent: In this context, only the most recent o ccurrences of constituent events are used; all previous o ccurrences are lost. In the ab ove event his- tory, E will b e raised twice: for the constituentevents fG ;F ;H g and for 2 3 1 fG ;F ;H g. 2 3 2 Chronicle: In this context, events are consumed in their chronological order. In a sense, this corresp onds to a rst-in- rst-out strategy: E will b e rep orted for fG ;F ;H g and for fF ;G ;H g. 1 1 1 2 2 2 Continuous: In this context, each event which may initiate a comp osite event starts a new instance of the comp osite event. A constituentevent can b e shared by several simultaneous o ccurrences of the comp osite event. In the example, each G and each F starts a new instance. Thus, the comp osite i j o ccurrences fG ;F ;H g, fF ;G ;H g, fF ;G ;H g, and fG ;F ;H g are 1 1 1 1 2 1 2 2 1 2 3 1 rep orted.