An overview of creating and maintaining relationship classes (ArcInfo and ArcEditor only)
An overview of creating and maintaining relationship classes (ArcInfo and ArcEditor only)
Release 9.3
Creating relationship classes
Before you can create a relationship, you must have a primary key field in the origin and a foreign key field in the destination.
Once you have the primary and foreign key fields defined, you can use one of the following three tools to create a relationship class:
In ArcCatalog, right-click the geodatabase or a feature dataset and click New > Relationship Class. Use the multipanel wizard to set the relationship properties.
Within one of the geoprocessing framework environments, you can create a new relationship class with the Create Relationship Class tool. This tool allows you to specify the same parameters as the ArcCatalog wizard in one dialog panel. It is located in the Data Management Tools toolbox > Relationship Classes toolset.
Also in the Data Management Tools toolbox > Relationship Classes toolset is the Table to Relationship Class tool. Unlike the previous two tools, this tool allows you to specify an existing intermediate key table, such as is required in a many-to-many relationship or in a relationship that has attributes. Use this tool to create a many-to-many relationship between two tables.
If both the origin and destination classes exist in the same feature dataset, the relationship class will be located in that feature dataset. Otherwise, the relationship class will be located directly under the geodatabase.
Creating a relationship can involve several additional steps, and there are different workflows you can follow to complete the process. The workflow you should follow depends on the data you have and the type of relationship you want to create.
If you have origin and destination classes populated with features or records, and the primary key values in the origin correctly relate to the correct foreign key values in the destination, follow these steps:
Create the relationship class with the New Relationship Class wizard or the Create Relationship Class tool.
Set rules if required.
If you set rules or are working with a composite relationship, test referential integrity with the ArcMap Validate Features command.
Limitations: This workflow is not applicable to many-to-many relationships or to relationships with attributes.
If you have origin and destination classes populated with features or records, have primary key values in the origin, but either have no foreign key values in the destination or have values that don't relate correctly, follow these steps:
Create the relationship class with the New Relationship Class wizard or the Create Relationship Class tool.
Set rules if required.
Interactively select related origin and destination objects in ArcMap and relate them with the Attributes dialog box.
This sets the foreign key values in the destination so they relate to the primary key values in the origin. If you created an attributed relationship in step 1, this adds records to the Intermediate Key table.
If you created an attributed relationship class in step 1, manually enter the attributes into the Intermediate Key table.
If you set rules or are working with a composite relationship, test referential integrity with the ArcMap Validate Features command.
Limitations: This workflow is not applicable to many-to-many relationships that do not include at least one feature class as the origin or destination.
To create a many-to-many relationship between two tables or to create a relationship using an existing Intermediate Key table that contains relationship attributes, follow these steps:
Create and populate the Origin table, Destination table, and Intermediate Key table, ensuring that primary key values correctly relate to destination key values.
Create the relationship class with the Table To Relationship Class tool.
Building and maintaining the relationship
ArcMap contains tools that help you build and maintain a relationship.
If you have objects in the origin and destination but they are not yet related, you can manually establish relations one at a time in ArcMap. To do this, select one or more objects in the destination, select one or more objects in the origin, then open the Attributes dialog box and relate them. You can do this, provided at least one side of the relationship contains features.
You can select an object, then create a related object in a related class, provided it is a new record in a table and not a feature.
You can remove an object from a relationship with the Attributes dialog box.
Once you've finished editing a composite relationship or a relationship with rules, you can check your work with the Validate Features command. It will tell you if any of your edits violate referential integrity.