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:
- Right click on an entity and select New Column from the popup menu.
- Enter the name and type of the discriminator.
- Right click on the entity and select Open Specification… from the popup menu.
- Select the column just created from the Discriminator Column drop-down menu.
- Click OK.
Defining Discriminator Value for Class
You can specify the discriminator value for each sub-class.
- Right click on each of the corresponding sub-classes for adding discriminator. Select ORM > ORM Class Detail… from the popup menu.
- 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.
- Click OK to confirm the change.