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.