Show Navigation | Hide Navigation
You are here:
Geoprocessing tool reference > Data Management toolbox > Relationship Classes toolset > Tools

Create Relationship Class (Data Management) (ArcInfo and ArcEditor only)

Release 9.2
Last modified November 29, 2010
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Tools"


Related Topics

Creates a relationship class to store an association between fields or features in the origin table and the destination table.


Usage tips

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.

  • SIMPLE — A relationship between independent objects (parent to parent). This is the default.
  • COMPOSITE — A relationship between dependent objects where the lifetime of one object controls the lifetime of the related object (parent to child).

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.

  • FORWARD — Messages are passed from the origin to the destination table.
  • BACK — Messages are passed from the destination to the origin table.
  • BOTH — Messages are passed from the origin to the destination table and from the destination to the origin table.
  • NONE — No messages passed. This is the default.

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.

  • ONE_TO_ONE — Each row or feature in the origin table can be related to zero or one row or feature in the destination table. This is the default.
  • ONE_TO_MANY — Each row or feature in the origin table can be related to one or several rows or features in the destination table.
  • MANY_TO_MANY — Several fields or features in the origin table can be related to one or several rows or features in the destination table.

String
<NONE | ATTRIBUTED>

Specifies if the relationship will have attributes.

  • NONE — Indicates the relationship class will not have attributes. This is the default.
  • ATTRIBUTED — Indicates the relationship class 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
Data types for geoprocessing tool parameters


Command line example

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.

  • SIMPLE — A relationship between independent objects (parent to parent). This is the default.
  • COMPOSITE — A relationship between dependent objects where the lifetime of one object controls the lifetime of the related object (parent to child).

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.

  • FORWARD — Messages are passed from the origin to the destination table.
  • BACK — Messages are passed from the destination to the origin table.
  • BOTH — Messages are passed from the origin to the destination table and from the destination to the origin table.
  • NONE — No messages passed. This is the default.

String
cardinality (Required)

Determines how many relationships exist between rows or features in the origin and rows or features in the destination table.

  • ONE_TO_ONE — Each row or feature in the origin table can be related to zero or one row or feature in the destination table. This is the default.
  • ONE_TO_MANY — Each row or feature in the origin table can be related to one or several rows or features in the destination table.
  • MANY_TO_MANY — Several fields or features in the origin table can be related to one or several rows or features in the destination table.

String
attributed (Required)

Specifies if the relationship will have attributes.

  • NONE — Indicates the relationship class will not have attributes. This is the default.
  • ATTRIBUTED — Indicates the relationship class 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

Data types for geoprocessing tool parameters


Script example

# 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()

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.