I want to hold relationships in neo4j but (maybe, I've not decided yet) to keep the objects in different DB (sort of Redis). And if to do so, it would be good to sync IDs in storage db and in neo4j. So, can I create a node in neo4j passing the ID to it?
PS project in PHP and accessing neo4j via REST API.
Creating a Single node You can create a node in Neo4j by simply specifying the name of the node that is to be created along with the CREATE clause.
In Neo4j, "Id" is a default internal property for both Nodes and Relationships. That means, when we create a new Node or Relationship, Neo4j Database Server will assign a number for internal usage. It is incremented automatically.
Node or Relationship Properties To represent these in Cypher, we can use curly braces within the parentheses of a node or the brackets of a relationship. The name and value of the property then go inside the curly braces. Our example graph has both a node property ( name ) and a relationship property ( since ).
A relationship connects two nodes — a start node and an end node. Just like nodes, relationships can have properties. Relationships between nodes are a key part of a graph database.
If you look closely, the labels column is in the form of an array, which means that a single node can have multiple labels. Also, with cypher projection, we can provide a virtual label, as shown in the query.
You normally can't, only if you use the BatchImporter, http://docs.neo4j.org/chunked/snapshot/indexing-batchinsert.html, you can specify the IDs to use.
Otherwise it is sensible to use external id's as node properties and index the nodes on those properties. So you have bi-directional resolutions of your external id's.
The indexing can also be done using the auto-indexer, so it happens automatically on node creation, update and removal.
You might also look into Neo4jPHP as a library to access Neo4j's REST API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With