HPlogo Up and Running with ALLBASE/SQL: HP 3000 and HP 9000 Computer Systems > Chapter 7 Comparing ALLBASE/SQL with TurboIMAGE

Tables and Indexes versus Data Sets

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The basic unit of storage for data items in TurboIMAGE is the data set, which consists of a set of records containing an ordered series of data items. A data set is either a detail or a master, and, if it is a master, it is either manual or automatic.

In ALLBASE/SQL, the basic unit of storage is the table, which is an unordered set of rows containing data items. Tables are not labeled manual or automatic, master or detail; but the same relationships are possible through the creation of different types of indexes or index-like structures.

Automatic Masters versus Indexes

Each TurboIMAGE automatic master data set has a unique key item, which provides calculated access to the data in the master, and chained access to the data in one or more detail data sets. Like an ALLBASE/SQL index, an automatic master is maintained by the system; that is, when the table or detail data set is updated, the index or automatic master is updated automatically. Also, you cannot have an index without a table, and you cannot have an automatic master without a detail data set. Both indexes and automatic masters contain only key data values.

One difference between the automatic master and the index is that an automatic master may serve up to 16 detail data sets, whereas an index serves only one key within one table. However, separate indexes can be created on similar keys in other tables, and many indexes may exist on the same table. Another difference is that ALLBASE/SQL indexes use a B-tree structure, whereas TurboIMAGE master data sets use calculated (hash) access to key values.

Manual Masters versus Hash Structures

Each TurboIMAGE manual master data set has a unique primary key item, which provides calculated access to the data in the master, and chained access to the data in the detail data set (if one exists). A manual master may contain data items other than just the key item; therefore, it cannot be automatically updated when detail data changes.

When you create an ALLBASE/SQL table as a hash structure, it behaves like a manual master data set, in that it has a unique primary key with calculated access to the key value. Like manual masters, hash structures have the advantage of speed when the key value is known exactly, but are less efficient than normal indexes when a range of values is required.

Master/Detail versus Referential Integrity

The TurboIMAGE manual master provides the following methods for enforcing data integrity:

  • Insisting that key values entered into the detail data set already exist in the manual master.

  • Preventing deletions of key values in the manual master without prior deletion of the same key values in the detail data set.

In ALLBASE/SQL, you can achieve the same end by creating a table with a referential constraint and specifying the following clause:

   HASH ON CONSTRAINT

This causes a unique hash key in the table (that is, the referenced or master table) to be related to a foreign key in another table (that is, the referencing or detail table).

Sort Items versus Indexes

In TurboIMAGE, you can specify sort items that become the basis for the sorted order of the output in queries to the database. You cannot use the search item as a sort item, however, because the search item points to a chain of entries whose order is fixed, and this order is not necessarily the same as the sort order.

In ALLBASE/SQL, you can use the ORDER BY clause in the SELECT statement to sort by any column you wish. ALLBASE/SQL tables are essentially unordered sets of rows, so they can be accessed in any order. Sorting is improved markedly, however, by the use of an index on the sort key. Note that the sort key can be and often is the same as the primary key in the table.

Feedback to webmaster