1. Home
  2. Docs
  3. Chapter 14. Database Design & Engineering
  4. 2. Database Designer’s Guide
  5. Using discriminator column

Using discriminator column

Download PDF

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
  2. Enter the name and type of the discriminator.
    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
  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
  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
  3. Click OK to confirm the change.