Active Databases and Triggers


Active Databases and Triggers

• Triggers is a technique for specifying certain types of
active rules.
• The Event-Condition-Action (ECA) is a model for
specifying active database rules. A rule in ECA model
has three components:
1) The event would be a database update operations, temporal
events, or other kinds of external events.
2) The condition determines whether the rule action should be
executed.
3) The action is a sequence of SQL statements, transactions, or
an external program that will be automatically executed.



• Maintaining the correct value for TOTAL_SAL can be
done via an active rule. The events that may cause a
change in the value of TOTAL_SAL are:
1) Inserting new employee tuples.
2) Changing the salary of existing employees.
3) Changing the assignment of existing employees from one
department to another.
4) Deleting (one or more) employee tuples.

The optional FOR EACH ROW clause is known as a
row-level trigger (i.e., the rule is triggered separately
for each tuple).
• If FOR EACH ROW clause was left out, the trigger
would be known as a statement-level trigger (i.e., the
rule would be triggered once for each triggering
statement).
• The keywords NEW and OLD can only be used with
row-level triggers.

Design Issues for Active Databases:

• The first issue concerns, activation, deactivation, and
grouping of rules.
– The activate command will make the rule active again.
– The deactivate command will make the trigger event not be
triggered.
– The delete command deletes the rule from the system.
– Therule set option can be used to group rules (so, the whole
set of rules can be activated, deactivated, or dropped).
– The PROCESS RULES command can trigger a rule or rule
set.

• The second issue concerns whether the triggered action
should be executed before, after, or concurrently
with the trigger event.
• A related issue is whether the action being executed
should be considered as a separate action or whether
it should be part of the same transaction that
triggered the rule.
• The rule condition evaluation is also known as rule
consideration.

• Three main possibilities for rule consideration:
1) Immediate consideration: the condition is evaluated as part
of the same transaction as the trigger event, and is evaluated
immediately; in one of the following forms
a) Before executing the trigger event.
b) After executing the trigger event.
c) Instead of executing the trigger event.
2) Deferred consideration: the condition is evaluated at the end
of transaction that include the trigger event.
3) Detached consideration: the condition is evaluated as a
separate transaction.

• Difficulties with using active rules:
1) To verify that a set of rules is consistent.
2) To guarantee termination of a set of rules under all
circumstances.
Potential applications for Active Databases

• To allow notification of certain conditions that occur
(e.g., to monitor the temperature of an industrial
furnace).
• To enforce integrity constraints by specifying the
types of events that may cause the constraints to be
violated.
• Automatic maintenance of derived data (e.g., the
derived attribute TOTAL_SAL in the simplified
version of Company schema).










Comments

Popular posts from this blog

Handling of Skew

Fragment-and-Replicate Join

USER INTERFACE DESIGN FOR ANNA UNIVERSITY SYLLABUS