Monday, April 6, 2020

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:
  1. Inserting (one or more) new employee tuples
  2. Changing the salary of (one or more) existing employees
  3. Changing the assignment of existing employees from one department to another
  4. 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-

  1. Triggering capability enhances the functionality of traditional databases as mentioned above.
  2. 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. 

18 comments:

  1. Wonderful blog on an interesting topic . Great work!

    ReplyDelete
  2. The example cleared my doubts about active databases clearly . Thanks and keep up the great work

    ReplyDelete
  3. I Don't read many technical blogs but this one was quite invigorating. Nice piece!

    ReplyDelete
  4. This blog was very much helpful for me......very well compiled!

    ReplyDelete
  5. Nice blog. I liked the way you have put emphasis on small details.

    ReplyDelete
  6. Very useful and nicely explained

    ReplyDelete
  7. I had read many blogs regarding active database but nowhere find systematic explanation of it. But in this blog it is very well explained and it is very good.

    ReplyDelete
  8. Nice blog made many things crystal clear

    ReplyDelete
  9. Very informative blog. A clean and systematic explaination.

    ReplyDelete
  10. Very well explained and in a proper manner and interesting to read.

    ReplyDelete
  11. Very much useful and proper explained.

    ReplyDelete
  12. Very informative and well researched blog.

    ReplyDelete
  13. I read and write many tech blogs but I must say I am impressed with this one !!

    ReplyDelete