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!
Go back to the Data Modeling page, open the
Click on ... symbol on the
movie_idfield → Add relationship
The Add Relationship modal will appear. In To field, navigate to
movies_metadatamodel and select
The relationship between
movies_metadatais n - 1 (Many-to-one) (one movie can have multiple production companies involved).
Click Add to finish
Go back to the Movies Analysis dataset. Click on ... → Add & Edit Models.
The Update Dataset modal will appear. Select the
movies_production_companiesmodel to include in the dataset
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.
Click Save to finish updating the dataset. You will see the fields in the
movies_production_companiesmodel are now available in the dataset
Drag in Production Company Name and Revenue fields. Click on Revenue and change the aggregation method to Sum
In Conditions area, select Release Date field and choose the 2017 time range. The fastest way would be using
matchesoperator and type in the year 2017. Clici Apply.
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 nulloperator. Click Apply
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