The unique index of an entity guarantees the record to be covered by index key containing no duplicated value, which helps to improve the performance of the database on accessing the data. The unique index is similar to primary key where the only difference is an entity can only have one primary key, but it can multiple unique indices in different column of an entity. In Visual Paradigm you can establish relationship between entities using both primary key and unique index. We will show you how to create relationship between entities using unique index in this article.
Suppose we would like to create a relationship from Cities.name to Customer.city:
- Right click on the Cities entity and select Open Specification.
- Select the Indices tab and press Add at the bottom of the dialog.
- Select the name column under All column list, and press the right arrow button to move it to Selected.
- Select Unique at the bottom of the dialog and press OK to confirm.
- Press OK to close the Entity Specification.
- Select the Cities entity and drag out the Resource Catalog icon, drop it over the Customer.
- Select One-to-Many Relationship from the popup to create one-to-many relationship from Cities to Customer.
- Right click on the relationship and select Open Specification.
- Switch to Foreign Key Column Mapping tab, and make sure the Reference combo box is selected the unique index defined on Cities.
- Change the Foreign Key column of the Customer entity from Generate Default Column to the city Press OK to confirm.
Now your Customer is reference to the Cities on the unique index instead of the primary key.