Managing Update Rules
Update Rules are used to give your server control over the order in which updates are applied to tables. When no update rules are specified, which is the default state, then Data Abstract will process the delta updates in the order in which they are received.
However there are situations where a more complicated approach is required, particularly if there are dependencies or relationships that exist between tables. This is where update rules come in.
An Update Rule specifies what actions are allowed on a table at a particular time. This allows you to build a chain where
Inserts occur first on particular tables, before
Update Rules view
This is the Update Rules view which is available when you click on the Update Rules folder in the Schema tree. The view shows any rules that you have already created and provides a quick overview of the table that the rule is for, what actions it affects and an description. This view also provides a means to re-order the rules so that its in the order that you want them. Select the rule in the table and the press the green Up/Down arrows to change the position of the rules. Those at the top are executed before those at the bottom.
Lastly you can create and delete update rules from this view.
Creating an Update Rule
The principal way is available on the Update Rules View, available when you click on the Update Rules folder in the Schema tree. Click on the "Add Update Rule" button, or you can also right click on the Update Rules folder and select the Add button.
After that the view changes to allow you to configure the update rule to your needs.
Configuring Update Rules
The configuration for an update rule is minimal. You will either be automatically taken to this view when you create a new rule, or when you double-click on an existing rule.
The Update Rule Name is mandatory and must be a unique string, however the Description can be set to whatever you would like.
The Rules specify which actions this rule is used for. Typically if multiple tables are related, you would have rules for insert /update first for both tables, and then delete actions in a separate rule.
The Data Table Name is the name of a table in the current Schema. You choose the table you wish from a drop down box, rather than typing the name.
The final configuration option is to specify what the Failure Behavior should be. The default is RaiseException which will raise and return an exception to the client application. Other options are to LogAndContinue which logs the problem in the server log and then continues processing, or IgnoreAndContinue which will cause Relativity to completely ignore the issue and carry on processing.
Example of Rules order
Getting the order of the Update Rules is important when you are dealing with related tables.
As an example, suppose you have two tables, a Customer Table and an Order table. The Customer table should be acted on first when adding or updating a record, then the Order table should be. However for a delete operation the reverse is true, the Order record should be deleted first before the customer is to prevent any orphan records.
In a visual form, you would want update rules that looked something like this:
|Customer||Insert + Update|
|Order||Insert + Update|