What are relations?

Robert van Boesschoten

Published: 20-08-2019

Last updated: 27-08-2020


Models can be related to one another with relations. These relations are used when something needs to be stored in a different model. For instance, when a customer needs to have multiple addresses a new model called address can be created. The models can call out to each other through a relation. Betty Blocks uses 3 different kinds of relations:

1. Has many
2. Belongs to
3. Has and belongs to many

More about these different kinds of relations can be found in this article:  Relations Reference.

HowTo create model relations?

  1. Go to the Datamodel by clicking on the Datamodel tab on the Builder Bar.
  2. Hover over the model which you would like to connect with another model.
  3. When hovering over the sides of that model an arrow will appear on that side. Drag and drop the arrow to another model.
  4. The model relation settings will appear. In this modal, you can select which of the 3 relation types you want to use on your model. More about relation types can be found here: What are the three relation types?
  5. Click on the Save button of the relation type that you want to use and the relation will be created.

Relations can also be created via the model settings:

  1. Go to the Datamodel by clicking on the Datamodel tab on the Builder Bar.
  2. Click on a model, the model settings will slide in from the right side of the screen.
  3. Click on the subview Relations within the model settings.
  4. Create a new relation for that model by clicking on the New button on the left side of the header.
  5. The relation form will appear. Within this form, you can enter which type of relation you want to use, which model you want to connect with and the name and label for your relation.
  6. Click on the Save button on the top right of the screen and your relation will be created.

Every model relation is shown in both models. Example: If you’ve created a relation that one Customer holds multiple Invoices, you will now see Customer in the Invoice model and Invoices in the Customer model. 


Not sure where to start?

Click here to register and start learning