Unrelated Node and Relationship have same ID

Hello all,

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:

Is this behavior expected? Thank you, I've likely done something very basic wrong as I am new.

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.

Also per MATCH - Cypher Manual

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.

Hi marlo,

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.

UUID -> Universally unique identifier - Wikipedia

1 Like

Thank you @dominicvivek06 . I didn't realize about Neo4j reusing ids. I will move over to uuids. All the best.