After completing this unit, you’ll be able to:
This unit’s exercise uses the Esri Geodatabase (File Geodb) reader/writer, which requires a licensed version of ArcGIS. For more information on required ArcGIS license levels, please see Required ArcGIS License Types for FME Geodatabase Formats.
Geodatabase relationship classes manage the relationships between features in different feature classes. Attributed and non-attributed relationship classes can be read and written with FME. Relationships are not rows in a table or feature classes but linkages through the origin and destination feature’s primary and foreign key values.
“Origin” features belong to the “Origin Table/Feature Class” specified when creating the relationship class in ArcCatalog, while “destination” features belong to the “Destination Table/Feature Class”.
Relationship classes can be simple or composite and attributed or non-attributed.
Simple vs. Composite:
In a “Simple” Relationship class, features can exist independently of each other – for example, a feature can exist without necessarily having an attachment, and you can delete any attachment without affecting the feature.
In a “Composite” Relationship class, origin and destination objects are more closely connected. If you delete a feature, you also delete the related attachment record.
Attributed vs. Non-attributed:
In a non-attributed relationship, a non-spatial table containing only the origin and destination feature keys contains the relationship class.

In an attributed relationship, a non-spatial table with more attributes than just the identifying keys contains the relationship class.

When reading a relationship class, FME must read both the origin and destination feature classes simultaneously with the relationship class. A relationship feature type shows an allowed Geometry of either geodb_relationship or geodb_attributed_relationship.

Each relationship feature has the following format attributes stored on it when read from a relationship class:
geodb_rel_origin_oid - the primary key of the related origin feature used when ArcGIS set up the relationship.geodb_rel_destination_oid - the primary key of the related destination feature used when ArcGIS set up the relationship.You can use these attributes to identify relationships between the origin and destination features within the workspace. These attributes are used for FME’s processes as format attributes and do not appear in the final written output.
Note that reading from relationship classes is very slow since each relationship is validated when read. Because this functionality is not often required, FME includes a parameter that, by default, turns off relationship reading to improve performance. Therefore, to read relationship classes, you must first locate and deactivate the Ignore Relationship Info parameter.

You cannot create relationship classes using FME; you must set them up using ArcGIS before running the translation. Once ArcGIS has defined the relationship, you must use the following attributes on features to write to a relationship class table using FME:
geodb_rel_origin_oid - the ID attribute from the related origin featuregeodb_rel_destination_oid - the ID attribute from the related destination featuregeodb_type - either geodb_relationship or geodb_attributed_relationshipYou likewise must use the following attributes on features written to the origin and destination feature classes/tables which participate in the relationship.
geodb_oid - the ID attributes used in the geodb_rel_origin_oid and the geodb_rel_destination_oid attributes.geodb_feature_has_relationships - Set to “YES” to specify that a feature participates in a relationship as an origin or destination.Required attributes for writing to relationship classes:
| Object | Required Attributes |
| Origin feature class or table | geodb_oid
|
| Destination feature class or table | geodb_oid
|
| Relationship class | geodb_rel_origin_oid
Table Handling: Use Existing |
For example, if an origin feature has geodb_oid = 1 and a destination feature has geodb_oid = 2, the feature written to the relationship table must have these attributes:
geodb_rel_origin_oid = 1geodb_rel_destination_oid = 2You can insert, update, and delete features in an attributed relationship. But you can only insert or delete features participating in a non-attributed relationship. Because attributed relationships have intermediate tables associated with them, you may update the attributes of the intermediate table (excluding key values) by providing a RID (relationship id) as an update/key field.
Relationship Keys
In a geodatabase, the relationship keys do not have to be of type Object ID (integers). They could be a GUID, for example. In this case, it’s tempting to load the foreign key attributes in the relationship. You don’t need to do this. You only need to set the values of geodb_rel_origin_oid & geodb_rel_destination_oid. The FME Geodb writer will populate the relationship feature class foreign keys.
Use only one Geodatabase writer: Be careful if you have more than one Geodatabase writer in your workspace. The same geodatabase writer must write both the origin and destination feature classes (or tables) that participate in the relationship and the relationship class. That means you cannot write to feature classes with one geodatabase writer and to relationship classes with another.
Sometimes, the data in the origin and destination feature classes already exist, and you want to add the relationships to the relationship table. You can do this if:
Set the geodb_type to geodb_relationship or geodb_attributed relationship (if attributed) and the geodb_rel_origin_oid and geodb_rel_destination_oid to their respective ObjectIDs. This does require that FME reads the feature classes which participate in the relationship but does not involve writing them out again. You only need to write the relationship table in this case.
You must use ArcGIS tools to create relationships, as you cannot produce them in FME.
1:1, 1:M non-attributed relationships: These have no intermediate table for keeping track of relationships. They are linked using a primary (origin table) and foreign (destination table) key.
M:N and any 1:1, 1:M or M:N attributed relationships: These use separate tables to keep track of the relationships. Each relationship entry contains a unique RID value and the primary and foreign key tracking these relationships.
File Geodatabase and SDE Geodatabase
1:1, 1:M non-attributed feature classes: If inserting with FME, you would either:
File Geodatabase ONLY - Not SDE Geodatabase
1:1, 1:M, M:N attributed relationships and M:N non-attributed relationships: Consider this scenario: you have populated feature classes and need to insert into the relationship table to populate it, or you want to update or insert attributes in an attributed relationship table. In this case, you may insert into the relationship table directly without writing to the feature classes which participate in the relationship. This insertion includes the primary/foreign key and/or attributes.
The assumption here is you already have a table or some source with those relationships defined. It’s probably a less common workflow, but it’s doable. Generally, you will insert both the feature classes and building/inserting into the relationship table simultaneously.
SDE Geodatabase
1:1, 1:M, M:N Attributed Relationships and M:N Non-attributed Relationships:
FME can only UPDATE the attributes in an attributed relationship, not the RID, foreign and primary keys. If this is desirable, you must use a DELETE and INSERT operation.
Currently, there isn’t a way to insert existing relationship attributes into a relationship table with an SDE geodatabase without reading the features participating in the relationship to get the ObjectID. This limitation exists because populating these relationships in ArcGIS requires the origin and destinations to be picked interactively rather than just defining the relationship. If the features in relationship classes already exist in the database and you only need to populate the relation table, you still need to read the features that participate. This step is required to get the ObjectIDs. However, you do not need to write these features back. You must rename the ObjectIDs read from the origin and destination relationship features to the geodb_rel_origin_oid and geodb_rel_destination_oid respectively, for FME to populate the relationship table.
You can delete individual records from a relationship class. To do this, you can:
geodb_rel_origin_oid and geodb_rel_destination_oid. These act like a unique key to the relation record. You also need to set a key field on the FME Geodatabase writer (i.e., RID), but FME ignores this field for relationship classes.