- 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 - Directional Relationships
In Neo4j, Relationships between two nodes are directional. They are either Uni-Directional or Bi-Directional.
As Neo4j follows Property Graph Data Model, it should support only directional relationships. If we try to create a Relationship without any direction, then Neo4j DB server should throw an error
In this chapter, we will provide an example to prove this.
We use the following syntax to create a relationship between two nodes.
CREATE (<node1-details>)-[<relationship-details>]->(<node2-details>)
Here -
<node1-details> is "From Node" Node details
<node2-details> is "To Node" Node details
<relationship-details> is Relationship details
If we observe the above syntax, it is using an arrow mark: ( ) – [ ] → ( ) . It denotes a direction from left side node to right side node.
If we try to use same syntax without arrow mark like ( ) – [ ] – ( ) , it means a Relationship without direction. Then Neo4j DB server should throw an error message
Example -
This example will prove that all Neo4j Relationships are directional.
Step 1 - Open Neo4j Data Browser.
It is Neo4j Data Browser Homepage
Step 2 - Type the below command on Data Browser.
CREATE (n1:Node1)-[r1:Relationship]-(n2:Node2)
Step 3 - Click on "Execute" button and observe the message.
If we observe above error message, it shows that Neo4j CQL CREATE command supports only directional relationships.