What is a relation?

A relation is a definition of how two objects relate to one another (i.e. the definition of how the two tables will be joined together in a query).

Relations can be one of three types:

  • one-to-one
  • one-to-many
  • many-to-many

For one-to-one and one-to-many relations, the two object definitions are related directly through a primary key and foreign key relationship. For example, you may have a users table where each user has made one or many posts. In this case, you’d create a one-to-many relation where the id property of the users table matches with the user_id property on posts.

For many-to-many relations, a dataset is required to be used as the join table for the relation.

All relations are bidirectional, meaning that you only need to create one relation between objects. This relation can then be used in both directions (e.g., start a pipeline at the users object and relate to that user’s company, or start at the companies table and relate users).

Creating a relation

To create a relation, your ontology must first contain the two blueprints that will be related. If you’re looking to create a many-to-many relation, you will also need a dataset to use as the join table for the relation. If these requirements are satisfied, create a relation via the following steps:

  • On the Ontology page, visit the Relations tab and press New Relation
  • Choose which type of relation is being modeled (one-to-many, etc.)
  • Designate the property on each table that will be used as the join keys in the relation
  • Add in a name, API name, and optional description about the each object used in the relation and hit Submit