cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Unrelated Node and Relationship have same ID

marlo
Node Link

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.

1 ACCEPTED SOLUTION

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

View solution in original post

3 REPLIES 3

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 - Neo4j 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

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