Back to articles list
- 2 minutes read

Tip #9 – How to create multiple references between two tables

Relationships in the real world may not be as easy as we would like them to be. Sometimes we want to model a situation where one table is refering to the other more than once. Luckily, with Vertabelo, this is a piece of cake.

Let’s say we want to model a rental agreement between two people: landlord and tenant. In this situation, the rental_agreement table would need to refer to the person table twice – first for the landlord and second for the tenant. Your initial model could look as follows:

Now, switch to reference in the toolbox and put a line from the person table to the rental_agreement table:

Your first reference is created:

Note that the foreign key here is autogenerated. If you disabled this option in account settings, you would have to add a new foreign key column in the rental_agreement table manually.

Adding the second reference looks exactly the same as adding the first one – just put another line from the person table to the rental_agreement:

Now, we’ve got multiple references between two tables:

Finally, we need to polish our model a little bit.

We begin by changing FK column names:

Now, the names are more descriptive and thus clearer:

Let’s select the first reference and take a look at the Reference properties panel:

We’re renaming the reference. Moreover, for documentation purposes, we’re adding role names to each side of the reference:

We’ll do exactly the same thing for the second reference:

Now, our database model is ready to handle rental agreements.

go to top