Select to view content in your preferred language

Query Relationship Classes?

8341
15
02-27-2017 10:56 AM
EricMahaffey1
Frequent Contributor

I can't seem to find anything that describes what to do with relationship classes once they are built.  Until now, all I can do is identify on the features in ArcMap, then click through the tree structure within the identify window in order to see the related records.  That's fine, but what about the ability to query the related features/records?  For instance, suppose you had a relationship class built for relating city blocks to the parcels within them.  I'd like to build a query to show all parcels that are "related" to a particular city block.  I just can't seem to find any guidance on doing these types of queries.  Thanks in advance.

0 Kudos
15 Replies
Asrujit_SenGupta
MVP Regular Contributor

By query, I assume you referring to SQL queries from Database end.

Why do you need to use the Relationship class to query related records? Finding related records can be done through pretty simple queries. If you are facing issues creating SQL queries, maybe provide us a sample of data that you have and the query that you have tried.

Correct me if I misunderstood the question.

You can check below anyway:

Benefits of relationship classes—Help | ArcGIS Desktop 

0 Kudos
EricMahaffey1
Frequent Contributor

I'd like to be able to do some basic queries on the related data through ArcMap.  Currently when I try to do a definition query, there's no option to access the related data.  Basically my question is, once the relationship classes are created, what can we do with them?

JakeSkinner
Esri Esteemed Contributor

Here are the benefits of relationship classes:

Benefits of relationship classes—Help | ArcGIS for Desktop 

The Web AppBuilder Query Widget allows you to interact with the related info too:

Query widget—Web AppBuilder for ArcGIS | ArcGIS 

JakeSkinner
Esri Esteemed Contributor

Hi Eric,

Add the feature class/tables to ArcMap that participate in the relationship class.  Open the attribute table of the city blocks feature class/table and perform your selection.  At the top left of the attribute table you click on the 'Related Tables' tool. 

This will list the related tables.  Selecting the related table will open the attribute table of the parcels with the selected records.

EricMahaffey1
Frequent Contributor

Thanks Jake.  I think I'll need to look at it a little more.  I think what I'm trying to come up with is a way to run some canned queries based on common values within the related data, and have these queries embedded within a geoprocessing model or python script.  Then I can attach to a tool, and give the end user some basic query/display capability to look at how the data is related with each other.

EricMahaffey1
Frequent Contributor

So looking at it a little more, I'm still not finding anything that answers my question.  I'm working within ArcGIS Desktop so using a Web App Query Widget won't be an option.  For years I've used Select By Attributes, and Definition Queries to parse out different pieces of data that have similar attributes.  Why can't these tools reach through a relationship class to all of the data?  Going back to my Blocks and Parcels example, suppose there many parcels being owned by a single person.  I'd like to select or query out only those parcels (without adding an owner field to parcels and mass populating it with redundant owner names).  Or another example would be, I'd like to select/query for all blocks that owner "John Doe" or "Sally Smith" has property in.  I hope what I'm saying makes sense, because I'd really like to benefit from the relational data that we're assembling. 

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Going back to my Blocks and Parcels example, suppose there many parcels being owned by a single person.  I'd like to select or query out only those parcels (without adding an owner field to parcels and mass populating it with redundant owner names). 

For this example, you would add the parcel feature class and owner table to ArcMap.  Perform your select by attribute on the owner table.  Open the attribute table of the owner table > click on the 'Related Tables' button > select the relationship class to the Parcel feature class.  The parcel feature class attribute table will open with the selected parcels.

EricMahaffey1
Frequent Contributor

Thanks Jake.  That works.  I'll do some more testing, and maybe come back with some more questions.  I appreciate the feedback.

0 Kudos
EricMahaffey1
Frequent Contributor

Jake,

So I've tinkered with this a bit more, and I'm getting the results I'm looking for by doing selections on the features or geometry, then clicking the relationship class under Related Tables in the Table window.  Do you happen to know if this workflow is accessible in Python?  Searching for geoprocessing tools within ArcGIS Desktop doesn't yield anything beyond the building of relationship classes.  I essentially want to build some tools the allow the user to do some basic querying, and which results in the selection and display of related features/records.  The problem is, I have to work within the dekstop environment at the moment.