from model to a column on a to model with a cardinality (oneToOne, oneToMany, or manyToOne). Relationships let metric columns aggregate across related records and let queries traverse from one model to another. You define one in code with defineRelationship.
Define a relationship
Wire each side to a model by handle, so both models deploy before the relationship and their uuids are injected automatically:relationships/contact-account.ts
| Field | Role |
|---|---|
from | The referencing side — { model, column }. model is a model handle or modelRef(uuid); column is the slug holding the foreign key. |
to | The referenced side — { model, column }, typically the target’s identifier column (e.g. id). |
relation | Cardinality: oneToOne, oneToMany, or manyToOne. |
from.property / to.property | Optional. Navigate into a JSON (object / array) column value, e.g. "hubspot___companies[0]". Only valid on JSON-typed columns. |
Both models must live in the same dataset — the dataset is derived from
the
from model at deploy. Relationships have no server-side slug, so the
defineRelationship slug is a local identifier only; the deployed
relationship is tracked by its state uuid.From the CLI
Relationships are set per dataset as a JSON array. List the datasets to find thedatasetUuid, then set one or more relationships:
Next steps
Models overview
How relationships fit alongside a model’s columns and segments.
Object models
Link native
Account / Contact / Deal records to each other.Querying data
Join related models with SQL in your warehouse.
Deploying
The reconcile lifecycle that creates and updates relationships.

