Cypher queries - lerics/neo4j_intro_jduchess GitHub Wiki

A great comparison between Cypher and SQL (you will recognize some of the queries) Cypher for SQL Professionals http://watch.neo4j.org/video/60292144 http://docs.neo4j.org/chunked/snapshot/examples-from-sql-to-cypher.html

Queries I ran during the presenation

Directors Daniel Craig worked with

START craig=node:Person(name="Daniel Craig") MATCH craig-[r:ACTS_IN]->movie<-[:DIRECTED]-dir RETURN movie,movie.title, r.name, dir.name

Every person who both acted and directed

This is an example of a query that is not a sweet spot for graphs as we have to look through all the person nodes and their relationships

START n=node:Person("name:*") MATCH n-[:ACTS_IN]->(), n-[:DIRECTED]->() RETURN DISTINCT n.name

Craigs coactors

START dc=node:Person(name="Daniel Craig") MATCH dc-[:ACTS_IN]->movie<-[:ACTS_IN]- coactor RETURN DISTINCT coactor, coactor.name

Craig -> Bacon

START dc=node:Person(name="Daniel Craig"), kevin=node:Person(name="Kevin Bacon") MATCH p = shortestPath(dc-[:ACTS_IN*]-kevin) RETURN EXTRACT(n in NODES(p) : COALESCE (n.name?, n.title?))