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 flausenludaeschmayginfo rmat ikun ifr eibur gde Abstract After briey 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 Subsequentlywe present our own stateoriented logical approach to ac tive rules which combines the declarative semantics of deductive rules with the p ossibility to dene 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 eventde tection and dierent coupling mo des Thus it can b e used for the formal analysis of rule prop erties like termination and expressivepo wer Finally weshowhow nested transactions can b e mo deled in Statelog b oth from the op erational and the mo deltheoretic p ersp ective 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 Min Today there is a plethora of quite dierent appli cation areas and semantics for rules From a birdseye 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 stratied well RDL pro ARDL Ariel Starburst Postgres founded Datalog cedural Datalog Fig Sp ectrum of database rule languages adapted from Wid On the one end of the sp ectrum deductive rules provide a concise and elegant representation of intensionally dened data Recursive views and static integrity constraints can be sp ecied 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 Springer nonmonotonic reasoning whichsubstantiates the claim that deductive rules are rather highlevel and mo del a kind of natural reasoning pro cess However deductive rules do not provide enough expressivenessorcontrol to directly sup p ort the sp ecication 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 dierent rule paradigms in databases in Figure and survey a number of formal and logical approaches to activerulesWe then present a sp ecic stateoriented logical approach to active rules called Statelogwhich yields a precise formal semantics for active rules It can b e shown that certain pro duction rules and deductiverules are sp ecial cases of Statelog rules and that many but not all features of active rules like comp osite event detection and dierent coupling mo des can b e sp ecied in Statelog Thus Statelog can serveas a unied 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 wayThe main technical contribution of this pap er is the continuation and renement of LML where a mo deltheoretic Kripkestyle 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 werstintro duce the basic terminology and features of active rules and then briey relate them to pro duction rules and deductive rules resp ectively Section is a short survey on some formal approaches to active rules In Section we intro duce Statelog a stateoriented 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 Starting from a simple mo del for at transac tions the framework is extended subsequently to incorp orate nested transactions Section Section develops an abstract conceptual mo del for Statelog with nested transactions by a mo deltheoretic Kripkestyle semantics Some conclud ing remarks are given in Section Rules in Databases Rules in database programming languages come in many dierentavors In this section we discuss language issues of the ab ovementioned rule sp ectrum and highlight dierences b etween the paradigms Active Rules Active rules are typically expressed as EventConditionAction ECA rules of the form on heventi if hcondition i then haction i Whenever the sp ecied event o ccurs the rule is triggered and the corresp onding action is executed if the condition is satised 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 classied as internal or external Internal events are caused by database op erations like retrieval or up date insertion deletion mo d ication 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 ecied using an event algebra typical op erators are disjunction E jE sequence E E conjunction E E etc cf CKAKSin may be Alternatively logics like past temp oral logic see eg LSChob used for the sp ecication of comp osite events Several event detection algorithms havebeendevelop ed which allow to detect comp osite events without storing the complete database history for instance by applying temp oral reduction rules LSChob or residuation Sin 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 bythe comp osite event This event consumption policy is elab orated using parameter contexts whichwere intro duced for the SNOOP algebra in CKAKCM In order to illustrate the dierent 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 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 Dierent 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 CKAK 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 fG F H g Chronicle In this context events are consumed in their chronological order In a sense this corresp onds to a rstinrstout strategy E will b e rep orted H g and for fF G H g for fG F 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 byseveral 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 rep orted The comp osite event initiated at F is still to b e completed Cumulative In this context all o ccurrences of constituentevents are accu mulated until and consumed when the comp osite event is detected In the example E is raised once for the constituentevents fG F F G F H g Unrestricted In this context constituentevents are not consumed but are reused arbitrarily many times For the ab ove history E is rep orted for all twelve p ossible combinations of fF G H g j k l Conditions If the triggering event of an active rule has been detected the rule b ecomes eligible and the condition part is checked The condition can b e a conventional SQLlike query on the current state of the database or it may include transition conditions ie conditions over changes in the database state The p ossibility to refer to dierent states or delta relations