Relates and Relationship Classes Explained

14609
15
09-25-2018 04:24 PM
Suzanne-Boden
Esri Regular Contributor
12 15 14.6K

Updated February 7, 2022

The difference between relates (often called table relates) and relationship classes is a source of much confusion, especially for new ArcGIS users. Though they sound similar, the terms refer to different things. Both have benefits and there are reasons to use each one. Here are the main things to know.

  • A relate exists in a map or layer file.
  • A relationship class is an object in a geodatabase.
  • Relates can be created and edited with an ArcGIS Pro or ArcGIS Desktop Basic, Standard, or Advanced license.
  • Relationship classes can be created and edited with an ArcGIS Pro or ArcGIS Desktop Standard or Advanced license. They are read-only with a Basic license.

All clear now? No? Let's continue then.

Deconstructing the Terminology

Relates are great because they allow you to select features in a layer, then easily see related features in a different layer or related records in a nonspatial table. Relationship classes are great because they enable "smart behavior." You can set up rules for how the participating feature classes or tables behave when something happens. For example, with a relationship class in place, if a feature is deleted, then its associated record in the other feature class or table can be automatically deleted as well. 

Both relates and relationship classes rely on cardinality, which describes how records in two different tables are related to one another—cardinality can be one-to-one, one-to-many, many-to-one, or many-to-many.

  • One-to-one: Every feature has exactly one related record in the other table.
  • One-to-many: Features in one table may have more than one related record in the other table.
  • Many-to-one: Multiple features in one table have one related record in the other table. 
  • Many-to-many: Multiple features in one table have multiple records in the other table.

Relates support one-to-many and many-to-one cardinalities, while relationship classes support all cardinalities. Feature classes and tables that participate in a relate or a relationship class must have a field of the same data type (text, short integer, long integer, object ID, etc.). That field will be the "connection point" (AKA key field) between the two.

The Relate Example

The map below contains a layer of fire stations and a nonspatial table that stores data about the city's fire department personnel. A relate was created between the layer and the nonspatial table, which have a one-to-many cardinality (every fire station has multiple personnel). The relate is based on a short integer field in both tables that stores a fire station ID number. The fields have different names, but that doesn't matter at all.  

 

ArcMap map of fire stations

 

Thanks to the relate, it's easy to find out which personnel are assigned to any given fire station. Just use the Identify tool and click a fire station on the map. In the Identify window, the related table name displays below the fire station feature name. Expanding the table shows the records associated with that station (the Washington station in this example, which has six assigned personnel).

 

ArcMap Identify window showing Washington station personnel

 

Suppose Brian Butler is transferred to the Adams station. His record in the FirePersonnel table is edited to replace the Washington station number (2) with the Adams station number (202). When the edit is saved, the data shown in the Identify window will reflect his new assignment. Washington now has only five assigned personnel...

 

ArcMap Identify window showing data for Washington station

 

...while the Adams station personnel list now includes Brian.

 

ArcMap Identify window showing Adams station data

 

The Relationship Class Example

Table relates are super-useful to quickly view feature data stored in separate tables (for efficient data management purposes). Relationship classes give you the ability to do more than easily view data, however. With a relationship class, you can set rules and properties that control what happens when data in either table is edited. You can also ensure that only valid edits are made.

Using the example above, suppose a relationship class named StationsPersonnel has been created between the Fire Stations feature class and Fire Personnel table. Also suppose the city requires that all stations have a minimum of five assigned firefighters and a maximum of 15 assigned firefighters. A rule has been created in the relationship class to enforce this requirement.

 

ArcMap Catalog window showing a relationship class object

 

With Brian Butler's transfer to the Adams station, Washington is left with five assigned firefighters. Jean Fiorini, however, has requested a transfer, and her request was approved. A GIS technician responsible for maintaining the fire department's GIS data updates Jean's record in the personnel table with the new station number. She gets a message warning her that the edit has broken a rule. 

  • Note: Depending on which version of ArcGIS you are using and how the relationship class was configured, edits that conflict with a relationship class rule may not be accepted.

The database knows that without Jean, Washington will have fewer than five assigned personnel. To comply with the relationship class rule, the technician should first add a firefighter to the Washington station, then edit Jean's record to reflect her new station assignment.

A relationship class is intended to ensure that all data edits are valid and that an organization's GIS database accurately reflects and supports real-world needs. Suppose the person who approved Jean's transfer didn't realize that Washington would be left with only four firefighters. The relationship class rule surfaced that piece of key information, and we will assume the GIS technician communicates the issue to prevent loss of property or lives down the line due to insufficient staffing. 

Want to learn more about relates and relationship classes? Check out these help topics:

For detailed training and hands-on practice with relates, relationship classes, and other geodatabase capabilities that enforce data integrity, take our Managing Geospatial Data in ArcGIS class.

15 Comments
LiamHarrington-Missin
Occasional Contributor II

Thanks for this useful article.  What I am slightly confused by is when to use one or the other.  Relate feels like a "light" version of Relationship with only your licence level being the restriction.  If given the choice it feels like Relationship should be the default if you can and avoid Relate as it provides a more robust solution. 

Is there a situation where that is not the case, when Relate should be chosen over Relationship?

Suzanne-Boden
Esri Regular Contributor

Hi Liam, the choice depends on the specific need. Relates are great when people just need to quickly access and view attributes stored in a separate table from the map layer (for example), and you can create them for shapefiles as well as geodatabase feature classes. Relationship classes are the more robust solution, as they support smart behavior and more cardinalities than relates. But they do require storing data in a geodatabase and a Standard or Advanced license.

AndrewBarker3
New Contributor III

Hi Suzanne,

Isn’t this fire station and personnel example a one to many relationship?  One spatial feature of fire station can have many aspatial records (personnel)?

In the post you mention this is a many to one...I’m confused how it could be. Care to share?

Suzanne-Boden
Esri Regular Contributor

Hi Andrew, great question! Cardinality depends on which way you're looking at the data (from which table). One fire station has many personnel (1-M), and many personnel are associated with one fire station (M-1). You're correct that in this example, the screenshots show a 1-M cardinality. I'll update the post. Thanks for asking the question.

MichaelThornton
New Contributor II

Suzanne, I want to use a realtional Class GDB object to relate multiple tables to my feature layer. My concern is that if someone deletes a polygon and redraws it on a sde two-way replication connection, that new objectIDs will be created for the feature layer and thereby breaking my connections between the non-spatial tables and my feature layer. Do you know if esri has a way of handling this?

Suzanne-Boden
Esri Regular Contributor

Hi Michael, I don't have the answer but will have one of my colleagues reply. In the meantime, this help topic may be useful: Replication and related data—ArcGIS Help | ArcGIS Desktop.  

Suzanne-Boden
Esri Regular Contributor

Hi again, Michael, to avoid the issue you mention, the recommendation is to *not* use the ObjectID field as the primary or foreign key when setting up a relationship class. I think this is the same recommendation you saw in another thread.

VincentMcClarty
New Contributor

Hi Suzanne,

Just another question you might be able to answer about relates and relationship classes. Can you only use relates when you want to symbolise on a field in a related layer or table in ArcGIS Pro/ArcMap?

I can't see a way to do this with relationship classes, but it would be good to know if I'm missing something.

Thanks

Vince

Suzanne-Boden
Esri Regular Contributor

Hi Vince, table joins are typically used to symbolize features in one layer using attributes from another layer or nonspatial table. Relates are great for finding and selecting features in a related layer or table, often as part of an editing workflow. Relationship classes are for when you want to do more than find and select related records, you want to enable "smart behaviors" that automate editing workflows and ensure data integrity over time. 

salwansabbar
New Contributor

Hi Suzanne,

I have two questions. First, you mentioned that Relates support only one-to-many and many-to-one cardinalities. But the ArcGIS Desktop help center mentioned that relates support one-to-many and many-to-many?

Second, I concluded that the relate is temporal and not permanent, while the relationship is permanent. Also, the table join is permanent, is that right.

thank you

Suzanne-Boden
Esri Regular Contributor

Hi, yes, you are correct. The post didn't explicitly cover many-to-many cardinality as that's a more complex topic, but it's supported in relates and relationship classes. Relates are "temporary" in the sense that they exist in a map, not as an item in a geodatabase. They remain available in the map until the map owner removes them.

Suzanne-Boden
Esri Regular Contributor

Also, regarding your question about table joins: they also remain in the map until removed. If you want the data to be permanently "joined," you can export the joined table to a new nonspatial table or new feature class. 

salwansabbar
New Contributor

Thanks Suzanne

CaitlinWilloughby
New Contributor

Hi Suzanne - great article! I am looking to have a spatial feature class with several (~6-8?) related tables in the geodatabase. The goal in setting up my data this way is to tie all the tables back to the spatial feature class without having to include all of the attributes of each table into one dataset. The data would be too large and get too unwieldly in that sense. There are no 'smart behaviors' or rules I need between the data, but more just a way to organize all the data and relate it back to the feature class.

I'm wondering if this is a good way to go about handling this big data 'relating' issue I have? Another question: does the spatial data need to be 'related' back to each table every time it's added to a new project?

Thanks! Caitlin

Suzanne-Boden
Esri Regular Contributor

Hi Caitlin, how you organize your data really depends on the types of data you're using and what you need to do with the data. Setting up table relates is an easy and convenient way to access nonspatial data associated with a layer in a map. The tradeoff is that relates are saved only in that map...however, for spatial layers, you can use the Save Layer to File tool to make the relates available in other maps/projects that include that layer. You can learn about that tool here: https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/save-to-layer-file.htm

About the Author
Suzanne is a Maryland native who enjoys writing about Esri technology and other topics. She is the Training Marketing Manager with Esri Training Services in Redlands, California.