Getting Started as an MPE/iX Programmer Programmer's Guide: HP 3000 Computer MPE/iX Computer Systems > Chapter 7 Data ManagementTurboIMAGE/XL and QUERY/V |
|
Together, TurboIMAGE/XL and QUERY/V provide a database management system. TurboIMAGE/XL is a set of programs and procedures you can use to define, create, access, and maintain a database. QUERY/V is a database inquiry facility that provides a simple method of accessing a TurboIMAGE/XL database without requiring programming. You can use QUERY/V interactively. TurboIMAGE/XL components are:
You can use DBSCHEMA to create a root file containing the structural definition of a database by using a schema. A schema analyzes data and formalizes data relationships. The schema is a summary of all the data relationships in a data base and stored as a separate text file. The format used in a schema is TurboIMAGE/XL's database description language. You can enter schema information in an MPE/iX text file, following the database description language format. Schema information includes:
Once you have created a schema in an MPE/iX text file, you can use the schema processor, DBSCHEMA, to create a root file and store in it an internal description of the database, based on the schema in the text file. The root file is part of a database and contains all the database structural information required by TurboIMAGE/XL and QUERY/V. The syntax for the command to run the schema processor is:
where:
Figure 7-5 “Example of Creating a Root File” shows an example of creating a root file. In this case, both DBSTEXT and DBSLIST are equated to actual file designators: DBSTEXT is an existing MPE/iX text file and DBSLIST is the line printer. DBUTIL is a TurboIMAGE/XL subprogram that has many capabilities. You can use it to:
You must be the creator of the database or know its maintenance word to use the DBUTIL commands PURGE and ERASE. The maintenance word is an optional ASCII string that you can specify with the DBUTIL commands CREATE or SET. It defines a password to use for executing DBUTIL commands, such as PURGE and ERASE, and to operate other database procedures. If no maintenance word is defined, then only the database creator can operate them. The DBUTIL command PURGE purges the root file and all of the data sets in the database. (You cannot use the MPE/iX command :PURGE to purge a root file, detail set, or master set. TurboIMAGE/XL has a transaction logging and recovery system with the capability of recovering a database from a transaction-oriented log file in the event of a system failure. DBUTIL allows you to enable or disable these options. Once you have created a root file, you can use DBUTIL to create the database described in the root file. To create the database, you must be logged onto the system with the same log-on used to create the root file. DBUTIL creates data sets according to the specifications in the internal description of the schema. When created, data sets are initialized to zero and contain no data. Figure 7-5 “Example of Creating a Root File” shows an example of creating a database. In this case, the manual master set, CUSTOMER, has a primary key item named ACCOUNT pointing to the detail set SALES. The automatic master set, DATE-MASTER, has a primary key item named DATE that also points to the detail set SALES. TurboIMAGE/XL procedures are a set of library routines that allow you to load, access, and manipulate data in the database. You can call them from HP C/iX, COBOL II/XL, HP FORTRAN 77/iX, and HP Pascal/iX application programs. You must be the creator of the database or know its database password word to use TurboIMAGE/XL procedures. (The database password is an optional ASCII string that you can specify with the DBUTIL commands CREATE or SET. It defines a password to use for executing TurboIMAGE/XL procedures and DBUTIL commands, such as as PURGE and ERASE. If no database password is defined, then only the database creator can operate them.) The database creator can use a semicolon (;) as a database password to bypass all internal database security. You need not be logged onto the same group and account that contains the database root file and the data sets. You can perform these procedures on a remote database. TurboIMAGE/XL procedures are in the following categories:
TurboIMAGE/XL subprograms are used for storing and loading. You must be the creator or know the maintenance password to use them and you must be logged onto the account and group where the database resides. The subprograms are:
DBSTORE and DBRESTOR copy a database to and from magnetic tape or serial disc. They copy the entire database, including the root file. You can use DBUNLOAD and DBLOAD to assist in restructuring a database, but they copy only data, not the root file or the data set structures. You can change the design of an existing database without writing special programs to transfer data from the old one to the new one. To restructure a database, follow these steps:
For detailed information on the types of design changes you can make using this method, refer to TurboIMAGE/XL Reference Manual (30391-90050). TurboIMAGE/XL is designed to maintain the integrity of its data bases. However, it is possible that data or structural information can be lost during a hardware failure or an operating system crash. It is highly recommended that you regularly backup a database. You can maintain the database by copying it to magnetic tape using DBSTORE at regular intervals. If necessary, you can restore the database using DBRESTOR. This restores the database to its state at the time it was last stored. You can use this method more often than system backups are done to maintain recent copies of the database and minimize the number of transactions that may be lost. To recover changes made after the last backup, you must do one of the following:
You can execute the transaction logging and recovery system to return a database to a state near that at the time of system failure. The logging system provides a mechanism to log database transactions to a logfile on magnetic tape or disc. If you must restore the database, first restore the backup data base copy and then run the recovery program, DBRECOV. This re-enters transactions from the log file against the data base. It also allows you to create individual user recovery files, providing information to users that enables them to figure out where to resume transactions. The database administrator is responsible for enabling and disabling the logging and recovery processes and generating backup database copies. This makes logging a global function controlled at the database level, rather than at the individual user level. |