Relationship Class Question

515
5
04-30-2014 01:10 PM
JasonGonzalez
New Contributor
Hi, I created a relationship class between a feature class and a table. When I open the attribute tables, I can select a record from the feature class and then see the associated records from the other table (1 to many, in this case).

My question is, is it possible to run a query on this relationship class and create a new table based on that new query?

Thanks.
0 Kudos
5 Replies
WilliamCraft
MVP Regular Contributor
Are you asking if it's possible to have records from the related table be selected automatically based on what you select in the feature class, and then export the selected records from the related table to a new table?  If so, then the answer is 'yes'. 

  1. Issue a selection against your feature class in ArcMap, either using Select By Location, Select By Attribute, or manually selecting whatever records you need through the attribute table or the map. 

  2. Once you've made your selection against your feature class, open the attribute table and click the Related Tables button.  That is the button with two little green tables and two arrows; it's at the top left of the feature class attribute table.  The related table is displayed with the related records selected. 

  3. Once the selected records appear for the related table, you can export only the selected records to create your new table either from the attribute table (top left drop-down button at the top) or from the Table of Contents (right click the table). 

These steps assume you have a relationship class set up between your feature class and your related table as you described earlier.  Does this answer your question?  If so, please mark the correct answer with the green check.

Here is the help section on accessing related records.  I'm assuming 10.2 at the moment.
0 Kudos
JasonGonzalez
New Contributor
Hi, thank you. That worked. However, maybe I'm heading down the wrong track because the results weren't what I was expecting.

Here is my situation;
I have a feature class of users and a table of non-spatial data. Both have a unique ID in common.

I want to be able to query the feature class and table to create new table(s). So for example, I might query the feature class to give me everyone between the age of 22-30 years old but also at the same time, give me any records from the table where a field is 'yes' and the id's between the two (feature class and table) are the same?

It's not that I don't know how to write the query for this, its just that I cant figure out which tool or function to use. I thought the relationship would do this, and it did, but its not allowing me to export data from both. If I do as you suggested, I can only export from one table.

Any idea on how to query to tables, keep the one-to-many relationship and then export to a new table?
0 Kudos
WilliamCraft
MVP Regular Contributor
but its not allowing me to export data from both. If I do as you suggested, I can only export from one table.


I'm not sure that I understand the problem you're having.  The selected records from the feature class can also be exported in the same fashion as described with the related table.  So, you query the feature class, then export the selected features into a new feature class, then walk through the steps I described above in order to produce the new table from the selected related records.
0 Kudos
JasonGonzalez
New Contributor
When I do the export, depending on which table I have open, I only get the records from that one table. I never get an export with the user info and the related data from the table.

I should say that the relationship does work, I can manually select a record from users feature class and then click the Related Tables icon and see the associated records.

Its just that the export doesn't have data from both. And really, I don't see how it could create a new table since, for example, if I select one user, he may have 20 entries from the table.
0 Kudos
WilliamCraft
MVP Regular Contributor
Exporting from one does not imply that you would or should get records from the other.  Just because they're related via relationship class doesn't mean anything when you're talking about exporting selected records.  The exports for selected records have to be done separately no matter how you make your selection.  So, exporting feature class records to a new feature class would not mean that you could automatically get the related records from the table... and vice versa.  It's just the way the software is designed.  The fact that the relationship class is set up as 1-M (one to many) has nothing to do with this.  The only exception to this rule is in the case of a Copy/Paste from within ArcCatalog... but in that case you're dealing with the entire recordsets rather than a selection set from each.
0 Kudos