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:
- Right click on an entity and select New Column from the popup menu.
Create a column in entity - Enter the name and type of the discriminator.
Enter the name of discriminator column - 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.
Select discriminator column - 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.
To edit ORM class detail - 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 - 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 |