To complete this challenge, you will need to:
- 
Review the movies.csv file and the data it contains. 
- 
Create a constraint to ensure that there are no duplicate movies. 
- 
Construct a Cypher statement to load the CSV file and create the Movie nodes. 
Movie data
Open and review the movies.csv CSV file. The file uses a comma (,) as a field delimiter and it contains headers and data for the following fields:
- 
movieId 
- 
title 
- 
budget 
- 
countries 
- 
movie_imdbId 
- 
imdbRating 
- 
imdbVotes 
- 
languages 
- 
plot 
- 
movie_poster 
- 
released 
- 
revenue 
- 
runtime 
- 
movie_tmdbId 
- 
movie_url 
- 
year 
- 
genres 
Creating the constraint
The movieId field is unique for each movie.
You should create a constraint named Movie_movieId to ensure the movieId property is unique for each Movie node.
Here is the Cypher statement you used to create the Person constraint:
CREATE CONSTRAINT Person_tmdbId
FOR (x:Person)
REQUIRE x.tmdbId IS UNIQUELoad the Movie nodes
You should construct a Cypher to:
- 
Load the movies.csv CSV file from https://data.neo4j.com/importing-cypher/movies.csv 
- 
Create the Movienodes usingMERGEwith themovieIdfield as the unique identifier.
- 
Set the following properties on the Movienodes:- 
tmdbId
- 
imdbId
- 
released
- 
title
- 
year
- 
plot
- 
budget
 
- 
Case sensitivity
The property names are case-sensitive. Make sure to use the correct case when setting the properties.
Here is the Cypher statement you used to create the Person nodes:
LOAD CSV WITH HEADERS FROM 'https://data.neo4j.com/importing-cypher/persons.csv' AS row
MERGE (p:Person {tmdbId: toInteger(row.person_tmdbId)})
SET
p.imdbId = toInteger(row.person_imdbId),
p.bornIn = row.bornIn,
p.name = row.name,
p.bio = row.bio,
p.poster = row.poster,
p.url = row.url,
p.born = row.born,
p.died = row.diedAdditional fields and data types
Later in the course, you modify the import process to include the additional fields and cast relevant data types.The import should create 93 Movie nodes.
It is a good idea to inspect the data after import. Run the following Cypher statement for return the first 25 Movie nodes:
MATCH (m:Movie) RETURN m LIMIT 25Validate Results
Once you have created the constraint and imported the Movie nodes, click the Check Database button to verify that the task is complete.
Hint
Use CREATE CONSTRAINT to create the constraint on the movieId property of the Movie label.
Construct a Cypher statement that uses LOAD CSV to import the data and MERGE to create the Movie nodes.
Solution
Run this Cypher statement to create the constraint and Movie nodes:
// Create the Movie node constraint
CREATE CONSTRAINT Movie_movieId
FOR (x:Movie) 
REQUIRE x.movieId IS UNIQUE;
// Load the Movie nodes
LOAD CSV WITH HEADERS
FROM 'https://data.neo4j.com/importing-cypher/movies.csv' AS row
MERGE (m:Movie {movieId: toInteger(row.movieId)})
SET
m.tmdbId = toInteger(row.movie_tmdbId),
m.imdbId = toInteger(row.movie_imdbId),
m.released = row.released,
m.title = row.title,
m.year = row.year,
m.plot = row.plot,
m.budget = row.budget;Summary
In this challenge, you used Cypher to create a constraint and load the Movie nodes from a CSV file.
In the next lesson, you will create relationships between the Movie and the Person nodes.