next up previous
Next: Reference Types Up: Complex Types and Object Previous: Structured and collection types

Inheritance

  1. Inheritance can be at the level of types or at the level of tables.
  2. Inheritance of types.

     
    		 create type Person
    

    (name MyString,

    social-security integer) [5pt] create type Student

    (degree MyString,

    department MyString)

    under Person

    create type Teacher

    (salary integer,

    department MyString)

    under Person

  3. Multiple inheritance: Since name and social-security are inherited from a common source Person, there is no conflict by inheriting them from Student as well as Teacher. However, department is defined separately in Student and Teacher, and one can rename them to avoid a conflict.

     
    		 create type TeachingAssistant
    

    under Student with (department as student-dept),

    under Teacher with (department as teacher-dept)

  4. Inheritance of tables:

    To avoid creation of too many subtypes, one approach in the context of database systems is to allow an object to have multiple types without having a most specific type.

    Object-relational systems can model such a feature by using inheritance at the level of tables, rather than types, and allowing an entity to exist in more than one table at once.

     
    		 create table people
    

    (name MyString,

    social-security integer) [5pt] create table students

    (degree MyString,

    department MyString)

    under people

    create table teachers

    (salary integer,

    department MyString)

    under people

  5. There are consistency requirements on subtables and supertables.
  6. Subtables can be stored in an efficient manner without replication of all inherited fields. Inherited attributes other than the primary key of the supertables can be derived by means of a join with the supertable, based on the primary key.
  7. Multiple inheritance is possible with tables. A teaching-assistant can simply belong to the table students as well as to the table teacher. However, if we want, we can create a table for teaching-assistant entities as follows:

     
    		 create type TeachingAssistant
    

    under Student with (department as student-dept),

    under Teacher with (department as student-dept)

    Based on the consistency requirements for subtables, if an entity is present in the teaching-assistant table, it is also present in the teachers and in the students table.

  8. Inheritance makes schema definition natural, ensures referential and cardinality constraints, enables the use of functions defined for supertypes on object belonging to subtypes, and allows the orderly extension of a database system to incorporate new types.

next up previous
Next: Reference Types Up: Complex Types and Object Previous: Structured and collection types

Osmar Zaiane
Tue Jul 7 15:03:55 PDT 1998