Connecting your models

Find out how to connect your models together to form the relations between them.

Updated over a week ago

After reading this article you’ll know how to:

  • Use the schema view

  • Form the connections between models

After you’ve created your models and added properties to them, in most use cases it’s essential to connect them together. Within the Betty Blocks platform, you are going to use the schema view to observe and build relations between the existing models within the data model in your application.

Let’s open our data model section. As you can see, there are 4 models over here:

  • Project

  • Role

  • Task

  • User

The ‘Role’ and ‘User’ models are created by default in your application, and the ‘Project’ and ‘Task’ models were added for this use case example.

Go to the schema overview.

Note: Sometimes it might happen: when getting to the schema view, you may notice only one model on the canvas. It happens because they might get overlaid. The solution is very simple: just drag them around.

To make sure models work together, we need to define their relations. You can create a relation by hovering over the model. Wait until the arrow pops out. Drag an arrow onto another model to create the relation between them.

First, let’s connect the ‘Project’ and ‘Task’ models. Drag the arrow from the ‘Project’ model onto the ‘Task’. In the pop-up window, you’ll see the relation type selector. It will help you choose the right kind of connection between the models. In this case, we need to define that one project might have many tasks.

Another relation we are going to create is between the ‘User’ and ‘Project’ models. User will have their own project(s). Hover over the ‘User’ model and drag an arrow to the ‘Project’ model. Then choose the option ‘Has many’, so that one user is able to have one or more projects.

Lastly, we can delete the newly created connection by clicking on the line between the ‘User’ and ‘Project’ models. In the slide-out menu on the right, choose the ‘Delete’ option.

Note: Be aware that deleting the relations between models might be dangerous because it might ruin the workflow in your application.

If you want to learn more about schema view and working with it, check out these articles:

Did this answer your question?