Database Trigger

A database trigger is procedural code that is automatically executed in response to certain events such as inserts/deletes/updates on a particular base or derived relvar (i.e. a view) in a database.

Note that allowing triggers on changes to views is very powerful. The views can be non-injectve functions of the base representation (i.e. they can hide information). Views involve the full power of the relational algebra to tranform the underlying base representation, providing complete control over what information is visible to consumers of the information.

It's useful for applications/services to be able to define asynchronous triggers. Furthermore this should allow for EOIO (exactly once in order) processing of the state changes.

The combination of database replication and database triggers provide a simpler alternative to event messaging.

For a DBMS this represents a small overhead - the DBMS already deals with changes to the data - for example it typically uses a log to represent changes to the data to implement atomicity and recovery.

See how database triggers feature in the recommended approach to implementing long running business processes.