Creates an attributed relationship class from the origin, destination, and relationship tables.
This tool creates a table in the database containing the selected attribute fields of the relationship table. These fields are used 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.
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.
TableToRelationshipClass_management (origin_table, destination_table, out_relationship_class, relationship_type, forward_label, backward_label, message_direction, cardinality, relationship_table, attribute_fields, origin_primary_key, origin_foreign_key, destination_primary_key, destination_foreign_key)
The table or feature class that will be associated to the destination table.
The table or feature class that will be associated to the origin table.
The relationship class that will be created.
The type of association to create between the origin and destination tables.
A label describing the relationship as it is traversed from the origin table/feature class to the destination table/feature class.
A label describing the relationship as it is traversed from the destination table/feature class to the origin table/feature class.
The direction messages will be propagated between the objects in the relationship. 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.
The cardinality of the relationship between the origin and destination.
The table containing attributes that will be added to the relationship class.
The fields containing attribute values that will be added to the relationship class.
The field in the origin table that will be used to create the relationship. Generally, this is the object identifier field.
The name of the Foreign Key field in the relationship table that refers to the Primary Key field in the origin table/feature class.
The field in the destination table that will be used to create the relationship. Generally, this is the object identifier field.
The field in the relationship table that refers to the Primary Key field in the destination table.
The following Python Window script demonstrates how to use the TableToRelationshipClass tool.
import arcpy arcpy.env.workspace = "C:/data/Montgomery.gdb" arcpy.TableToRelationshipClass_management("owners", "Parcels", "ownersParcels_RelClass", "SIMPLE", "Owns", "Is Owned By", "BACKWARD", "MANY_TO_MANY", "owners", ["OWNER_PERCENT", "DEED_DATE"], "OBJECTID", "owner_id", "OBJECTID", "parcel_id")
Create an attributed relationship class between parcel feature class and table with owner information.
# Name: TableToRelationshipClass.py # Description: Create an attributed relationship class between parcels # feature class and table with owner information # Author: ESRI # import system modules import arcpy from arcpy import env # Set environment settings env.workspace = "C:/data" # Copy owners.dat to file gdb table, since both tables to be related # must be in the same database ownerDat = "owners.dat" ownerTbl = "Montgomery.gdb/owners" arcpy.CopyRows_management(ownerDat, ownerTbl) # Create attributed relationship class between 'parcel' parcel layer # and 'owner' table with additional parcel owner information parcel = "Montgomery.gdb/Parcels" relClass = "Montgomery.gdb/parcelowners_RelClass" forLabel = "Owns" backLabel = "Is Owned By" attributeFields = ["OWNER_PERCENT", "DEED_DATE"] originPK = "OBJECTID" originFK = "owner_ID" destinationPK = "OBJECTID" destinationFK = "parcel_ID" arcpy.TableToRelationshipClass_management(ownerTbl, parcel, relClass, "SIMPLE", forLabel, backLabel, "BACKWARD", "MANY_TO_MANY", ownerTbl, attributeFields, originPK, originFK, destinationPK, destinationFK)
- ArcGIS Desktop Basic: No
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes