Table Of Contents
External Data Types
What is an external data type?
External data type declaration
Variations of the external data type declaration
Conclusion
External Data Types
This chapter describes external data types and provides a list of the externally defined data types used in the databases of MWFM NMOS
What is an external data type?
An external data type is any data type that is not reconsider as a valid OQL data type and hence must be defined elsewhere within the database schema or in another previously loaded schema. It is important that you define any external data type and load the schema configuration file before you make any reference to the data type or an error will be generated. External data types are generally used as integer or text representations of a complex combination of other data types. This implies that you can define any unique data type in any database schema, provided it is founded on the valid basic OQL data types.
An example of an external data type is shown in Table 21-1.
.
Table 21-1 Definition of a new example deviceCode external data type
Definition
|
deviceCode value
|
router
|
1
|
switch
|
2
|
bridge
|
3
|
hub
|
4
|
If, for example, you wish to create a new integer data type called deviceCode to represent different types of devices with the translations shown by the above table, the following entry into the configuration file for the database schema would define the new data type
// This entry assumes that the translations database does not
// exist. if it does then there is no need to create the
// translations database.
create database translations;
// create the table which stores the data type translations
create table translations.deviceCode
(
deviceCode integer not null primary key,
deviceText char not null primary key,
unique(deviceCode)
);
// populate the table with the device codes and their
// translations
insert into translations.deviceCode
(deviceCode, deviceText)
values
(1, "router");
insert into translations.deviceCode values (2, "switch");
insert into translations.deviceCode values (3, "bridge");
insert into translations.deviceCode values (4, "hub");
|
:
External data type declaration
You must declare externally defined data types in the database configuration files before the database tables that use them are created. In order to do this you must use the OQL datatype and is external data type declaration as shown below for the new deviceCode data type created in the above example.
datatype deviceCode is external deviceCode
|
Variations of the external data type declaration
In the proceeding example a new data type called deviceCode was created and declared but there may be an instance where you want to create a new external data type deviceType but with identical translations to the deviceCode data type. In such an instance you would simple declare the deviceType data type but with a reference to the deviceCode data type as shown below:
datatype deviceType is external deviceCode
|
You should refer to the OQL tutorial and syntax definition in "The OQL Language," for the basic syntax of the datatype and is external external data type declaration.
Conclusion
This chapter outlined how to create and declare external data types. It also previewed the OQL syntax which is detailed in Chapter 28.
The next chapter details the database structure used by the MWFM NMOS component CLASS.