Inheritance (Cont.)


Types
Each class is assigned a type which defines the attributes applicable to the objects.

Substitutability
An object should be substitutable by objects of its subclasses. Thus, the type of the subclass must be a subtype of the type of the superclass in an appropriate sense. A type T' is a subtype of the type T and vice versa T is a supertype of T', if either T = T' or the following conditions apply:
  1. If T is a class, then every subclass T' of T is a subtype of T.
  2. If T is a tuple type, then T' is a subtype of T, if T' is also of tuple type and every attribute in T is defined for T' as well. Moreover, for corresponding attributes the T'-type must be a subtype of the T-type.
  3. If T is a set type, then T' is a subtype of T, if T' is also a set type and the element type of T' is a subtype of the element type of T.
Find all employees who have the same domicile as their drivers.

SELECT a FROM a IN employee
  WHERE a.domicile.location = a.driver.domicile.location;

Late Binding
Substitutability of objects and redefinition of methods requires late binding. Determine all employees whose successindicator > 50.
successindicator ( employee ): INTEGER
successindicator ( manager ): INTEGER

SELECT a FROM a IN employee 
  WHERE a.successindicator > 50;