Chapter 12. Subtyping and Inheritance

Table of Contents
1. Introducing Subtypes by Specialization
2. Introducing Supertypes by Generalization
3. Intension versus Extension
4. Type Hierarchies
5. Kinds and Roles
6. The Class Hierarchy Merge Design Pattern
7. Subtyping and Inheritance in Computational Languages
7.1. Subtyping and inheritance in OOP
7.2. Subtyping and inheritance with XML Schema
7.3. Subtyping and inheritance with OWL
7.4. Representing class hierarchies with SQL database tables
7.4.1. Single Table Inheritance
7.4.2. Table per Class Inheritance
7.4.3. Joined Tables Inheritance
8. Quiz Questions
8.1. Question 1: Statements about a Class Hierarchy
8.2. Question 2: Class Hierarchy Merge

The concept of a subtype, or subclass, is a fundamental concept in natural language, mathematics, and informatics. For instance, in English, we say that a bird is an animal, or the class of all birds is a subclass of the class of all animals. In linguistics, the noun "bird" is a hyponym of the noun "animal".

An object type may be specialized by subtypes (for instance, Bird is specialized by Parrot) or generalized by supertypes (for instance, Bird and Mammal are generalized by Animal). Specialization and generalization are two sides of the same coin.

A subtype inherits all features from its supertypes. When a subtype inherits attributes, associations and constraints from a supertype, this means that these features need not be repeatedly rendered for the subtype in the class diagram, but the reader of the diagram has to understand that all features of a supertype also apply to its subtypes.

When an object type has more than one direct supertype, we have a case of multiple inheritance, which is common in conceptual modeling, but prohibited in many object-oriented programming languages, such as Java and C#, which only allow class hierarchies with a unique direct supertype for each object type.