Your Relational Database Can Do More than Store Data
Please note: This post originally appeared on Extol.com (EXTOL has been acquired by Cleo).
It is easy to think of the database as just a place to store data in a structured and shareable way, but modern relational databases can do more than that. For example, triggers are a feature that let you define an action to be performed when certain events occur within the database, such as when a new record is inserted, updated, or deleted from a table.
Triggers can be useful when you don’t have control over the application using the database, but you do have control of the database itself. This is actually a common scenario because many application vendors don’t ship their own database; instead, they connect to an existing database and create the tables their application requires when they are installed. This is valuable because it lets you integrate off-the-shelf applications. For example, perhaps you have an application where you normally add and maintain customer information. You also have another application that needs some customer information, such as their name and address for shipping, and it tracks that data within its own table. By using triggers on the insert and update of the address data, you can automatically add and keep synchronized the data for the shipping application.
Some of the other common uses for triggers include: adding an audit trail or sending email notifications when certain critical records are changed, helping to enforce database integrity by rejecting changes that have invalid field values or automatically converting older codes to a new one and forwarding events on to another application that monitors changes to help detect business trends in real time.