 |
|
Relational Database Objects and Abstract Data Types
Oracle Database Tips by Donald Burleson
|
Unlike traditional database management system which only provide for
primitive data types such as INTEGER and CHARACTER, the object-oriented
programming languages allow for the creation of abstract data types.
The data types offered in commercial database systems, CHAR INTEGER
NUMBER, VARCHAR, BIT, are sufficient for most relational database
applications but developers are now beginning to realize that the
ability to create user-defined data types can greatly simplify there
database design. While these data types were popular within the
programming languages, they have only recently been introduced into the
mainstream world of database objects.
Some
commercial relations database vendors have committed to incorporating
user-defined data type in their future releases. Oracle, the popular relational
database for midrange computers, has announced that Oracle version 8 will
support abstract data typing by extending SQL to allow for a CREATE TYPE
definition.
At the
most basic level, and abstract data type is nothing more than a collection of
smaller, basic data types that can be treated as a single entity. While this is
a simple concept, the changes in database object design will be dramatic. Some
argue that a database must be able to support data types which contain lists
rather than finite values, and some of the object/relational databases such as
UniSQL allow for a single data type (a column) to contain lists of values, or
even another table.
These
features are called by several names. In the C programming language they are
called structures, in data structure theory they are called abstract data types
(ADT's), while in the marketplace they are referred to as user-defined data
types. Each of these terms mean essentially the same thing, and we can think of
these terms as being interchangeable.
While
pre-relational databases supported primitive ADT's, the more robust data typing
was not introduced until the object/relational hybrid database became popular.
UniSQL, the relational/object-oriented database developed by Dr. Wong Kim,
supports the concept of nested tables, whereby a data "field" in a table may be
a range of values or an entire table. This concept is called complex, or
unstructured data typing. With this approach the domain of values for a
specific field in a relational database may be defined. This ability to "nest"
data tables, allows for relationship data to be incorporated directly into the
table structure. (Figure 5.1) For example, the OCCUPATIONS field in the table
establishes a one-to-many relationship between an employee and their valid
occupations. Also note that the ability to nest the entire SKILLS table within
a single field. In this example, only valid skills may reside in the SKILLS
field, and this implements the relational concept of "domain integrity".
Figure 5.1 An example of embedded complex data
types
Now that see
understand the basic idea behind abstract data types, let's explore some of the
compelling benefits to this approach.