24 Database Modeling Tips for Vertabelo

Tip #23 – How to create a reference to an alternate key

Vertabelo Team

Posted: December 23, 2015

Sometimes, you want the reference between two tables to reference an alternate key and not the primary key. Here's how you can do it in Vertabelo.

In this example, we want to model cars and their owners using owner and car tables.

The car table has an alternate key consisting of the vin column:

We want the owner table to refer to the car table, but using the car table’s alternate key. Let’s start with a typical reference by switching to a reference in the toolbox and putting a line from the car table to the owner table:

Now, we have a reference using the car table’s primary key. Our current goal is to switch it to the alternate key.

Let’s change reference properties. Delete the id and car_id column pair from the reference:

Then add a new one – between the vin and car_id columns:

Finally, rename the car_id column in the owner table to car_vin and change its type to char(17), just like in the original vin column:

Now, our reference is using an alternate key.


Try our online database modeler. No registration. No commitments.

Subscribe to our newsletter

If you find this article useful, join our weekly newsletter to be notified about the latest posts.

It's Time to Master Python Gain practical knowledge of Python or prepare for a coding interview. Let's Do This Other Python courses: