Add Relationships

In Create and explore a Dataset, we have used a single model to answer a simple question. What if we want to know, say, the total revenue of movies released by companies in the year 2017?

The name of production companies are not in the movies_metadata model, but the movies_production_companies model. We will need to add a relationship to link these two together.

To learn more about relationship between models in Holistics, refer to Model Relationship.

Let's go through the steps to create relationship between our two models!

  1. Go back to the Data Modeling page, open the movies_jproduction_companies model

  2. Click on ... symbol on the movie_id field โ†’ Add relationship

  3. The Add Relationship modal will appear. In To field, navigate to movies_metadata model and select id field.

    The relationship between movies_production_companies and movies_metadata is n - 1 (Many-to-one) (one movie can have multiple production companies involved).

    Click Add to finish

  4. Go back to the Movies Analysis dataset. Click on ... โ†’ Add & Edit Models.

  5. The Update Dataset modal will appear. Select the movies_production_companies model to include in the dataset

  6. Click Next step. You will see that the relationship between the two models are displayed as Active. You can also switch to the Diagram tab to view have a visualization of the relationship.

  7. Click Save to finish updating the dataset. You will see the fields in the movies_production_companies model are now available in the dataset

  8. Drag in Production Company Name and Revenue fields. Click on Revenue and change the aggregation method to Sum

  9. In Conditions area, select Release Date field and choose the 2017 time range. The fastest way would be using matches operator and type in the year 2017. Clici Apply.

  10. Since not all movies have revenue figures published, we should filter out the ones without this value.

    In Conditions, search for the Revenue field and select is not null operator. Click Apply

  11. Click Get Result. We can see that Walt Disney Pictures, Warner Bros. and Universal Pictures are the top three companies with highest movie earnings.

Congratulations ๐Ÿฅณ! You are off to a good start. However,this is just a glimpse of what Holistics can do. In the next section we will explore more functionalities that enable you to answer complex analytics questions.

๐Ÿ’ก If you want to practice this section more, try setting up other models' relationships based on this diagram: https://dbdiagram.io/embed/6077d1d3b6aeb3052d90320c