Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Neo4j: Add label, properties to a relationship

Syntax

CREATE (node1)-[label:Rel_Type {key1:value1, key2:value2, . . . n}]-> (node2)

Example

CREATE (RamaKrishna:Person{name: "Rama Krishna", age: 32, city: "Bangalore", male: true})
CREATE (MuraliKrishna:Person{name: "Murali Krishna", age: 34, city: "Hyderabad", male: true})
CREATE (RamaKrishna)-[c:COLLEAGUES {since: "5 yrs", organization: "yahoo"}]->(MuraliKrishna)


Step 1: Open neo4j browser by hitting following url in browser.

http://localhost:7474/browser/

 




Step 2: Execute below queries to create nodes and relationship among them.


 

CREATE (RamaKrishna:Person{name: "Rama Krishna", age: 32, city: "Bangalore", male: true})
CREATE (MuraliKrishna:Person{name: "Murali Krishna", age: 34, city: "Hyderabad", male: true})
CREATE (RamaKrishna)-[c:COLLEAGUES {since: "5 yrs", organization: "yahoo"}]->(MuraliKrishna)

 


 

Step 3: Get the node to verify.

MATCH (n) RETURN n


 

Previous                                                    Next                                                    Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Neo4j: Add label, properties to a relationship

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×