Many to 1 table updates throgh Relationship Class

358
7
10-07-2013 11:28 AM
JayKappy
Occasional Contributor
Say I have a Feature Class and a Stand alone table set up with a Relationship Class
Say this is an inspection based Feature CLass....Say hydrants.  I inspect these locations once a year.
I have the relationship class there to hold the historical records of the inspections over time.

How do I add records to the related table?  If I add a record it creates a New Record in the Hydrant table...but how do I apply edits nand new records to the related table to house the historical records?

Can I edit the historical table in ArcMap? ArcGIS online?  THanks
0 Kudos
7 Replies
JoeBorgione
MVP Esteemed Contributor
Say I have a Feature Class and a Stand alone table set up with a Relationship Class
Say this is an inspection based Feature CLass....Say hydrants.  I inspect these locations once a year.
I have the relationship class there to hold the historical records of the inspections over time.

How do I add records to the related table?  If I add a record it creates a New Record in the Hydrant table...but how do I apply edits nand new records to the related table to house the historical records?

Can I edit the historical table in ArcMap? ArcGIS online?  THanks


Sounds like you have a two-way communication relationship or composite relationship: that is, a record in the table must have a record (feature) in the feature class.  It also sounds like you don't want that.  My guess is what you really want is a relationship that creates a record in your table IF/WHEN you add a fire hydrant to your feature class, right?

If so, you need to redefine your relationship class.  Once you get that straightened out, using a relationship class (or just a simple relate) is a really cool way to manage your data.  When you select a feature that is related to the table, you can add or edit records that are subsequently selected in the table through the relationship.
That should just about do it....
0 Kudos
JayKappy
Occasional Contributor
Thanks
So I created a Relationship class on the Hydrant FC and the Historical Table.
Type:  Simple
Carnality:  1- Many
Notification:  Forward (origin to destination) (Hydrant FC to Historical Table)
I didnt setup any rules at this point in the Relationship Class.

I can identify and see the related records...I can edit the related records...BUT cannot figure out how to add a new record to an existing FC point.  Any thoughts?  Is my Carnality set incorrect?  How is this accomplished.

Thanks
0 Kudos
JoeBorgione
MVP Esteemed Contributor
Thanks
So I created a Relationship class on the Hydrant FC and the Historical Table.
Type:  Simple
Carnality:  1- Many
Notification:  Forward (origin to destination) (Hydrant FC to Historical Table)
I didnt setup any rules at this point in the Relationship Class.

I can identify and see the related records...I can edit the related records...BUT cannot figure out how to add a new record to an existing FC point.  Any thoughts?  Is my Carnality set incorrect?  How is this accomplished.

Thanks


See this for an explanation better than I can provide:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//004t00000004000000.htm

In a simple relationship, related objects can exist independently of each other.


and:

In a composite relationship, destination objects can't exist independently of origin objects, so when the origin is deleted, the related destination objects are also deleted in a process called a cascade delete.


finally:

In simple relationships, getting this correct is critical. This is because when you delete a record in the origin class, the simple relationship class finds the matching records in the destination class and sets the value of their key fields to Null.



With respect to adding a hydrant, can't you simply add the feature class to an ArcMap session and then start an edit session on it?
That should just about do it....
0 Kudos
JayKappy
Occasional Contributor
Yes I can add a new feature to the Hydrant FC no problem and it adds a record to the historical table.
But I want to add multiple records to the Historical table relating to that single Hydrant.
That make sense?
The Historical table is simply a stand alone table...no geometry.
0 Kudos
JoeBorgione
MVP Esteemed Contributor
Yes I can add a new feature to the Hydrant FC no problem and it adds a record to the historical table.
But I want to add multiple records to the Historical table relating to that single Hydrant.
That make sense?
The Historical table is simply a stand alone table...no geometry.



And?  That is how it is supposed to work.  If you want to add an additional record to the table, edit it too.  Just be sure to put in the correct value in the key field and you're good to go.  (BTW, yeah, I know what a table is... Thanks.)
That should just about do it....
0 Kudos
JayKappy
Occasional Contributor
And?  That is how it is supposed to work.  If you want to add an additional record to the table, edit it too.  Just be sure to put in the correct value in the key field and you're good to go.  (BTW, yeah, I know what a table is... Thanks.)


I was not implying that you did not know what a Table was...no need to get snippy.....just trying to point out that the related object was not another FC with Geometry but rather a table, if that were to affect things.
I was hoping for something a little more automatic....
So what you are saying is:

  1. that I have to actually figure out what Key field I am dealing with in the main FC

  2. Go back to the related table and add a new record and manually type in the ID from the main FC record I am dealing with.

0 Kudos
JoeBorgione
MVP Esteemed Contributor
I was not implying that you did not know what a Table was...no need to get snippy.....just trying to point out that the related object was not another FC with Geometry but rather a table, if that were to affect things.
I was hoping for something a little more automatic....
So what you are saying is:

  1. that I have to actually figure out what Key field I am dealing with in the main FC

  2. Go back to the related table and add a new record and manually type in the ID from the main FC record I am dealing with.



Okay; fair enough.  I'll keep the snippiness to minimum...

1. Yes
2. Yes

But to elaborate:  it seems as though you have table in some format that has the historical data in it.  You have a feature class with hydrants. And you need to create a relationship where there currently isn't one.  Is this correct?

If that is the case, I can not see how you can automatically create a relationship.  However, if there is something, anything, that appears in both the feature class and the stand alone table that can tie a hydrant to one or more of the historical records you can then create the needed relationship.  Maybe an address? Or serial number? Or..?  And if you can do this, I wouldn't necessarily create a relationship class, but rather just a relate in ArcMap.  You can come back to a relationship class later.

Assuming have a relate set up in ArcMap; add a field to your feature class called something like MyKey or JoinID etc and calc it equal to to the objectid.  That value will never change and it ensures a unique value.  As you add features sometime in the future, you'll need to calc that field accordingly.  Add a similar field in your historical table; leave them null.  

If you are a python guy you can probably use a cursor to step through each feature, select it, use the related tables function to select the appropriate related records, and calculate the the <null> key field in the table to the value specified in the the selected feature class, and be on your way back to the relationship class concept.

If you're not a programmer, the grunt work begins. And you'll perform the described workflow manually.  Select feature, related table, calc related records id field; repeat ad nauseum. (But what else are you going to do in a bright, crisp fall afternoon?)

You may ask if I have a serial number that is unique to the hydrant, and that serial number appears in my historical data table, why do I need to do this?  The short answer is you don't, really.  But this will just establish a nice clean item to maintain the relationship with, that is used for nothing else.  You'll be able to create your relationship class, add new hydrants (that have no history) and then add history records related to that new hydrant as needed. 

Now if there is nothing at all for you to establish the initial relationship, or I've completely missed the boat here, my apologies for wasting your time.
That should just about do it....
0 Kudos