Promoting Data Integrity Through Rules

From ER/Studio Data Architect
Jump to: navigation, search

Go Up to Using ER/Studio Data Architect

Rules promote data integrity by validating the data supplied to an attribute or table column. For example, you could define a rule, NotLessThanZero, which specifies that data values for an attribute or column be zero or greater. Once bound to a table column, the rule would reject any transactions that supply a negative value to the table column. Rules are independent database objects that behave like check constraints, but can be re-used throughout your data model.

Rules, like Defaults in the Data Dictionary let you manage and reuse commonly used rules. Rules can be bound to other dictionary objects such as datatype or UDTs as well as attributes/columns. Rules can be created directly in the domain or under the Rules node.

Example

If you have a generic constraint that will apply to many fields, you can create a domain that will allow you to specify the constraint in that domain. You can use a place-holder for the column in the table. Use @var to substitute the column name. The column name replaces @var when a rule in the data dictionary is bound to a column.

For example, a rule was created in the Pubs.dm1 sample model, with the following syntax:

UPPER(@var) in ('Y', 'N')

When that rule is bound to column au_id as follows:

RuleBinding.gif

the rules translates to:

UPPER(au_id) in ('Y', 'N')

as shown in the Check Constraint Value area in the following screenshot:

Rule Constraint.gif

Create and Edit Data Dictionary Rules

  1. On the Data Model Explorer, click the Data Dictionary tab.
  2. On the Data Dictionary tab, right-click the Rules node and then select New Rule.
  3. Complete the Add/Edit Dictionary Rule Editor as required and then click OK to implement the changes.
  4. Once created, you can edit the rule by double-clicking it to launch the editor.

The following describe options that require additional explanation:

Rule Value tab

Specifies the rule. You must specify the rule value in the same syntax as the database platform in which you intend to use the rule.

Attachment Bindings tab

Bind an external piece of information, or attachment to the rule. You can also remove an attachment from an object, override an attachment binding's default value, or change the position of a bound attachment. To override the value of the attachment you have moved to the Selected Attachments grid, double-click the Value field of the target attachment. ER/Studio Data Architect opens the Value Override Editor or a list depending on the attachment datatype. Attachments are created in the Attachments folder of the Data Dictionary and must be applied to the default before they will display on this tab. For more information, see Attaching External Documents to the Data Model.

Binding Information tab

Select the object classes and/or specific objects to which you want to bind this rule. You can override this setting using the Rule/Constraint tab of the object class editor.

See Also