Goals This guide explains the basic concepts of Cypher, Neo4j’s query language, including how to create and query graphs. You should be able to read and understand Cypher queries after finishing this guide. Prerequisites You should have familiarized yourself with… Read more →
This guide explains the basic concepts of Cypher, Neo4j’s query language, including how to create and query graphs. You should be able to read and understand Cypher queries after finishing this guide.
You should have familiarized yourself with Graph Databases and the Property Graph Model.
The Movie Graph is a mini graph application containing actors and directors that are related through the movies they’ve collaborated on.
It is available in your Neo4j Browser if you execute
It is helpful if you run the queries as you go along, but you should understand them even so.
This guide will show you how to:
- Create: insert movie data into the graph
- Find: retrieve individual movies and actors
- Query: discover related actors and directors
- Solve: the Bacon Path
Hidden below this text is a giant code block containing a single Cypher query statement composed of multiple
This will create the movie graph.
(You can unfold it with the little [role=’icon-plus-sign-alt’]plus button)
Example queries for finding individual nodes.
- Look at every query example
- Run the query with the play button
- Notice the syntax pattern
- Try looking for other movies or actors
Find the Person Named “Tom Hanks”…
Find the Movie Titled “Cloud Atlas”…
Find 10 People…
Find Movies Released in the 1990s…
Finding patterns within the graph.
- Actors are people who acted in movies
- Directors are people who directed a movie
- What other relationships exist?
List All Tom Hanks Movies…
Who Directed “Cloud Atlas”?
Tom Hanks’ Co-Actors…
Solve the Six Degrees Question
You’ve heard of the classic “Six Degrees of Kevin Bacon”? That is simply a shortest path query called the “Bacon Path”.
- Variable length patterns
- Built-in shortestPath() algorithm
Movies and Actors up to Three Hops Away from Kevin Bacon
The Bacon Path to Meg Ryan
When you’re done experimenting, you can remove the movie data set.
- Nodes can’t be deleted if relationships to them exist
- Delete both nodes and relationships together
|This will remove all Person and Movie nodes!|