openMetadataInitiative / openMINDS_Python

Python package for the openMINDS metadata models. The package contains all openMINDS schemas as Python classes in addition to schema base classes and utility methods.
MIT License
1 stars 2 forks source link

Should there be a check against adding the same instance multiple times to a collection? #22

Closed ehennestad closed 1 year ago

ehennestad commented 1 year ago

As far as I can se from the current code, it is possible to add an instance multiple times. Should there be a check against that? (Or am I missing something?)

apdavison commented 1 year ago

It depends what you mean by the "same instance". If you add two instances with the same @id, the second one overwrites the first in the collection.

If you have two independent instances with identical properties, but with no @id defined, then these will be treated as different.

fairgraph avoids the latter situation by defining certain properties as collectively defining identity (e.g. "givenName" and "familyName" for Person). This is something we've discussed adding to the openMINDS schemas, but I don't think we reached a conclusion on whether this should be in openMINDS, or left up to the policies of individual graph databases like the EBRAINS KG.

ehennestad commented 1 year ago

Do instances automatically get an id? Otherwise, if you are using blank node identifiers by default then the same instance, i.e same python object, could get added multiple times?

Regarding the multiple instances with identical properties, I see your point. Seems like this requires a lot of work for many instances to define what should be the defining identities.

apdavison commented 1 year ago

Do instances automatically get an id

yes, if they don't have one, they get a blank node identifier when they're added to the collection. In this case, the Python object now has a value for the "id" attribute, and so if it is added again, it won't be duplicated.

ehennestad commented 1 year ago

I see, thanks for the clarification!