Triggers are particularly useful when certain business rules should always be enforced across applications. These rules may exist because data in one table is related to data in other tables. If there is ever a change in the rules, you need only change the trigger definitions at the database, and all applications will follow the new rules without any additional changes required.
A very good example of such a rule was demonstrated in the L8NITE application. Recall that when the cashier scans and adds a product at customer checkout, the product information is inserted into the PRODUCT_PURCHASES table. In the same transaction, the product inventory is also updated. Similarly, for a refund request, the same business rule applies. The information for the product being returned is inserted into the PRODUCT_PURCHASES table. The application updates the product inventory to reflect this change. Rather than code such logic repeatedly in different parts of the application, we can move it to a trigger, allowing the trigger action to take care of the product
0 comments:
Post a Comment