@TECHREPORT{R-95-27, PSURL = {/publications/cgi-bin/tr-fetch.pl?r-95-27+ps}, NUMBER = {R-95-27}, INSTITUTION = ida, ADDRESS = idaaddr, YEAR = {1995}, AUTHOR = {Sk{\"o}ld, Martin and Falkenroth, Esa and Risch, Tore}, TITLE = {Rule Contexts in Active Databases - A Mechanism for Dynamic Rule Grouping}, ABSTRACTURL = {/publications/cgi-bin/tr-fetch.pl?r-95-27+abstr}, ABSTRACT = {Engineering applications that use Active DBMSs (ADBMSs) often need to group activities into modes that are shifted during the execution of different tasks. This paper presents a mechanism for grouping rules into contexts that can be activated and deactivated dynamically. The ADBMS monitors only those events that affect rules of activated contexts. By dynamic rule grouping the set of monitored rules can be changed during the transactions. In a static rule grouping the rules are associated with specific objects during the schema definition. A rule is always activated into a previously defined context. The same rule can be activated with different parameters and into several different contexts. Rules in a context are not enabled for triggering until the context is activated. However, rules can be directly activated into a previously activated context. When rule contexts are deactivated all the rules in that context are disabled from triggering. The user defined contexts can be checked at any time in a transaction. Rule contexts can be used as a representation of coupling modes, where the ADBMS has built-in contexts for immediate, deferred, and detached rule processing. These built-in coupling modes are always active and are automatically checked by the ADBMS. Contexts and rules are first-class objects in the ADBMS. Database procedures can be defined that dynamically activate and deactivate contexts and rules to support dynamically changing behaviours of complex applications. The context mechanism has been implemented in the AMOS ADBMS. The paper concludes with an example of a manufacturing control application that highlights the need for rule contexts.}