Using Discriminator Column

In a generalization hierarchy, the superclass distributes its commonalities to its subclasses. The subclasses inherit all superclass' attributes and may contain their own attributes. Visual Paradigm combines the entities within the hierarchy into one single entity that contains all the attributes, plus an additional discriminator column, which contains a unique value that can be used for identifying the entity in which a record belongs to. Discriminator column is used when "table per class" is chosen as inheritance strategy. In order to make discriminator works, you need to define the discriminator in the entity and the discriminator values in the object model.

Adding the discriminator column for entity

You can add a column to an entity as the discriminator column. To add a discriminator column:

  1. Right click on an entity and select New Column from the popup menu.
    Create a column in entity
    Create a column in entity
  2. Enter the name and type of the discriminator.
    Enter the name of discriminator column
    Enter the name of discriminator column
  3. Right click on the entity and select Open Specification... from the popup menu.
  4. Select the column just created from the Discriminator Column drop-down menu.
    Select discriminator column
    Select discriminator column
  5. Click OK.

Defining Discriminator Value for Class

You can specify the discriminator value for each sub-class.

  1. Right click on each of the corresponding sub-classes for adding discriminator. Select ORM > ORM Class Detail... from the popup menu.
    To edit ORM class detail
    To edit ORM class detail
  2. In the Class Specification window, enter the discriminator value that represent the sub-class. This value will be stored in the corresponding database record under the discriminator column.
    Enter discriminator value
    Enter discriminator value
  3. Click OK to confirm the change.

Related Resources

The following resources may help you to learn more about the topic discussed in this page.

 
13. Different Inheritance Strategies Table of Contents 15. Using Array Table

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.OK