The CREATE clause in neo4j is used to create graph elements — nodes and relationships.
create(a:test) return a ;
This will create a node in neo4j and default
create(a:test{name:"vipul"}) return a ;
This will create a node in neo4j and default
We can similarly create multiple properties in the node.
create(add:Address{country:"India",capital:"DELHI"})
return add
creating a relationship between the nodes
match(a:test)
where a.name="vipul"
match(add:Address)
where add.Country="India"
create(a)-[rel:LIVES_IN]->(add)
return a,add
we can create multiple relationships between 2 nodes as
match(a:test)
where a.name="vipul"
match(add:Address)
where add.Country="India"
create(a)-[rel:BELONGS_TO]->(add)
return a,rel ,add
We can also set properties to the relation as :
match(a:test)
where a.name="vipul"
match(add:Address)
where add.Country="India"
create(a)-[rel:LIVES_IN{by:"birth"}]->(add)
return a,rel ,add
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Vipul Pandey
Vipul Pandey is a good team-player & developing application on MEAN and java spring boot. Vipul loves to keep rotating fingers in his keyboard until he creates somethings inspiring.Hobbies are playing cricket ,swimming & photography.