Relationships
Last updated
Last updated
Relationship are a way of telling Whaly how your datasets are linked together.
It's a great way to:
Combine data from various source
Create detailed explorations
To configure a dataset relationship, go to the information tab and then scroll to the relationship block and click on Add a relationship.
In order to add a relationship you need to provide:
A dataset which will be related to the current dataset
A column from the current dataset
A column from the related dataset that will match the one selected above in values and in type (example => String can only match String columns)
A type of relationship
Has many
Belongs to
Has one
Let's imagine we have the three following tables:
Orders
Users
Address
In this example a User has multiple orders therefore when setting up relationships we will do:
Relationship 1:
From dataset: User
To dataset: Order
Type has many
From Column: user_id
To column: : user_id
Please note that "has many" is the opposite of "belongs to", therefore this relationship would have been legit too:
Relationship 2:
From dataset: Order
To dataset: User
Type belongs to
From Column: user_id
To column: : user_id
Whenever a relationship is created, the symmetric relationship is automatically created on the other dataset.
As we have the same number of rows in both the Users and Address as a User can have a single Address and vice versa, we will create a one to one relationship:
Relationship 3:
From dataset: User
To dataset: Address
Type: has one
From Column: address_id
To column: address_id
The "has one" relationship is quite rare in real world, it's relevant when you have exactly the same number of rows in the two related datasets.