Relationships (Feature Service)

URL:
https://<root>/<serviceName>/FeatureServer/relationships
Methods:
GET
Version Introduced:
10.7

Description

The relationships resource includes relationship class information for the layers and tables in a specific service, including information about relationship rules from the back-end relationship classes and relationship information already found in individual layers and tables. The relationships resource allows applications to get all the information in one resource, rather than having to piece together the relationships information in each individual layer and table.

Services that support the relationships resource will have the supportsRelationshipsResource property set as true on their service resource.

For more information on relationship classes in enterprise geodatabases, see Relationship class properties.

New at 11.3

  • Reference feature services support user defined relationship IDs for relationship classes published from ArcGIS Pro 3.3. Each relationship id is still a unique integer value across the relationship classes in the feature service, but now it can be user defined rather than generated by the system.

New at 11.1

The following update has been made for enterprise hosted feature services running on a relational data store:

  • This resource is now supported for qualifying hosted feature services. Support for this is indicated when the service-level supportsRelationshipsResource property is true .

The following update has been made for non-hosted feature services (referencing enterprise geodatabases) published from ArcGIS Pro:

  • The catalogID property has been added to the relationships array returned by the relationships resource.

Request parameters

ParameterDetails

f

The response format. The default response format is html .

Values: html | json | pjson

Response properties

The following properties are returned for each relationship class.

PropertyDetails

id

The unique identifier assigned to each relationship.

name

The name assigned to the relationship when the relationship was created.

backwardPathLabel

A name to identify the relationship when navigating from the destination table to the origin table.

originLayerId

The layer ID of the origin table participating in the relationship.

originPrimaryKey

The name of the primary key field in the origin table.

forwardPathLabel

A name to identify the relationship when navigating from the origin table to the destination table.

destinationLayerId

The layer ID of the destination table participating in the relationship.

originForeignKey

In a non-attributed relationship, the originForeignKey is the foreign key in the destination relationship class which relates the rows of the destination layer or table to the origin layer or table. In an attributed relationship, originForeignKey is the foreign key in the intermediate table, which relates the rows of the intermediate table to the origin layer or table.

relationshipTableId

The ID of the intermediate table in the feature service for attributed relationships.

destinationPrimaryKey

The name of the primary key field in the destination table.

destinationForeignKey

In attributed relationships, this is the foreign key in the intermediate table that relates the rows of the intermediate table to the destination layer or table.

rules

If the relationship class has relationship rules, the rules array will list information about each rule. If no rules are defined, an empty array is returned. The each rule has the following properties:

ruleID - The unique ID of the relationship rule.

originSubtypeCode - The user defined subtype code in the origin table that the relationship rule applies to.

originMinimumCardinality - The minimum amount of relationships allowed from the origin table to the destination table. A -1 value for this property means no minimum has been defined.

originMaximumCardinality - The maximum amount of relationships allowed from the origin table to the destination table. A -1 value for this property means no maximum has been defined.

destinationSubtypeCode – The user defined subtype code in the destination table that the relationship rule applies to.

destinationMinimumCardinality – The minimum amount of relationships allowed from the destination table to the origin table. A -1 value for this property means no minimum has been defined.

destinationMinimumCardinality - The maximum amount of relationships allowed from the destination table to the origin table. A -1 value for this property means no maximum has been defined.

cardinality

The cardinality of the relationships as a combination of origin and destination cardinalities. When you create a relationship class, you create it with an initial cardinality, such as one-to-many or many-to-many.

In a real system, however, relationship cardinalities are more specific. Once you've created the relationship class, you can refine the cardinality by creating rules.

Relationship rules allow you to restrict the type of objects in the origin feature class or table that can be related to a certain kind of object in the destination feature class or table.

Values: esriRelCardinalityOneToOne | esriRelCardinalityOneToMany | esriRelCardinalityManyToMany

If an object in the origin table can be related to only one object in the destination table, the relationship cardinality is esriRelCardinalityOneToOne . If an object in the origin table can be related to multiple objects in the destination table, the relationship cardinality is esriRelCardinalityOneToMany . If an object in the origin table can be related to multiple objects in the destination table and an object in the destination table can be related to multiple objects in the origin table, the relationship cardinality is esriRelCardinalityManyToMany .

attributed

Indicates whether the relationship is attributed.

Values: true | false

composite

Indicates whether the relationship is composite.

Values: true | false

catalogID

Introduced at ArcGIS Enterprise 11.1. A universal identifier from the back-end data store. This value can be used, for example, by the UUID for the relationship class in the back-end enterprise geodatabse.

JSON Response syntax

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
  "relationships": [
    {
      "id": <id>,
      "name": "<name>",
      "catalogID": "<identifier>",//Added at 11.1
      "backwardPathLabel": "<backwardPathLabel>",
      "originLayerId": <originLayerId>,
      "originPrimaryKey": "<originPrimaryKey>",
      "forwardPathLabel": "<forwardPathLabel>",
      "destinationLayerId": <destinationLayerId>,
      "originForeignKey": "<originForeignKey>",
      "relationshipTableId": <relationshipTableId>,
      "destinationPrimaryKey": "<destinationPrimaryKey>",
      "destinationForeignKey": "<destinationForeignKey>",
      "rules": [
        {
          "ruleID": <ruleID>,
          "originSubtypeCode": <originSubtypeCode>,
          "originMinimumCardinality": <originMinimumCardinality>,
          "originMaximumCardinality": <originMaximumCardinality>,
          "destinationSubtypeCode": <destinationSubtypeCode>,
          "destinationMinimumCardinality": <destinationMinimumCardinality>,
          "destinationMaximumCardinality": <destinationMaximumCardinality>
        }
      ],
      "cardinality": "<cardinality>",
      "attributed": <true | false>,
      "composite": <true | false>
    }
  ]
}

JSON Response example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
  "relationships": [
    {
      "id": 0,
      "name": "county_division",
      "catalogID": "{A14D41FC-ABB5-4E9C-86BC-BB0290D5B331}",
      "backwardPathLabel": "belongs",
      "originLayerId": 0,
      "originPrimaryKey": "GlobalID",
      "forwardPathLabel": "has",
      "destinationLayerId": 2,
      "originForeignKey": "GlobalID_sor",
      "relationshipTableId": 3,
      "destinationPrimaryKey": "GlobalID",
      "destinationForeignKey": "GlobalID_des",
      "rules": [
        {
          "ruleID": 1,
          "originSubtypeCode": 1,
          "originMinimumCardinality": 0,
          "originMaximumCardinality": 2,
          "destinationSubtypeCode": 0,
          "destinationMinimumCardinality": 0,
          "destinationMaximumCardinality": 1
        },
        {
          "ruleID": 2,
          "originSubtypeCode": 2,
          "originMinimumCardinality": -1,
          "originMaximumCardinality": -1,
          "destinationSubtypeCode": 0,
          "destinationMinimumCardinality": -1,
          "destinationMaximumCardinality": -1
        }
      ],
      "cardinality": "esriRelCardinalityOneToMany",
      "attributed": false,
      "composite": true
    }
  ]
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.