Attribute rules enhance the editing experience and improve data integrity for geodatabase datasets. They are user-defined rules that can be used to automatically populate attributes, restrict invalid edits during edit operations, and perform quality assurance checks on existing features.
Attribute rules are complementary to existing rules used in the geodatabase, such as domains and subtypes. For example, domains can be assigned to an attribute field to aid in the data collection process by providing a list of valid values for editors. Additionally, an attribute rule can be used to restrict values for an attribute field that are not part of the domain when performing a field calculation. After rules are added to a dataset, they can be evaluated as edits take place or at a later time.
The following are examples of how attribute rules can be used in a geodatabase:
- To save time during editing, specific attribute values are automatically populated for newly created features. For example, when a pole is created, the assetID attribute is generated based on a sequence.
- To help enforce data integrity, edits can be blocked based on a user requirement. For example, when creating or updating a single phase transformer, the phasescurrent attribute must be A, B, or C.
- Populate specific attribute values for existing features at a user-specified time. For example, the fulladdress field for existing features is populated by concatenating several text fields.
- Review existing features to ensure that user requirements are maintained after field edits are made. For example, existing features can be evaluated to ensure that when a pole is taller than 65 feet, the material must be steel. Features that don't pass the evaluation are flagged as error features to be reviewed.
When you create an attribute rule, you must specify the rule type to use. The attribute rule type chosen depends on the task and at what point in the editing process the rule needs to be evaluated. Review the following rule type details to determine the applicable rule type for your workflow:
- Calculation—To increase efficiency in data collection and editing, immediate calculation rules automatically populate attributes based on editing patterns. This enhances the editing experience as new features are created or as changes are made to existing data. Batch calculation rules are evaluated at a user-specified time on existing data.
- Constraint—To ensure quality data is entered into the GIS, constraint rules control data entry by user-defined requirements. This prevents invalid data entry while editing to ensure data integrity. To find data inconsistencies of existing data, use validation rules.
- Validation—To review features that violate specified attribute or geometry requirements, validation rules highlight errors in existing data. This brings awareness to affected features to improve data integrity.
Note:The input workspace for evaluating batch calculation and validation rules depends on the type of geodatabase the dataset with attribute rules is stored in:
- File or mobile geodatabase—The geodatabase is the input workspace to evaluate.
- Enterprise geodatabase—You must use a feature service with the Validation capability as the input workspace to evaluate. Learn more about sharing data as a feature service with the Validation capability.
Attribute Rules view
Attribute rules are viewed, created, and managed in their own tabular-style view called the Attribute Rules view. The Attribute Rules view can be accessed using the context menu of the dataset directly from the Catalog or Contents pane. It can also be accessed by clicking the Attribute Rules button on the ribbon; this is available in the Data Design group on the Data tab when an active layer in the map view is selected or when using the Fields or Subtypes view.
For details about using this view, see Create and manage attribute rules.
Create attribute rules with Arcade
Attribute rules are created on an input feature class or table. To add an attribute rule, the dataset must have GlobalIDs, and for enterprise geodatabases, the operation must be performed as the data owner. You can create rules in the Attribute Rules view using the Add Attribute Rule tool or the Import Attribute Rules tool. Rules can be targeted for specific subtypes in the rule definition. This is helpful when you want a rule to only apply to a subset of features in a dataset.
ArcGIS Arcade script expressions are used as part of the rule definition to define what to calculate or the valid feature configurations. Arcade is a portable expression language that can be used across the ArcGIS platform.
See the Arcade profile for the requirements and global variables to author attribute rule types. The Arcade Getting Started guide and Function Index are additional resources you can use to construct script expressions for attribute rules.
Create attribute rules with Data Reviewer
Optionally, attribute rules are created using capabilities available in ArcGIS Data Reviewer. Data Reviewer provides a library of data validation checks that identify common errors found in spatial data. These checks assess different aspects of a feature's quality that can include its attribution, integrity, or spatial relationship to other features.
Data Reviewer checks are configurable and enable you to implement organization-specific data quality requirements without the requirement to create or maintain custom code.
Note:Adding attribute rules to a dataset impacts backward compatibility:
- Once attribute rules are added to a dataset, it is incompatible with ArcMap or ArcGIS Pro 2.0 and earlier. See Client and geodatabase compatibility for more information on functionality available when using mixed client and geodatabase releases.
- Newer Arcade functions impact what ArcGIS client releases can access the dataset with the attribute rule. See Compatibility of Arcade in script expressions for more information.
Manage attribute rules
Once attribute rules are established on datasets in the geodatabase, there are several ways to review and manage the rules. You can use the Attribute Rules view to display properties, make changes to existing attribute rules, and create rules. You can also use geoprocessing tools in the Attribute Rules toolset to administer attribute rules for a dataset or to script certain tasks.
The arcpy.Describe function can be used on a dataset to print the attribute rule properties. You can also view attribute rule properties using the Export Attribute Rules tool and reviewing the contents of the exported .csv file.
You can temporarily disable attribute rules on a dataset using the Attribute Rules view or the Disable Attribute Rules and Enable Attribute Rules tools. When a rule is in the disabled state, it does not execute for triggering events. This can improve performance for bulk data loads and is useful when rule execution must be suspended.
Attribute rules are created as a property of feature classes or tables in the geodatabase. Attribute rules are included in the data transfer process with datasets in the geodatabase using copy and paste or the Export XML Workspace Document and Import XML Workspace Document tools. Data migration tools such as Feature Class To Feature Class and Table To Table do not transfer the attribute rules with the underlying dataset.
To transfer attribute rules between existing datasets, use the Export Attribute Rules and Import Attribute Rules tools. The Export Attribute Rules tool uses a .csv file to store the definition of the attribute rule.
Sequences are excluded from the Export XML Workspace Document tool and attribute rules referencing sequences are not added to the data in the target geodatabase during Import XML Workspace Document execution.
Evaluate attribute rules and manage error features
You can evaluate attribute rules for a dataset during an edit operation or at a user-specified time on existing data. Depending on the rule type and properties, the attribute rule evaluation will occur at different times:
- Immediate evaluation
- Immediate calculation rules
- Constraint rules
- Deferred evaluation
- Batch calculation rules
- Validation rules
Evaluation of batch calculation and validation rules creates errors to highlight data that violate attribute rules. Each error is stored as an error feature in the error layers. Error features can be reviewed through the Error Inspector during quality assurance workflows.