First page Back Continue Last page Graphics

Inheritance Example


Notes:

Inheritance Example

The subsequent slides present examples of inheritance demonstrated by a simple table, which contains the data shown in this slide.

To set up inheritance, you first need to determine the discriminator column and the appropriate values. The table in the slide has three distinct values for PERSON_TYPE_CODE: PERS, STAFF, and CUST.

You also need to know which columns are common to the base type and all subtypes. In the example, the PERSON_ID, PERSON_TYPE_CODE, PERSON_ADDRESS, and PERSON_NAME columns have values for all entries. This is because any person should have those attributes.

Next, you determine which columns are specific to each subtype. In the example, SALARY is specific to records with a PERSON_TYPE_CODE of STAFF, whereas CREDIT_LIMIT is specific to the PERSON_TYPE_CODE of CUST. Again, it makes sense to track the salary of employees and the credit limit of customers.

The following slides show how to create an entity object inheritance with a base class of PersonEO, whose discriminator column is PERSON_TYPE_CODE with a value of PERS. There are two subtypes: EmployeeEO, with a PERSON_TYPE_CODE of STAFF, and CustomerEO, with a PERSON_TYPE_CODE of CUST.