Inheritance - Reference Types, Query with Complex Types


Inheritance gives the hierarchical relationships between different objects at different levels and gives code reusability. It is the most important feature of the object database . Inheritance can be at the level of types, or at the level of tables.

Inheritance makes schema definition more natural. Without inheritance of tables. the schema designer has to link tables corresponding to subtables explicitly with tables corresponding to supertables via primary keys, and to define constraints between the tables to ensure referential constraints.

Reference Types

Object-oriented language provides the ability to refer to objects. An attribute of a type can be a reference to an 0bject of a specified type.

In order to initialise a reference attribute, one need to get the identifier of the tuple that is to be referenced. One can get the identifier value of a tuple by means of a query. Thus, to create a tuple with the reference value, one may first create the tuple with a null reference and then set the reference separately.

one where the referenced table must have an attribute that stores the identifier of the tuple. One declares this attribute, called the self-referential attribute by adding a ref is clause to the create table statement.

Query with Complex Types

A complex data type is usually a composite of other existing data types. One might create a complex data type whose components include built-in types, opaque types, distinct types or other complex types.

There are two types of complex data types:

1.    Collection type.

2.    Row Type

An extension of Structured Query Language (SQL) can deal with complex types. It is described in following manner:

1.    Relation-Valued Attributes: Extended SQL allows an expression to appear where a relation name may appear, such as in a FROM clause The ability to use sub-expression makes it possible to take advantage of the stnjcture of nested relation.

2.    Path Expressions: The dot notation for referring to composite attributes can be used with references. For example,

create table phd-students

(advisor ref(people))

under people

To get the names of the advisors of all Phd students, query is:

Select phd-students.advisor.name

From phd-students

An expression of the form "phd-students.advisor" is called a path expression. References can be used to hide join operations and thus the use of references simplifies the query considerably.

3.    Nesting and Unnesting: The transformation of a nested relation into INF is called unnesting. The doc relation have two attributes author list and keyword-list, which are nested relations.