Graph-Oriented Databases : Introduction with Neo4J
In this tutorial, you'll have to import the following script : dump
MATCH (a)-[:'FRIEND']->(b) RETURN a,b
MATCH (someone)-[:FRIEND]->(mf)<-[:FRIEND]-(other)
//identify a node which is at the same time a friend of "someone" and a friend of "other"
WHERE someone.name = "Annie" and other.name = "Lisa"
//"other" is set to "Lisa" and "someone" is "Annie"
RETURN mf.name
MATCH (someone)-[:FRIEND]->(mf)<-[:FRIEND]-(other)
//identify a node which is at the same time a friend of "someone" and a friend of "other"
WHERE someone.name = "Annie" and other.name = "Lisa"
//"other" is set to "Lisa" and "someone" is "Annie"
RETURN count(mf)
MATCH (someone)-[:FRIEND]->(mf)<-[:FRIEND]-(other)
//identify a node which is at the same time a friend of "someone" and a friend of "other"
WHERE someone.name = "Annie"
//"other" can be whoever and "someone" is "Annie"
RETURN mf.name
OPTIONAL MATCH (someone)-[:FRIEND]->(mf)<-[:FRIEND]-(other)
//get all the nodes with common friends, OPTIONAL will allow to fetch the results even incomplete,
// due to that only part of the clause is verified.
RETURN someone.name AS Friend1, other.name AS Friend2, count(mf) AS Count
//return the name of the connected nodes, and their associated count
ORDER BY count(mf) DESC LIMIT 2
MATCH (l:Label) RETURN count(l) as Labels
MATCH (n)
RETURN DISTINCT count(labels(n)), labels(n);