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 Delete operations, to help ensure the validity of the data.

Update Rules view

This is the Update Rules view which you see when the Update Rules folder in the navigation tree view is selected. 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 a 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 buttons named Up and Down 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 / Editing an Update Rule

The principal way is available on the Update Rules View, available when you left click on the Update Rules folder in the navigation tree view. Click on the "Add New UpdateRule" button, or you can also right click on the Update Rules folder and select the "Add new Update Rule" button.

The view then changes so you can configure the update rule to your needs.

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 click on an existing rule.

The Update Rule Name is mandatory and must be a unique string.

The On Table you choose the table the rule applies to from the drop down box, which shows the tables available in the schema.

You then specify what action the rule is for. Available options are Do Insert, Do Update and Do Delete. 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 final configuration option is to specify what the Failure Behavior should be. The default is Raise an Exception which will raise and return an exception to the client application. Other options are to Log & Continue which logs the problem in the server log and then continues processing, or Ignore & Continue 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:

DataTable Name Command
Customer Insert + Update
Order Insert + Update
Order Delete
Customer Delete