Triggers

A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database. For example, when a new record (representing a new worker) is added to the employees table, new records should also be created in the tables of the taxes, vacations and salaries.

Triggers List

The triggers list display shows the database table triggers created by the component.

It does not show any triggers created by another mechanism, unless they happen to contain the specific string 'audit' within their name.

Triggers are names after the table upon which they are applied, followed by the specific string '_audit_' and then by a two character string, the first of which indicates whether it is a 'BEFORE' (b) or 'AFTER' (a) trigger, and the second indicates whether it is applied on an 'INSERT' (i), 'UPDATE' (u) or 'DELETE' operation.'

The screen also allows a single point where triggers may be enabled, which is where the trigger is created within the database. Disabling the trigger removes the trigger from the database.

[Important]Important

MySQL has a few restrictions upon triggers which may be briefly summarised as follows: Only one trigger of any specific type is possible upon any given table. Triggers if present are automatically enabled. Triggers can not be disabled. Disabling a trigger requires the trigger be deleted.

The screen can also used to delete triggers. Deletion of a trigger not only removes it from the database (disabling), but also removes all trace of the trigger from the component.

Figure 5.3. Triggers List

Triggers List