Define a relationship
Connect two models through matching properties.
A relationship lets an explore use fields from two models. It specifies which properties match and how many rows can match on each side.
Before you start
You need Builder, Admin, or a custom role with model editing access. Both models need matching key properties. Verify their values and types before defining the relationship.
Use a relationship when readers should see two distinct business subjects, such as orders and customers. If the extra columns belong within one model, consider a SQL join in that model instead.
Connect the models
- Open the starting model in Models.
- In its relationships list, select New relationship or the add button.
- Under Relationship to, select the other model.
- Choose the Mapping that describes how many rows match.
- Under Conditions, select the property from each model that should match.
- Select Add Condition when a combined key needs more than one pair.
- Add a description and select the model's Save button.
The mapping is the relationship's cardinality:
| Mapping | Meaning from the starting model |
|---|---|
| One to one | One row matches one row in the other model. |
| One to many | One row can match several rows in the other model. |
| Many to one | Several rows can match one row in the other model. |
| Many to many | Several rows can match several rows in the other model. |
For orders linked to customers, use many to one when each order belongs to one customer.
Match the orders model's customer_id to the customers model's unique customer_id.
O1C1O2C1O3C2C1C2Read the same relationship from customers to orders as one to many.
Verify related fields and row counts
Create an explore from the starting model and add a field from the related model. Check a few known matches. Compare row counts and totals before and after adding the related field. Repeated matches can change a calculation's meaning.
If no fields appear, check that the relationship saved and that you can read the other model. If values are missing, compare the key values and types on both sides.
Add model context when AI needs guidance on when to use the relationship. Keep its Description as a summary of the relationship definition.