Table per concrete type

The Table Per Concrete (TPC) Type inheritance is an inheritance that is used when the database contains two or more tables with sets of identical columns.

For example, suppose that in the database we have the TPC_Horse and TPC_Dog tables. Both these tables contain the following identical columns: BirthDate and Genus.

Within the Database First approach, used for the purpose of this example, first, we move the TPC_Horse and TPC_Dog tables onto the design surface to create classes with the same respective names:

Sample tables on the diagram

Next, we move identical properties (ID, BirthDate and Genus) from one of the classes onto the diagram surface.

This displays the following dialog box:

Refine a model

In the dialog box above, we select New base class and enter a name for the abstract class, for example, TPCBaseEntity, and click OK.

Open the Inheritance Editor dialog box for the created inheritance and select Table Per Concrete Type in the Type combo-box:

Edit the inheritance

At this stage, a TPC inheritance is created between the class, from which we moved the identical properties and the TPCBaseEntity class. The model looks as follows:

Created TPC inheritance

In the Properties window of the TPCBaseEntity class, we set Abstract to True.

Now we shall move the identical properties from the other class onto the diagram surface. The Model Refactoring dialog box is displayed again with the following selection:

Select an action to perform with the object

If the automatic selection of the parameters is different, it will be necessary to select the Existing base class and select the TPCBaseEntity class from the corresponding dropdown list.

When we click OK in the dialog box, we get the final version of the model with correctly set inheritances:

The model with configured inheritances

See also

Overview

Table per hierarchy

Table per type