- Neo4j Tutorial
- Neo4j - Home
- Neo4j - Overview
- Neo4j - Data Model
- Neo4j - Environment Setup
- Neo4j - Building Blocks
- Neo4j CQL Write Clauses
- Neo4j - Merge Command
- Neo4j - Set Clause
- Neo4j - Delete Clause
- Neo4j - Remove Clause
- Neo4j - Foreach Clause
- Neo4j CQL Read Clause
- Neo4j - Match Clause
- Neo4j - Optional Match Clause
- Neo4j - Where Clause
- Neo4j - Count Function
- Neo4j CQL General Clauses
- Neo4j - Return Clause
- Neo4j - Order By Clause
- Neo4j - Limit Clause
- Neo4j - Skip Clause
- Neo4j - With Clause
- Neo4j - Unwind Clause
- Neo4j CQL Functions
- Neo4j - String Functions
- Neo4j - Aggregation Function
- Neo4j CQL Admin
- Neo4j - Backup & Restore
- Neo4j - Index
- Neo4j - Create Unique Constraint
- Neo4j - Drop Unique
- Neo4j Useful Resources
- Neo4j - Quick Guide
- Neo4j - Useful Resources
- Neo4j - Discussion
Neo4j - ID Property
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.
We will go through an example to understand this concept
Example
This example demonstrates how Neo4j DB server assigns an Id Property to a Node and how to view this property value.
Step 1 - Open Neo4j Data Browser
Step 2 - Type the below command on Data Browser
CREATE (tweet:Tweet{message:"Hello"})
Step 3 - Click on "Execute" button and observe the results.
It creates one Node with one Property and one Label.
Step 4 - Type the below command on Data Browser and Click on "Execute" button to observe the results.
MATCH (tweet:Tweet{message:"Hello"}) RETURN tweet
Step 5 - Click on "Execute" button to observe the results.
Step 6 - Click on circle to view Tweet Node properties
If we observe this, we can find an id = 0 property added to this node. When we create another Node, Neo4j DB server will automatically increment this number
Step 7 - Type the below command on Data Browser
CREATE (tweet:Tweet{message:"Hello"})
Step 8 - Click on "Execute" button and observe the results.
It creates one Node with one Property and one Label.
Step 9 - Type the below command on Data Browser and Click on "Execute" button to observe the results.
MATCH (tweet:Tweet{message:"Hello"}) RETURN tweet
Step 10 - Click on circle to view Tweet Node properties
Here we can observe that Node id value is incremented and assigned to one
Note -
In the same way, Neo4j DB server assigns one default Id property to Relationships.
- Maximum value of Id Property of Node's is around 35 Billion.
- Maximum value of Id Property of Relationship's is around 35 Billion.