I am struggling to prevent the following problem. My understanding was the the Neo4j DB automatically created unique IDs for all objects. However I have managed to create data where the same ID is shared by an unrelated Node and Relationship. See the following image:
ids are unique by object type. i.e. one can create a node which has an internal id of X and also create a relationship which also has an internal id of X. This is expected and allowed.
Neo4j reuses its internal ids when nodes and relationships are deleted. This means
that applications using, and relying on internal Neo4j ids, are brittle or at risk of
making mistakes. It is therefore recommended to rather use application-generated
ids.
one of the id is from node and other from a relationship. As @dana_canzano mentioned ->
Neo4j reuses its internal ids when nodes and relationships are deleted. This means
that applications using, and relying on internal Neo4j ids, are brittle or at risk of
making mistakes. It is therefore recommended to rather use application-generated
ids.
So this is the reason, I started to used UUID. The advantage of UUID's are its is unique across the entire database.