You are on page 1of 3

CSE3086 20MIA1002

LAB ASSIGNMENT – 11
create (p1:Person{name: "Micheal"}),(p2:Person{name: "Jennifer"}), (p3:Company{name:"
Neo4j"}),(p4:Technology {type:"Graphs"})

match (a:Person),(b:Person) where a.name="Micheal" and b.name = "Jennifer" create (b)-


[:IS_FRIENDS_WITH {since:2018}]->(a)

match (a:Technology),(b:Person) where a.type="Graphs" and b.name = "Jennifer" create (b)-


[:LIKES]->(a)

match (a:Company),(b:Person) where a.name="Neo4j" and b.name = "Jennifer" create (b)-


[:WORKS_FOR]->(a)

match (n) return n

Q2) Display the details of students who have registered NoSQL in c1 slot under
faculty “ABC”. Display the details of students who have registered NoSQL in
c2 slot under faculty “XYZ”. Design the appropriate graph to display the result
for the above queries. Make sure to use properties in nodes and relationships.
create (s1:Student{name:"alan"}),(s2:Student{name:"bob"}),(s3:Student{name:"clerk"}),(s4:
Student{name:"dave"}),(t1:Teacher{name:"abc"}),(t2:Teacher{name:"xyz"})

match (a:Teacher),(b:Student) where a.name = 'abc' and b.name = 'alan' create (b)-
[:Register{slot:'c1'}]->(a)

match (a:Teacher),(b:Student) where a.name = 'abc' and b.name = 'bob' create (b)-
[:Register{slot:'c2'}]->(a)

match (a:Teacher),(b:Student) where a.name = 'xyz' and b.name = 'dave' create (b)-
[:Register{slot:'c2'}]->(a)

match (a:Teacher),(b:Student) where a.name = 'xyz' and b.name = 'clerk' create (b)-
[:Register{slot:'c1'}]->(a)
match(n) return n

match (a:Student)-[r:Register{slot:'c1'}]->(b:Teacher{name:"abc"}) return a.name

match (a:Student)-[r:Register{slot:'c2'}]->(b:Teacher{name:"xyz"}) return a.name

Q3) Load your own studentregno.csv file into a graph in neo4j.


LOAD CSV WITH HEADERS FROM "file:///student20mia1002.csv" AS line
CREATE (n:Node { latitude: toFloat(line.latitude), longitude: toFloat(line.longitude), rssi: lin
e.rssi })

MATCH (n:Node) RETURN n

Q4) Delete the relationship IS_FRIENDS_WITH between two-person labelled


nodes from question 1. Delete the node Neo4j company from question 1.
match (Person{name:"Jennifer"})-[r:IS_FRIENDS_WITH]->() delete r

match (n:Company{name:'Neo4j'}) detach delete n

You might also like