Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Neo4j Create Relationship

  • Last Updated : 23 Aug, 2019

In Neo4j to create relationship between nodes you have to use the CREATE statement like we used to create nodes. lets create relation between two already created nodes.

  • Already created nodes:
  • Query to create relation:
    $ MATCH (a:GeeksforGeeks), (b:W3School)
    WHERE a.Name = "A Computer Science Portal" AND b.Name = "We are the Learner"
    CREATE (a)-[r:edutech]->(b)
    RETURN r
  • Output of above query:

    To create multiple relationship between nodes:
    You can see how easy it is to continue creating more nodes and relationships between them. So we will create one more node and add two more relationships.

  • Creating a new node:
    $ CREATE (c:Company { Name: "Tuitorial" })


  • Creating relationship:
    MATCH (a:GeeksforGeeks), (b:W3School), (c:Comapny)
    WHERE a.Tag = "A Computer Science Portal" AND b.Tag = "We are the Learner" AND 
    c.Name = "Tuitorial" CREATE (c)-[pr:PRODUCED]->(b), (c)-[pr1:PROVIDER]->(a)
    RETURN a, b, c


    My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!