Tuesday 3 August 2021

Neo4j: Exercise 1: Create likes relationship

Create three persons Rama, Krishna, Naveen.

Create Likes relationship like below.

a.   Rama likes Krishna

b.   Krishna likes Naveen

c.    Naveen likes Krishna

 

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

http://localhost:7474/browser/

 


Step 2: Create three persons by executing below command.

CREATE (p1:Person{name: "Rama"}), (p2:Person{name: "Krishna"}), (p3:Person{name: "Naveen"}) RETURN p1, p2, p3




Step 3: Create LIKES relationships among persons

MATCH (p1:Person{name: "Rama"}), (p2:Person{name: "Krishna"}), (p3:Person{name: "Naveen"})

MERGE (p1)-[:LIKES]->(p2)

MERGE (p2)-[:LIKES]->(p3)

MERGE (p2)<-[:LIKES]-(p3)

RETURN p1, p2, p3

 


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment