ArcGIS Server Banner

Relationships between datasets in a geodatabase in PostgreSQL

Relationships between datasets in a geodatabase in PostgreSQL

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Relationships manage associations between objects in one table and objects in another. Creating relationship classes between tables in your geodatabase can help maintain referential integrity, allow you to more efficiently edit related tables, and gives you the ability to query related tables. The following types of relationships between tables in a geodatabase are supported:

Just as features are stored in a feature class and nonspatial rows are stored in tables, relationships are stored and managed in a relationship class.

For details on relationships and relationship class cardinality, see Relationship class properties.

Relationships in ArcCatalog

In the Catalog tree, relationship classes appear as part of a feature dataset. The following is an example relationship class, Anno_19_72, as it appears in the Water feature dataset:

Relationship class in a feature dataset in ArcCatalog (PostgreSQL)

In this example, the Anno_19_72 relationship class relates the Distribmains feature class to its corresponding annotation feature class, DistDiam.

You can view information about relationship classes by right-clicking the relationship class and clicking Properties to open the Relationship Class Properties dialog box.

Relationship Class Properties dialog box in ArcCatalog

This shows the Distribmains feature class participates in a one-to-many relationship with the DistDiam annotation feature class. The records in the tables are joined based on the ObjectID in the Distribmains feature class and the FeatureID in the DistDiam feature class. This is a composite relationship class, which means changes in one table affect or alter features in the related table. In this case, changes made to the origin class (Distribmains) triggers a change in the destination feature class (DistDiam). This is referred to as Forward notification.

Relationship classes in a PostgreSQL DBMS

Relationship classes with a cardinality of one to one and one to many do not require a new table to be created in the geodatabase to store the relationships. All the system metadata required to manage the relationship is stored in the gdb_relclasses system table. The rules that are defined for the relationships are stored in gdb_relrules.

Relationship class system tables in PostgreSQL

Relationship classes with a many-to-many cardinality, however, do require a new table in the database to store the primary keys from the origin and related destination datasets that maintain the relationship between the two datasets. The name of the table that stores this information corresponds to the name of the relationship class.

This table may also have other fields to store attributes of the relationship that are not specific to either the origin or destination class but are a property of the relationship itself. This is known as an attributed relationship. For example, it may be useful to add some metadata or descriptive text for each related pair in the relationship class for future reference. You can add attributes to the relationship class when you create it.

See the topic Relationship class properties for illustrations and further information on relationship classes with many-to-many cardinality.

Relationship classes in an XML workspace document

Relationship classes appear in XML documents as a type of data element. The following is a portion of an XML document from a dataset containing a relationship class.

 <DataElement xsi:type="esri:DERelationshipClass">
    <CatalogPath>/V=sde.DEFAULT/FD=m8db.hbear.Water/RC=m8db.hbear.Anno_19_72</CatalogPath> 
    <Name>m8db.hbear.Anno_19_72</Name> 
    <DatasetType>esriDTRelationshipClass</DatasetType> 
    <DSID>-1</DSID> 
    <Versioned>true</Versioned> 
    <CanVersion>true</CanVersion> 
    <HasOID>true</HasOID> 
    <OIDFieldName>RID</OIDFieldName> 
    <Fields xsi:type="esri:Fields">
      <FieldArray xsi:type="esri:ArrayOfField">
        <Field xsi:type="esri:Field">
          <Name>RID</Name> 
          <Type>esriFieldTypeOID</Type> 
          <IsNullable>false</IsNullable> 
          <Length>4</Length> 
          <Precision>10</Precision> 
          <Scale>0</Scale> 
          <Required>true</Required> 
          <Editable>false</Editable> 
        </Field>
        <Field xsi:type="esri:Field">
          <Name>Diameter</Name> 
          <Type>esriFieldTypeInteger</Type> 
          <IsNullable>true</IsNullable> 
          <Length>4</Length> 
          <Precision>10</Precision> 
          <Scale>0</Scale> 
        </Field>
        <Field xsi:type="esri:Field">
          <Name>bldg_id</Name> 
          <Type>esriFieldTypeInteger</Type> 
          <IsNullable>true</IsNullable> 
          <Length>4</Length> 
          <Precision>10</Precision> 
          <Scale>0</Scale> 
        </Field>
      </FieldArray>
    </Fields>
  <Indexes xsi:type="esri:Indexes">
    <IndexArray xsi:type="esri:ArrayOfIndex">
      <Index xsi:type="esri:Index">
        <Name>r206_sde_rowid_uk</Name> 
        <IsUnique>true</IsUnique> 
        <IsAscending>true</IsAscending> 
        <Fields xsi:type="esri:Fields">
          <FieldArray xsi:type="esri:ArrayOfField">
            <Field xsi:type="esri:Field">
              <Name>RID</Name> 
              <Type>esriFieldTypeOID</Type> 
              <IsNullable>false</IsNullable> 
              <Length>4</Length> 
              <Precision>10</Precision> 
              <Scale>0</Scale> 
              <Required>true</Required> 
              <Editable>false</Editable> 
            </Field>
          </FieldArray>
        </Fields>
      </Index>
    <Index xsi:type="esri:Index">
      <Name>GDB_9_Diam</Name> 
      <IsUnique>false</IsUnique> 
      <IsAscending>true</IsAscending> 
      <Fields xsi:type="esri:Fields">
        <FieldArray xsi:type="esri:ArrayOfField">
          <Field xsi:type="esri:Field">
            <Name>Diameter</Name> 
            <Type>esriFieldTypeInteger</Type> 
            <IsNullable>true</IsNullable> 
            <Length>4</Length> 
            <Precision>10</Precision> 
            <Scale>0</Scale> 
          </Field>
        </FieldArray>
      </Fields>
    </Index>
    <Index xsi:type="esri:Index">
      <Name>GDB_9_feature_id</Name> 
      <IsUnique>false</IsUnique> 
      <IsAscending>true</IsAscending> 
      <Fields xsi:type="esri:Fields">
        <FieldArray xsi:type="esri:ArrayOfField">
          <Field xsi:type="esri:Field">
            <Name>bldg_id</Name> 
            <Type>esriFieldTypeInteger</Type> 
            <IsNullable>true</IsNullable> 
            <Length>4</Length> 
            <Precision>10</Precision> 
            <Scale>0</Scale> 
          </Field>
        </FieldArray>
      </Fields>
    </Index>
  </IndexArray>
  </Indexes>
  <CLSID>{A07E9CB1-9A95-11D2-891A-0000F877762D}</CLSID> 
  <EXTCLSID /> 
  <RelationshipClassNames xsi:type="esri:Names" /> 
  <AliasName>m8db.hbear.Anno_19_72</AliasName> 
  <ModelName /> 
  <HasGlobalID>false</HasGlobalID> 
  <GlobalIDFieldName /> 
  <RasterFieldName /> 
  <ExtensionProperties xsi:type="esri:PropertySet">
    <PropertyArray xsi:type="esri:ArrayOfPropertySetProperty" /> 
  </ExtensionProperties>
  <ControllerMemberships xsi:type="esri:ArrayOfControllerMembership" /> 
  <Cardinality>esriRelCardinalityManyToMany</Cardinality> 
  <Notification>esriRelNotificationBoth</Notification> 
  <IsAttributed>true</IsAttributed> 
  <IsComposite>true</IsComposite> 
  <OriginClassNames xsi:type="esri:Names">
    <Name>m8db.hbear.Distribmains</Name> 
  </OriginClassNames>
  <DestinationClassNames xsi:type="esri:Names">
    <Name>m8db.hbear.DistDiam</Name> 
  </DestinationClassNames>
  <KeyType>esriRelKeyTypeSingle</KeyType> 
  <ClassKey>esriRelClassKeyUndefined</ClassKey> 
  <ForwardPathLabel>m8db.hbear.DistDiam</ForwardPathLabel> 
  <BackwardPathLabel>m8db.hbear.Distribmains</BackwardPathLabel> 
  <IsReflexive>false</IsReflexive> 
  <OriginClassKeys xsi:type="esri:ArrayOfRelationshipClassKey">
    <RelationshipClassKey xsi:type="esri:RelationshipClassKey">
      <ObjectKeyName>OBJECTID</ObjectKeyName> 
      <ClassKeyName /> 
      <KeyRole>esriRelKeyRoleOriginPrimary</KeyRole> 
    </RelationshipClassKey>
    <RelationshipClassKey xsi:type="esri:RelationshipClassKey">
      <ObjectKeyName>FeatureID</ObjectKeyName> 
      <ClassKeyName /> 
      <KeyRole>esriRelKeyRoleOriginForeign</KeyRole> 
    </RelationshipClassKey>
  </OriginClassKeys> 
  <DestinationClassKeys xsi:type="esri:ArrayOfRelationshipClassKey">
    <RelationshipClassKey xsi:type="esri:RelationshipClassKey">
      <ObjectKeyName>OBJECT_ID</ObjectKeyName> 
      <ClassKeyName /> 
      <KeyRole>esriRelKeyRoleDestinationPrimary</KeyRole> 
    </RelationshipClassKey>
    <RelationshipClassKey xsi:type="esri:RelationshipClassKey">
      <ObjectKeyName>Feature_ID</ObjectKeyName> 
      <ClassKeyName /> 
      <KeyRole>esriRelKeyRoleDestinationForeign</KeyRole> 
    </RelationshipClassKey>
  </DestinationClassKeys>
  <RelationshipRules xsi:type="esri:ArrayOfRelationshipRule" />
</DataElement>