Active Databases
Active Databases
DATABASES
A PRESENTATION BY
3
PROBLEM WITH TRADITIONAL DATABASE
SYSTEMS: EXAMPLE
7
ACTIVE DATABASES
• Active databases support the preceding application by moving
the reactive behavior from the application (or polling
mechanism) into the DBMS.
• Active databases are thus able to monitor and react to specific
circumstances of relevance to an application.
• An active database system must provide a knowledge model
(i.e., a description mechanism) and an execution model
(i.e., a runtime strategy) for supporting this reactive behavior.
8
ACTIVE DATABASES
1. Active DBMS provides: Regular DBMS primitives + definition of
application-defined situations + triggering of application-defined
reactions
‣ being able to react automatically to situations in the database
‣ allowing the specification and implementation of reactive behavior
2. Active DBMS
• Embed situation-action rules in database
• Support many functionalities:
E.g. Integrity control, derived data, change notification
9
• Active DBMS functionality commercially available in SQL:99 as triggers
ACTIVE DATABASES
10
ACTIVE DATABASES
T1: 25 copies of
Korth sold
On update of sales
when 11
Quantity <5
TRIGGERS
• Triggers is a concept that is technique for specifying certain
types of active rules in the database.
• A data base that has a set of associated triggers is called an
active data base.
• Trigger is like a procedure that is automatically invoked by the
DBMS in response to specified changes to data base.
• Trigger is like a ‘Daemon that monitors a data base, and is
executed when the data base is modified in a way that matches
the event specification
12
TRIGGER PARTS
Triggers work in ECA model. It has three parts:
• Event : A change to data base that activates the trigger
• Condition: A trigger restriction specifies a Boolean
(logical) expression must be TRUE for the trigger to fire
• Action: A procedure that is executed when the trigger is
activated. Similar to stored procedures, a trigger action can
contain PL/SQL statements
13
TYPES OF TRIGGERS
An SQL statement may change several rows.
• Apply action once per SQL statement.
• Apply action for each row changed by SQL statement.
Row Triggers
• A row trigger is fired each time the table is affected by the triggering
statement.
• If a triggering statement affects no rows, a row trigger is not executed at all.
Statement Triggers
• A statement trigger is fired once on behalf of the triggering statement,
regardless of the number of rows in the table that the triggering statement
affects (even if no rows are affected) 14
TRIGGER TIMINGS
Actions may apply before or after the triggering event is
executed.
Before Trigger
• Execute the trigger action before the triggering statement.
• Eliminate unnecessary processing of the triggering statement.
After Trigger
• AFTER triggers are used when you want the triggering
statement to complete before executing the trigger action 15
AVAILABILITY
16
CREATING A TRIGGER
20
ACTION
The range of tasks that can be performed if the rule condition
is evaluated to be true.
It is usually a sequence of SQL statements.
But actions may:
• Perform some behavior invocation within the database or an
external call,
• inform the user or system administrator of some situation,
• abort a transaction,
• take some alternative course of action using do-instead
21
EXECUTION MODEL OF ACTIVE DATABASES
22
EXECUTION MODEL OF ACTIVE DATABASES
Whenever the department number changes, all employee records for this
department will automatically be changed as well, so that the employees
will continue to work for the same department.
31
CONTROLLING TRIGGERS USING SQL
32
Compensation and
Databases Recovery
33
1. Introduction to Database Recovery
2. Types of Failures in Databases
3. Compensation and Logging Mechanisms
4. Database Recovery Techniques (Examples)
5. Real-World Applications (With Case Studies)
6. Challenges and Solutions in Database
Recovery 34
Introduction to Database Recovery
41
Two-Phase Commit Protocol (2PC)
43
Real-World Applications
Challenges:
- Managing large volumes of data.
- Balancing consistency with availability.
- High costs for advanced recovery systems.
Solutions:
- Use of advanced log processing algorithms and
distributed recovery protocols. 45
Conclusion
46
Thank you