Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good practice to use an "id" attribute in Neo4J?

Tags:

neo4j

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?

like image 833
John Bachir Avatar asked Jan 21 '14 05:01

John Bachir


People also ask

What are the weaknesses of Neo4j?

Neo4j has some upper bound limit for the graph size and can support tens of billions of nodes, properties, and relationships in a single graph. No security is provided at the data level and there is no data encryption. Security auditing is not available in Neo4j.

What can you do to improve the performance of Neo4j?

Heap Sizing The size of the available heap memory is an important aspect for the performance of Neo4j. Generally speaking, it is beneficial to configure a large enough heap space to sustain concurrent operations. For many setups, a heap size between 8G and 16G is large enough to run Neo4j reliably.

What must Relationships in Neo4j have?

Relationships always has a direction (one direction). Relationships must have a type (one type) to define (classify) what type of relationship they are. Nodes and relationships can have properties (key-value pairs), which further describe them.


1 Answers

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.

like image 130
Sumeet Sharma Avatar answered Oct 05 '22 03:10

Sumeet Sharma