Relating several feature classes to a single attachment table

1136
4
07-13-2018 05:30 PM
CharlottePeters2
New Contributor III

Hi,

I'm familiar with creating or enabling attachments for a feature class or table in ArcCatalog and ArcGIS Online. Is there a way to have several feature classes in a FGDB relate to a single attachment table using one:many relationships between each feature class and the one attachment table? I've tried the following, which didn't work:

  • creating my own attachment table with a BLOB data type field and a GUID field for each connecting feature class' Global ID
  • creating attachments for one feature class (e.g. survey_ATTACH) in ArcCatalog and then creating new relationships between each of the other feature classes to the newly created survey_ATTACH table using the parent's GlobalID to the child's REL_GLOBALID.
  • copying the survey_ATTACH table, adding GUID fields to hold each of the feature classes GLOBALID and creating relationships between each feature class and the survey_ATTACH table

I was hoping to lump all photos from all the feature classes into a single attachment table instead of the 9-10 attachment tables for the FGDB.

Thanks.

4 Replies
JoeBorgione
MVP Emeritus

Using a GUID as the relate key can be tricky business.  If the data is collected in geodatabase and then moved into another gdb, those guids get changed.  My suggestion is to add another fieild and name it something like RelateID or JoinID.  You make it a text fields of 255 characters and then calulate it's value of the original GUID.  That value is a static snapshot so it persists regardless of where the data ends up living. Create your subsequent relationship classes based on this field.

Like so many things in life there is a trade of when using this procedure.  It's up to you to you to add new relate field values when records are added....

That should just about do it....
0 Kudos
CharlottePeters2
New Contributor III

Thanks for the suggestion on preserving the GUID. Whether I use GUID or another relate field, I still cannot seem to create a single table that will accept attachments, photos in my case, from multiple feature classes (FC). I have 5 FCs that need to have attachments. Instead of creating an attachment table for each FC, I want to have a single attachment table and relate all the FCs to the table via one:many relationships. When I create the relationships, ArcMap, ArcGIS Pro, and ArcGIS Online do not recognize the table as an attachment table. When I use the 'create attachments' feature in ArcCatalog, I can attach files to a single FC.

0 Kudos
JoeBorgione
MVP Emeritus

Hmmm.... That's interesting.  All of it.

Re-thinking my earlier suggestion, I think you will need a series of 5 different relate fields in your attachment table:

FC1_Relate, FC2_Relate, FC3_Relate, FC4_Relate, FC5_Relate

In each of your 5 feature classes, you'll just have one relate field (aka the 'Key' field).

How do you 'create attachments' feature in ArcCatalog' ?  Looking at An overview of the Attachments toolset—Help | ArcGIS for Desktop , I don't see such a tool and the help makes me wonder if you'll actualy be able to accomplish your goal of one attachment table with  mulitple feature classes.

That should just about do it....
0 Kudos
CharlottePeters2
New Contributor III

To create attachments in ArcCatalog, right click the FC in ArcCatalog>>Manage>>Create attachments. It creates the [parent name]_ATTACH table and [parent name]_ATTACHREL relationship. The graphic shows attachment tables/relationships created for tables.

Create attachments in ArcCatalog

By default, the _ATTACH table contains the following fields where the REL_GLOBALID field is used to relate to the parent GlobalID:

One way I tried was to create relationship classes between each FC and the one _ATTACH table that I had ArcCatalog create for FC0 so:

  • FC1:FC0_ATTACH using parent GlobalID from FC1 to FC0_ATTACH REL_GLOBALID
  • FC2:FC0_ATTACH using parent GlobalID from FC2 to FC0_ATTACH REL_GLOBALID
  • and so on for the other FCs

That didn't work in the sense that the table would show up in ArcMap, ArcGIS Online, and Collector for ArcGIS but I couldn't add any attachments except for FC0.

Another way I tried was to add GUID fields to the FC0_ATTACH table for every FC I wanted to relate, which sounds like what you suggested earlier.

  • FC1:FC0_ATTACH using parent GlobalID from FC1 to FC0_ATTACH FC1_GlobalID
  • FC2:FC0_ATTACH using parent GlobalID from FC2 to FC0_ATTACH FC2_GlobalID
  • and so on

That approach yielded the same results as the first approach.

To add to the confusion of how ESRI handles attachments. I used ArcCatalog to auto create attachments for an Assessment FC, which gave me:

  • Assessment FC
  • Assessment_ATTACH table
  • Assessment_ATTACHREL relationship

I looked at the Relates property for Assessment FC in ArcMap and could not see the _ATTACHREL relationship listed; however, I could still add attachments. The relationship shown in the graphic below is for another table and not for the Attachment table.

ArcCatalog attachment

Then I manually created a relationship between a Camera FC (in the same FGDB as Assessment) to the Assessment_ATTACH table using parent GlobalID to child REL_GLOBALID. Since the Assessment_ATTACH relationship works for Assessment FC, I thought I could hitch the Camera FC to the same attachment table and inherit all the attachment capabilities afforded the Assessment FC. Wrong! I could still add attachments for the Assessment FC, but not for the Camera FC. I look at the relate properties for the Camera FC and the relationship I created between Camera FC:Assessment_ATTACH is in the list.

manual attachment

It makes me wonder if there is something going on behind the scenes to make the attachment relationships work that isn't exposed to the user. Also wonder if a personal GDB would treat attachments differently seeing as how it follows the Access database schema. A rabbit hole for another day. For now, I'll do it the ESRI way and create attachments for every FC/table that needs it.

Thanks.