Adding Language Data

In the previous lesson, you learned that duplicating data in the graph can be expensive. To illustrate duplication of data, you will add a languages property to each Movie node in the instance model.

Execute this Cypher code to add a languages property to the Movie nodes of the graph:

cypher
Adding a Language Property
MATCH (apollo:Movie {title: 'Apollo 13', tmdbId: 568, released: '1995-06-30', imdbRating: 7.6, genres: ['Drama', 'Adventure', 'IMAX']})
MATCH (sleep:Movie {title: 'Sleepless in Seattle', tmdbId: 858, released: '1993-06-25', imdbRating: 6.8, genres: ['Comedy', 'Drama', 'Romance']})
MATCH (hoffa:Movie {title: 'Hoffa', tmdbId: 10410, released: '1992-12-25', imdbRating: 6.6, genres: ['Crime', 'Drama']})
MATCH (casino:Movie {title: 'Casino', tmdbId: 524, released: '1995-11-22', imdbRating: 8.2, genres: ['Drama','Crime']})
SET apollo.languages = ['English']
SET sleep.languages =  ['English']
SET hoffa.languages =  ['English', 'Italian', 'Latin']
SET casino.languages =  ['English']

And here is the associated instance model:

Instance model with languages

Querying languages

Here is a query to support our new use case:

Use case #11: What movies are available in a particular language?

With this query, we find all movies in Italian.

Execute this query and answer the next question.

cypher
Movies in Italian
MATCH (m:Movie)
WHERE 'Italian' IN m.languages
RETURN m.title

In quale film si parla italiano?

Which movie features dialogue spoken in Italian?

  • ✓ Hoffa

Hint

You will have to run the two queries above in sequence to find the movie with Italian listed within the .languages property.

Once you have done so, execute Movies in Italian code block above to reveal the answer.

Solution

You may be able to tell from the first code block that the answer is Hoffa.

Summary

In this challenge, you added a languages property to each Movie node to support the new use case.

In the next lesson, you will learn how to refactor duplicate data.