Unique Identifier Best Practice

I'm working on a requirement for a corporate knowledge application.
Users can create articles and we store the articles in a MongoDB where they get a unique ObjectID.
Subsequently we store the article in our Neo4J database and create the needed relations.

What is the best practice to uniquely identify nodes and keep the reference to the document in MongoDB?
Should we use a plugin like neo4j-uuid to automatically generate an id and additionally store the ObjectID as another attribute on the node? Or should we just solely store the ObjectID on the node?

We need to keep the reference so we can find the corresponding document in MongoDB but also need to be able to get nodes by id.

I'm not sure what adding a new uuid via neo4j-uuid (or apoc function) would add, if it were me I would just go with a simple node property that has a uniqueness constraint on it (and therefore an index as well)

That sounds right, thanks. What about other nodes that do not have a reference to our MongoDB?

Shouldn't be an issue -

Unique constraints do not mean that all nodes have to have a unique value for the properties — nodes without the property are not subject to this rule.


To expand on what Terry was saying. You could/should use the provided ObjectID with a uniqueness constraint, since you already know that's the unique identifier. That will make it easier down the road vs introducing another prop to manage for uniqueness.

1 Like