Select to view content in your preferred language

AGOL honors Composite but not Simple Relationship class rules

1627
10
09-02-2021 12:44 PM
Labels (1)
DougBrowning
MVP Esteemed Contributor

Came across this for Survery123 but posting here since it is a AGOL issue.

To review a Composite relationship class will "manage" the data.  Mainly if you delete a parent it will also delete the children.  This does seem to be honored in AGOL when editing hosted services.

A Simple class is considered "unmanaged" but that is not really true.  What Simple does is if you delete a parent all the children keys turn to Null.  (No idea why they would do that.  The big issue here is if you delete a few parents at once you can now not pull the children back apart.  Highly annoying BTW.)  The funny thing here is that AGOL is NOT honoring this rule like it does for Composite. 

No idea if this is a bug or what.  Anyone seen anything about this?  Anyone know why AGOL is diff than SDE?  I actually like it since Simple in AGOL does not null keys we are able to merge children more easily.  

As a side note

I use this trick to get around this management.  If you are not using the globalid for the relate (which you really should not) I first calculate the key field of the parent to the word Delete.  Then replicate if you have one.  Then delete the parents - this way when it goes looking for children with the key delete it finds none and all good.  The just replace the parents.

If you do use globalid (using built in 123 classes for example) then I instead change the children parentglobalid field to a value like delete.   Then when I delete the parent it cannot find any children and leaves it alone.  Then when I replace the parent I can fix the parentglobalids to the new parent.  Of course the hard part here is having a way to tell the children apart.  Need to delete one parent at a time or have a second field to hold some info that allows you to piece it back together.  This is why I always have my own key field in my data that I pass down to all my repeats.   Saves my butt on the reg.

Hope that helps someone.

10 Replies
ceverhart
New Contributor

Oh that's a good idea! For our current purposes, we just deleted that relationship class and switched the origin and destination around and made it simple. It makes one of the tables' foreign key nulled out but, that's acceptable for our purposes. Originally it was nulling the Primary Key which is incredibly undesirable haha. 

 

Thank you for posting your workaround and the other link, they were very helpful!