NEO4J Sample Query and Flask

Last week I posted a neo4j database sample for a small management system. Now we have to try run a sample query for that. Here’s the sample queries.

Basic Query: Who do people report to?

MATCH
(e:Employee)<-[:REPORTS_TO]-(sub:Employee)
RETURN
*

Who is in Robert(any name written in employee) reporting?

MATCH
p=(e:Employee)<-[:REPORTS_TO]-(sub:Employee)
WHERE
sub.firstname=”Robert”
RETURN
p

Who is the Big Boss?

MATCH
p=(e:Employee)
WHERE
NOT (e)-[REPORTS_TO]->()
RETURN
e.firstname as bigBoss


Companies Cross-Sell .

MATCH
(choc:Product {productName: ‘Chocolade’})
<-[:PRODUCT]-(:Order)<-[:SOLD]-(employee),
(employee)-[:SOLD]->(o2)-[:PRODUCT]->(other:Product)
RETURN
employee.firstname, other.productName, count(distinct
o2) as count
ORDER BY
count DESC
LIMIT 5;

 

I am learning to about the neo4j Flask. Neo4j flask is like django of python.

Continues learning about neo4j will be a must. I see now the importance of a NoSql or a graphdb unto Sql databases. Indeed it is much useful but is hard to query.

Next will be purely learning Flask and py2neo.

Leave a Reply