Reputation: 22731
In my system I have a relational DB table with "id" columns, and I am representing some of that same data in Neo4J.
My first approach is to make an "id" attribute in Neo which correlates to the id column.
Is there any reason that this isn't a good practice? Does it conflict technically or conceptually with the node IDs that Neo generates?
Upvotes: 6
Views: 988
Reputation: 2583
If the ids serve the purpose of uniquely distinguishing the nodes that will get generated then yes its good to have one.
But keep in mind the possibility that if your graph grows in future and say a situation arrives that another DB table needs to be modelled into graph and by any chance say some ids in the new DB table conflict with the old DB table then in that situation you will get into trouble maintaining uniqueness of node.
And node ids that neo4j generates are recommended not to be used as they are prone to be reused in case the nodes are deleted.
In case you just want to model the DB table into graph database and dont want to relate the graph data to your db table later on, you can use UUID.randomUUID().toString() to generate random unique UUIDs(extremely less probability of duplicate UUID) for ids of nodes.
Upvotes: 7