I'm wondering how to delete a relationship between two objects. Considering we have one Layer parcel and one Table citizen/B] and a relationship such has one parcel is own by one citizen and a citizen can own many parcels.
Here are is how the layer/table look like:
Parcel ID OWNER_ID (= Citizen.ID)
Citizen ID
Exemple :
Parcel ID OWNER_ID 1 1 2 1 3 2
Citizen ID 1 2
In my code I get the relationships from parcel:
parcel.relationships[0]
Now if I want to remove the relationship between a parcel and its owner without knowing the schema how can I do that ? relationship.keyField will give me ID which is the key field in table Citizen but what about key fiekd OWNER_ID in layer Parcel ? This is this field I should set to null in order to remove the relationship.
e.g. Parcel ID OWNER_ID 1 1 2 1 3 2
In other words my question could be: given a layer, how can I know which of his attributes is used in a relationship with another layer or table ?
You need to use the APIs Relationship class: (I have always known the schema of the data I was using so I don't have any code examples for you).
keyFieldInRelationshipTable :The key field in attributed relationship class table that matches keyField. Returned only for attributed relationships. Requires ArcGIS 10.1 or later. keyField: The relationship key field. Requires ArcGIS 10.1 or later.