Switchboard Docs
Context layer

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

  1. Open the starting model in Models.
  2. In its relationships list, select New relationship or the add button.
  3. Under Relationship to, select the other model.
  4. Choose the Mapping that describes how many rows match.
  5. Under Conditions, select the property from each model that should match.
  6. Select Add Condition when a combined key needs more than one pair.
  7. Add a description and select the model's Save button.

The mapping is the relationship's cardinality:

MappingMeaning from the starting model
One to oneOne row matches one row in the other model.
One to manyOne row can match several rows in the other model.
Many to oneSeveral rows can match one row in the other model.
Many to manySeveral 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.

One relationship, two directions
Orders
Order IDCustomer ID
O1C1
O2C1
O3C2
Customers
Customer ID
C1
C2
Start with OrdersMany to one
Start with CustomersOne to many
Illustrative keys. Orders O1 and O2 match customer C1; O3 matches C2. The matching property is customer_id.

Read the same relationship from customers to orders as one to many.

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.

On this page