ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / RelationshipClassDescription Class / RelationshipClassDescription Constructor / RelationshipClassDescription Constructor(String,TableDescription,TableDescription,RelationshipCardinality,String,String)
The name of the description.
The origin class of the ArcGIS.Core.Data.RelationshipClass.
The destination class of the ArcGIS.Core.Data.RelationshipClass.
The relationship cardinality of the ArcGIS.Core.Data.RelationshipClass.
The name of the ArcGIS.Core.Data.Field in the origin class that serves as the origin primary key.
The name of the ArcGIS.Core.Data.Field in the destination class that serves as the origin foreign key.
Example

In This Topic
    RelationshipClassDescription Constructor(String,TableDescription,TableDescription,RelationshipCardinality,String,String)
    In This Topic
    Creates a description object of the ArcGIS.Core.Data.RelationshipClass.
    Syntax

    Parameters

    relationshipClassName
    The name of the description.
    originClassDescription
    The origin class of the ArcGIS.Core.Data.RelationshipClass.
    destinationClassDescription
    The destination class of the ArcGIS.Core.Data.RelationshipClass.
    relationshipCardinality
    The relationship cardinality of the ArcGIS.Core.Data.RelationshipClass.
    originPrimaryKey
    The name of the ArcGIS.Core.Data.Field in the origin class that serves as the origin primary key.
    originForeignKey
    The name of the ArcGIS.Core.Data.Field in the destination class that serves as the origin foreign key.
    Exceptions
    Example
    Creating relationship class
    public void CreateRelationshipWithRelationshipRules(SchemaBuilder schemaBuilder)
    {
      // Creating a 'BuildingType' table with two fields - BuildingType and BuildingTypeDescription
      FieldDescription buildingType = FieldDescription.CreateIntegerField("BuildingType");
      FieldDescription buildingTypeeDescription = FieldDescription.CreateStringField("BuildingTypeDescription", 100);
      TableDescription buildingTypeDescription = new TableDescription("BuildingType", new List<FieldDescription>() { buildingType, buildingTypeeDescription });
      TableToken buildingtypeToken = schemaBuilder.Create(buildingTypeDescription);
    
      // Creating a 'Building' feature class with three fields - BuildingId, Address, and BuildingType
      FieldDescription buildingId = FieldDescription.CreateIntegerField("BuildingId");
      FieldDescription buildingAddress = FieldDescription.CreateStringField("Address", 100);
      FieldDescription usageSubType = FieldDescription.CreateIntegerField("UsageSubtype");
      FeatureClassDescription featureClassDescription = new FeatureClassDescription("Building", new List<FieldDescription> { buildingId, buildingAddress, buildingType, usageSubType }, new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84));
    
      // Set subtype details (optional)
      featureClassDescription.SubtypeFieldDescription = new SubtypeFieldDescription(usageSubType.Name, new Dictionary<int, string> { { 1, "Marketing" }, { 2, "Utility" } });
    
      FeatureClassToken buildingToken = schemaBuilder.Create(featureClassDescription);
    
      // Creating a 1:M relationship between the 'Building' feature class and 'BuildingType' table
      RelationshipClassDescription relationshipClassDescription = new RelationshipClassDescription("BuildingToBuildingType", new FeatureClassDescription(buildingToken), new TableDescription(buildingtypeToken),
        RelationshipCardinality.OneToMany, buildingType.Name, buildingType.Name)
      {
        RelationshipType = RelationshipType.Composite
      };
    
      // Adding relationship rules for the 'Marketing' subtype
      relationshipClassDescription.RelationshipRuleDescriptions.Add(new RelationshipRuleDescription(1, null));
    
      schemaBuilder.Create(relationshipClassDescription);
      schemaBuilder.Build();
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.1 or higher.
    See Also