Javatpoint Logo
Javatpoint Logo

Create Relationship

CREATE statement is used to create relationship between nodes. These relationships define direction, type and form patterns of the data.

It defines mainly three things:

  • Creating Relationships
  • Creating Relationships between existing nodes
  • Creating relationships with label and properties

Creating Relationship

While creating a relationship, relationship should be specified within square braces "[ ]", depending on the direction of the relationship it is placed between hyphen " - " and arrow " ? " as shown in the following syntax.



Let's create two nodes "Raul" and "It" first and then specify the relationship between them.

Neo4j Create relationship 1

Now create a relationship "PLAYER_OF between these two nodes as ?


Neo4j Create relationship 2

You can also see it in tabular or text form:

Neo4j Create relationship 3 Neo4j Create relationship 4

You can also download (export) the graph in which format you want to save it. Click on the download button, see the example:

Neo4j Create relationship 5

Create a Relationship between existing Nodes

MATCH statement is used to create relationship between the existing Nodes.



Create a relationship using MATCH statement.


Neo4j Create relationship 6

Create a Relationship with Label and Properties

CREATE statement is used to create a relationship with label and properties.



Let's take an example to create a relationship for a node with label and properties using the CREATE statement.

First create a node "Kohli", having multiple labels

Then create some properties with the same node:

Neo4j Create relationship 7

Create another node "Ind":

Neo4j Create relationship 8

Now create a relationship with label and properties:

Neo4j Create relationship 9

Creating a complete path

In Neo4j, CREATE statement is used to create a path. A path is formed using continuous relationship.



First create a node3 name "Champions_Trophy" to do further operations.

Neo4j Create relationship 10

Now execute the following code:

Neo4j Create relationship 11
Next TopicNeo4j Create Index

Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA