Create relationship between entities using unique index

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:

Original ERD

Original ERD

  1. Right click on the Cities entity and select Open Specification.

    Open Specification for Cities entity

    Open Specification for Cities entity

  2. Select the Indices tab and press Add at the bottom of the dialog.

    Switch to Indices tab to add an index

    Switch to Indices tab to add an index

  3. Select the name column under All column list, and press the right arrow button to move it to Selected.

    Select the name column to be included in the index

    Select the name column to be included in the index

  4. Select Unique at the bottom of the dialog and press OK to confirm.

    Specify the index as unique type

    Specify the index as unique type

  5. Press OK to close the Entity Specification.
  6. Select the Cities entity and drag out the Resource Catalog icon, drop it over the Customer.

    Drag out resource icon from Cities and drop it to Customer

    Drag out resource icon from Cities and drop it to Customer

  7. Select One-to-Many Relationship from the popup to create one-to-many relationship from Cities to Customer.

    Specify the relationship type as one-to-many

    Specify the relationship type as one-to-many

  8. Right click on the relationship and select Open Specification.

    Open specification dialog of the relationship

    Open specification dialog of the relationship

  9. Switch to Foreign Key Column Mapping tab, and make sure the Reference combo box is selected the unique index defined on Cities.

    Specify the foreign key is reference to the index

    Specify the foreign key is reference to the index

  10. Change the Foreign Key column of the Customer entity from Generate Default Column to the city Press OK to confirm.

    Specify the city column as the foreign key

    Specify the city column as the foreign key

Now your Customer is reference to the Cities on the unique index instead of the primary key.

Relationship is created by reference to the index column

Relationship is created by reference to the index column

Related Know-how

Related Link

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply