This article discusses IMS database organization, access methods, secondary indexes, and logical relationships. It covers the following topics:
Hierarchic Sequential Databases
Hierarchic Direct Databases
Fast Path Databases
The Role of Secondary Indexes
The Role of Logical Relationships
When you create an IMS database, you tell IMS what the physical structure of the database will be-the segment names, segment lengths, the fields that each segment will contain, the segment's position in the hierarchy, and so on. You also tell IMS what segments can be accessed, whether they can be updated, deleted, or new ones inserted, and other access control specifications. You do this through a series of specifications that will be contained in control blocks, also called DL/I control blocks, because the DL/I command language is used perform the data manipulation functions. Control blocks do just what the name implies-they control the way in which IMS will structure and access the data stored in the database.
The data structure and control specifications you write will be contained in three major control blocks:
DBD, which describes the database organization and access methods
PSB, which describes an application program's view and use of the database
ACB, which combines information from the DBD and PSB
A database description (DBD) is a series of macro statements that define the type of database, all segments and fields, and any logical relationships or indexing. DBD macro statements are submitted to the DBDGEN utility, which generates a DBD control block and stores it in the IMS.DBDLIB library for use when an application program accesses the database.
Figure 2-1 shows a sample DBD for an HDAM database. When the DBD is assembled and link-edited, a load module is created and stored in an IMS DBDLIB library. In the DBDGEN process, each segment is assigned a segment code, a one-byte value in ascending sequence, that is used to identify the segment in physical storage.
In the DBD statement, an IMS access method and a system access method are specified (HDAM, OSAM in this example). The roles of the two access methods are discussed in greater detail in "Access Methods."
Fields within each segment can be defined as key fields or non-key search fields for use by application programs in retrieving segments. A key field is used for searching and sequencing. Each segment occurrence will be placed in a database record according to the sequence of the key fields. In Figure 2-1, the statement for field COLLID (college ID) is defined as a sequence field (SEQ) and as unique (U). Only fields that will be used in SSAs or that are key fields must be defined in the DBD.
Program Specification Block
The program specification block (PSB) is a series of macro statements that describe the data access characteristics of an application program. Among other things, the PSB specifies:
all databases that the application program will access
which segments in the database that the application program is sensitive to
how the application program can use the segments (inquiry or update)
A PSB consists of one or more program communication blocks (PCBs). The PCB specifies the segments to which the application program can have access and the processing authorization for each segment. You define a PCB for each database (or each view of the database) accessed by the application program. In the application program host code, you specify the PSB for that application.
For each PCB, you must code a corresponding block in the application program's linkage section. These data communication I/O areas are used for communication between IMS and the application. (There are actually two types of PCBs, a database PCB and a data communications PCB.)
PCBs contain SENSEG (sensitive segment) and SENFLD (sensitive field) statements. These statements allow you to specify which segments and fields the application program will "see." If you define a segment as sensitive, it will be accessible to the application. If you do not, it will be ignored by the application program. This gives you great flexibility in creating the views that application programs will have of your database.
The PSB macros are used as input to the PSBGEN utility, a macro assembler that generates a PSB control block. The PSB control block is stored in the IMS.PSBLIB library for use during database processing. There can be many PSBs for one DBD.
Figure 2-2 shows the structure of PSB generation input.