Creating Nodes

Here is the initial instance model you will be working with:

Instance model

Run the Cypher code below to add the Person and Movie nodes to the graph which will serve as our initial instance model:

Click the Run in Sandbox button to the top right of the code sample to open the Sandbox to the right and run the query.
cypher
MATCH (n) DETACH DELETE n;

MERGE (:Movie {title: 'Apollo 13', tmdbId: 568, released: '1995-06-30', imdbRating: 7.6, genres: ['Drama', 'Adventure', 'IMAX']})
MERGE (:Person {name: 'Tom Hanks', tmdbId: 31, born: '1956-07-09'})
MERGE (:Person {name: 'Meg Ryan', tmdbId: 5344, born: '1961-11-19'})
MERGE (:Person {name: 'Danny DeVito', tmdbId: 518, born: '1944-11-17'})
MERGE (:Person {name: 'Jack Nicholson', tmdbId: 514, born: '1937-04-22'})
MERGE (:Movie {title: 'Sleepless in Seattle', tmdbId: 858, released: '1993-06-25', imdbRating: 6.8, genres: ['Comedy', 'Drama', 'Romance']})
MERGE (:Movie {title: 'Hoffa', tmdbId: 10410, released: '1992-12-25', imdbRating: 6.6, genres: ['Crime', 'Drama']})

Notice that in this code we are using the Neo4j best practice guidelines for naming labels (CamelCase) and properties (camelCase).

You can verify that the nodes have been created by running this code:

cypher
MATCH (n) RETURN n

You should have 7 nodes in the graph.

Validate Results

Once you have run the query to create the nodes, click the Check Database button and we will check the database for you.

Hint

It looks you don’t have the seven nodes from the query above in your database. Have you deleted any of them before clicking Check Database?

Solution

Try clicking Run in Sandbox on the two queries below:

cypher
Delete all Nodes
MATCH (n) DETACH DELETE n;
cypher
Create 7 Nodes
MERGE (:Movie {title: 'Apollo 13', tmdbId: 568, released: '1995-06-30', imdbRating: 7.6, genres: ['Drama', 'Adventure', 'IMAX']})
MERGE (:Person {name: 'Tom Hanks', tmdbId: 31, born: '1956-07-09'})
MERGE (:Person {name: 'Meg Ryan', tmdbId: 5344, born: '1961-11-19'})
MERGE (:Person {name: 'Danny DeVito', tmdbId: 518, born: '1944-11-17'})
MERGE (:Person {name: 'Jack Nicholson', tmdbId: 514, born: '1937-04-22'})
MERGE (:Movie {title: 'Sleepless in Seattle', tmdbId: 858, released: '1993-06-25', imdbRating: 6.8, genres: ['Comedy', 'Drama', 'Romance']})
MERGE (:Movie {title: 'Hoffa', tmdbId: 10410, released: '1992-12-25', imdbRating: 6.6, genres: ['Crime', 'Drama']})

Once you have run these queries, the following query should return 7.

cypher
Check The Graph
MATCH (n) RETURN count(n)

Once you are finished, click Try again…​ above to verify your graph.

Summary

In this challenge, you populated the graph with nodes to represent the initial instance model you will be working with in this course.

In the next challenge, you will model a new node for the graph data model.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?