Create Relationship Class (Data Management) (ArcInfo and ArcEditor only) |
|
Release 9.2
Last modified November 29, 2010 |
![]() ![]() ![]() Print all topics in : "Tools" |
Creates a relationship class to store an association between fields or features in the origin table and the destination table.
Usage tips
Relationships can exist between spatial objects (features in feature classes), nonspatial objects (rows in a table), or spatial and nonspatial objects.
Once created, a relationship class cannot be modified; you can only add, delete, or refine its rules. Relationship classes can be deleted and renamed using ArcCatalog in the same manner as any other object in the database.
For many-to-many relationship classes, a new table in the database is created to store the foreign keys used to link the origin and destination classes. This table can also have other fields to store attributes of the relationship itself that are not attributed to either the origin or destination class. For example, in a parcel database, you may have a relationship class between parcels and owners in which owners "own" parcels and parcels are "owned by" owners. An attribute of that relationship may be percentage ownership. One-to-one and one-to-many relationship classes may also have attributes; in this case, a table is created to store the relationships.
Simple or peer-to-peer relationships are relationships between two or more objects in the database that exist independently of each other. For example, in a railroad network, you may have railroad crossings that have one or more related signal lamps. However, a railroad crossing can exist without a signal lamp, and signal lamps exist on the railroad network where there are no railroad crossings. Simple relationships can have one-to-one, one-to-many, or many-to-many cardinality.
A composite relationship is a relationship in which the lifetime of one object controls the lifetime of its related objects. For example, power poles support transformers, and transformers are mounted on poles. Once a pole is deleted, a delete message is propagated to its related transformers, which are deleted from the transformers' feature class. Composite relationships are always one-to-many.
Forward and backward path labels describe the relationship when navigating from one object to another. The forward path label describes the relationship navigated from the origin class to the destination class. In the pole-transformer example, a forward path label might be: Poles support transformers. The backward path label describes the relationship navigated from the destination to the origin class. In the pole-transformer example, a backward path label might be: Transformers are mounted on poles.
Relationship classes can also be created in ArcCatalog. Select the menu item New - Relationship Class from the context menu of a geodatabase.
The environment settings do not have an effect on this tool.
Command line syntax
An overview of the Command Line window
CreateRelationshipClass_management <origin_table> <destination_table> <out_relationship_class> <SIMPLE | COMPOSITE> <forward_label> <backward_label> <NONE | FORWARD | BACKWARD | BOTH> <ONE_TO_ONE | ONE_TO_MANY | MANY_TO_MANY> <NONE | ATTRIBUTED> <origin_primary_key> <origin_foreign_key> {destination_primary_key} {destination_foreign_key}
Parameter | Explanation | Data Type |
<origin_table> |
The table or feature class that will be associated to the destination table. |
Table View |
<destination_table> |
The table that will be associated to the origin table. |
Table View |
<out_relationship_class> |
The relationship class that will be created. |
Relationship Class |
<SIMPLE | COMPOSITE> |
The type of relationship to create between the origin and destination tables.
|
String |
<forward_label> |
A name to uniquely identify the relationship when navigating from the origin table to the destination table. |
String |
<backward_label> |
A name to uniquely identify the relationship when navigating from the destination table to the origin table. |
String |
<NONE | FORWARD | BACKWARD | BOTH> |
The direction in which messages will be passed between the origin and destination tables. For example, in a relationship between poles and transformers, when the pole is deleted, it sends a message to its related transformer objects informing them it was deleted.
|
String |
<ONE_TO_ONE | ONE_TO_MANY | MANY_TO_MANY> |
Determines how many relationships exist between rows or features in the origin and rows or features in the destination table.
|
String |
<NONE | ATTRIBUTED> |
Specifies if the relationship will have attributes.
|
Boolean |
<origin_primary_key> |
The field in the origin table, typically the OID field, that links it to the Origin Foreign Key field in the relationship class table. |
String |
<origin_foreign_key> |
The field in the relationship class table that links it to the Origin Primary Key in the origin table. |
String |
{destination_primary_key} |
The field in the destination table, typically the OID field, that links it to the Destination Foreign Key field in the relationship class table. |
String |
{destination_foreign_key} |
The field in the relationship class table that links it to the Destination Primary Key in the destination table. |
String |
workspace E:\arcgis\ArcTutor\BuildingaGeodatabase\Montgomery.mdb CreateRelationshipClass owners landbase\parcels powns SIMPLE owns "is owned by" NONE ONE_TO_ONE NONE PROPERTY_ID PROPERTY_ID
Scripting syntax
About getting started with writing geoprocessing scripts
CreateRelationshipClass_management (origin_table, destination_table, out_relationship_class, relationship_type, forward_label, backward_label, message_direction, cardinality, attributed, origin_primary_key, origin_foreign_key, destination_primary_key, destination_foreign_key)
Parameter | Explanation | Data Type |
origin_table (Required) |
The table or feature class that will be associated to the destination table. |
Table View |
destination_table (Required) |
The table that will be associated to the origin table. |
Table View |
out_relationship_class (Required) |
The relationship class that will be created. |
Relationship Class |
relationship_type (Required) |
The type of relationship to create between the origin and destination tables.
|
String |
forward_label (Required) |
A name to uniquely identify the relationship when navigating from the origin table to the destination table. |
String |
backward_label (Required) |
A name to uniquely identify the relationship when navigating from the destination table to the origin table. |
String |
message_direction (Required) |
The direction in which messages will be passed between the origin and destination tables. For example, in a relationship between poles and transformers, when the pole is deleted, it sends a message to its related transformer objects informing them it was deleted.
|
String |
cardinality (Required) |
Determines how many relationships exist between rows or features in the origin and rows or features in the destination table.
|
String |
attributed (Required) |
Specifies if the relationship will have attributes.
|
Boolean |
origin_primary_key (Required) |
The field in the origin table, typically the OID field, that links it to the Origin Foreign Key field in the relationship class table. |
String |
origin_foreign_key (Required) |
The field in the relationship class table that links it to the Origin Primary Key in the origin table. |
String |
destination_primary_key (Optional) |
The field in the destination table, typically the OID field, that links it to the Destination Foreign Key field in the relationship class table. |
String |
destination_foreign_key (Optional) |
The field in the relationship class table that links it to the Destination Primary Key in the destination table. |
String |
# Create a relationship class between parcels and ownership data # Create the Geoprocessor object import arcgisscripting, sys, string, os gp = arcgisscripting.create() # Local variables... owners_parcels = "C:/arcgis/ArcTutor/BuildingaGeodatabase/Montgomery.mdb/owners_parcels" owners_dat = "C:/arcgis/ArcTutor/BuildingaGeodatabase/Montgomery.mdb/owners_dat" parcels = "C:/arcgis/ArcTutor/BuildingaGeodatabase/Montgomery.mdb/Landbase/Parcels" try: # Process: Create Relationship Class... gp.CreateRelationshipClass_management(owners_dat, parcels, owners_parcels, "SIMPLE", "owns", "is owned by", "NONE", "ONE_TO_ONE", "NONE", "PROPERTY_ID", "PROPERTY_I", "", "") except: # If an error occurred while running a tool print the messages print gp.GetMessages()