Introduction:
Active Databases management system has recently become a very attractive database research topic. Many different systems and models have been proposed which claim to be active. However, it is still unclear what the term “active database management system” really means. Under which condition can you legitimately claim that your system is “active”?
So, here we try to explore some of the key features of active databases.
Active database from passive database by writing trigger
|
What is Active Databases?
A database that has ability to spontaneously react to event occurring inside as well as outside the system is called active database. Any active
database follows generalized model which is called ECA-rules consists of
events, conditions and actions. The meaning of such a rule is: “when an event
occurs, check the condition and if it holds, execute the action”. Other terms
are used synonymously as triggers. If we see the conventional databases which
are also called as passive databases and ADBMSs extend “passive” DBMS with the
possibility to specify reactive behavior by writing the triggers.
What is a trigger?
Trigger is like procedure that is automatically invoked by the
DBMS in response to specified change to database. A database that has set
associated triggers is called an active database.
Need of active databases
Let’s take a real world example such as BOOKING AN ONLINE TICKET.
When a person books the seats whose current status is ‘available’, at the same
time that seat status has to be changes to ‘booked’ so that other person can’t
book the same seat. In this situation we may write a trigger such that when
seat booking is confirmed the trigger is initiated and change the current
status from ‘available’ to ‘booked’.
Levels of granularity
There are basically two types of trigger-
- Row-level trigger:Trigger which executes on every change (Update/Delete/Insert) in row for which condition is satisfied is known as row-level trigger
- Statement-level trigger: Trigger which executes only once per statement is called as statement-level trigger.
Triggering Types:
- Before Triggering - Executed before the modification of a row.
- After Triggering - Executed after the modification.
Example of Active database-
Lets take an examples are based on a much simplified variation of the company database application,
employee(Name, Ssn, Salary, Dno, Superviser_ssn)
department(Dname, Dno, Total_sal, Manager_snn)
Security number (Ssn), salary (Salary), department to which they are currently assigned (Dno, a foreign key to DEPARTMENT), and a direct supervisor (Supervisor_ssn, a (recursive) foreign key to EMPLOYEE). For this example, we assume that NULL is allowed for Dno, indicating that an employee may be temporar-ily unassigned to any department. Each department has a name (Dname), number (Dno), the total salary of all employees assigned to the department (Total_sal), and a manager (Manager_ssn, which is a foreign key to EMPLOYEE).
Notice that the Total_sal attribute is really a derived attribute, whose value should be the sum of the salaries of all employees who are assigned to the particular department. Maintaining the correct value of such a derived attribute can be done via an active rule. First we have to determine the events that may cause a change in the value of Total_sal, which are as follows:
- Inserting (one or more) new employee tuples
- Changing the salary of (one or more) existing employees
- Changing the assignment of existing employees from one department to another
- Deleting (one or more) employee tuples
Application of Active Databases:
Applications which depends on data monitoring are majorly depends on active database, some of which are as below-
- Production Control
- Maintenance task. e.g. inventory control
- Financial applications. e.g. stock and bond trading
- Air traffic control
- Telecommunication and network management.
Advantages of using Active Databases-
- Triggering capability enhances the functionality of traditional databases as mentioned above.
- The interface power of ECA rules makes active database systems a suitable platform for building large and efficient knowledge base and intelligence system.
So, this is basic idea for Active database and triggers.