Previous Topic: Referential Integrity Triggers (RI Triggers)Next Topic: DBMS Support for Triggers


Referential Integrity to Enforce Business Rules

Business rules are logical constructs that express how a business uses its data. You can use a set of built-in referential integrity (RI) options to capture common business rules that apply to relationships between data that you maintain in different tables. You can enforce the rules using a variety of different programming techniques, including the following:

One of the best ways to enforce RI rules is through the use of triggers. Unlike the coding in front-end applications, triggers are centrally located, so that if the business rule changes, the change can be implemented once. Triggers also support the enforcement of additional rules, beyond those supported by declarative referential integrity. For example, in an Order Entry database, if you want to flag backorder items when creating a row in the CUST_ORDER table, you can create a custom trigger to check a quantity_on_hand value for a product when inserting a row into the ORDER_LINE table.

CA ERwin Data Modeler triggers can handle the most common rules for enforcing referential integrity without any additional programming or customization. For example, the question, "Can I delete an order that has one or more order line details?" can be answered by a business rule and can be enforced by a built-in trigger. If the business answer to the question is:

In a similar way, the business rule might specify that the dependent rows in the child ORDER_LINE table should not be deleted when the row in the CUST_ORDER table is deleted, but that the foreign key value should be set to NULL or to a default value. You can handle each of these situations using CA ERwin Data Modeler-generated triggers.

More information:

Triggers

Set Default Referential Integrity Rules