24 Database Modeling Tips for Vertabelo

Tip #4 – How to Make a Column Unique

by
Vertabelo Team

Posted: December 4, 2015

Sometimes there are columns in a table that don’t belong to primary key, but are still unique. To mark them as a unique, you have to create an alternate (unique) key containing it.

Single-column alternate (unique) key

Select the table with the column you want to make a unique. Then, click the Alternate (unique) key tab in the Table properties panel on the right:

Select the table containing the column you want to make a unique. Then, expand the ‘Alternate (unique) key’ section in the ‘Table properties’ panel on the right

Click Add key:

Click 'Add key', alternate key

Click the down arrow to show the properties:

Click the down arrow to show the properties, alternate key

Find the column you want to make a unique and add it to the key:

Find the right column and add it to the key, unique column

Now, the column is unique:

Now, the column is set as unique, unique column

You can check the table code by clicking the SQL preview button in the top right corner:

You can see your unique key in the SQL code preview

Multicolumn alternate (unique) key

Your unique key may have more than one column. To create a multicolumn one, select the table, expand the Alternate (unique) key section on the right, and click Add key:

To create a multicolumn unique key, select the table, expand the ‘Alternate (unique) key’ section on the right, and then click ‘Add key’

Add all columns you want to include in your key:

Add all columns you want to include in your unique key

Your multicolumn alternate (unique) key is ready (as seen on the SQL code preview):

Your multicolumn alternate (unique) key is ready

Setting an index as unique

You can make an index unique too. Just go to your index:

Expand the properties of the index you want to make unique

Click Set next to the Unique field:

Click ‘Set’ next to the ‘Unique’ field

And set it to Yes:

Make sure that the ‘Unique’ field is set to ‘Yes’

The SQL preview of your unique index looks as follows:

The SQL preview of your unique index

 
 
 
 

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

 
 
Tags
 
Subscribe to our newsletter

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

 
 
 
 
 
 
 
New SQL Course! Learn how to process trees and graphs in SQL, and how to effectively organize long SQL queries. View course Discover our other courses: