Identifying a New Relationship

Now for another challenge.

We need to refactor the model for a new use case:

Use case #9: What users gave a movie a rating of 5?

We have already identified the Person and Movie nodes and the ACTED_IN and DIRECTED relationships for our use cases:

  • What people acted in a movie?

  • What person directed a movie?

  • What movies did a person act in?

Model thus far

We have an additional use case that we must model for asking a question about users who rated movies. We have defined the User label to represent users who reviewed or rated movies.

1. Adding a new relationship to the model

What Relationship Type could you use when creating a relationship between User nodes and Movie to represent a rating?

  • ❏ rated

  • ✓ RATED

  • ❏ SCORE

  • ❏ RATING

Hint

A common way of talking about movie ratings is that a user has rated a movie. Once the data is created, rating the movie is in the past, so using past tense makes sense.

You format relationship types as UPPER_SNAKE_CASE.

Solution

The answer here is RATED.

rated is in the wrong case and SCORE and RATING are nouns rather than verbs.

2. Relationship Properties

What properties could you add to the relationship to support this use case? (Select any that apply)

  • ❏ RATING

  • ✓ rating

  • ❏ userId

  • ❏ tmdbId

Hint

You could say that the user has given the user a rating of between 1 and 5 stars. You format properties as lowerCamelCase.

Relationships do not need ID properties to identify the start and end nodes.

Solution

You could add a rating property to the relationship to store the user’s rating of the movie. You format properties as lowerCamelCase.

The relationship does not need userId or tmdbId properties to identify the start and end nodes.

Summary

Here is what your data model should now look like:

Current data model

In this challenge, you demonstrated your skills in identifying the connections between the entities of the domain and defining the relationships for the graph data model. In the next challenge, you will create new relationships in the graph for our instance model.