Segments, Records, and Pointers


As described in Chapter 7, "Overview of the IMS Hierarchical Database Model," on page 67, a segment represents one entity or grouping of related fields. In IMS, unlike DB2 or many other DBMSs, you do not have to define all of the fields to IMS. You must only define the segment as being long enough to contain all the application data to be stored. The only fields you must define to IMS are those that you need to use to identify and search for segments. Specifying non-search fields is optional.

In addition to the application data, each segment contains control information that is used by IMS. The control information is placed at the beginning of the segment in a segment prefix. Figure 8-2 shows the layout of a segment with the prefix and application data portions. The prefix is automatically maintained by IMS and is not accessible to the application. The control information in the prefix consists of various flags, descriptive fields (segment type code and delete byte), and pointers to implement the hierarchical structure and access paths. The contents of the prefix will vary, depending on the IMS access method and options chosen when the database is defined.

Figure 8-2. Layout of a Typical Segment

Prefix

Data

Sement Type Code

Delete Byte

RBA Pointer

RBA Pointer

RBA Pointer

Application Data


The RBA pointers in Figure 8-2 consist of the relative offset (number of bytes) of the segment being pointed at, from the start of the data set being used to store the data. This is the relative byte address (RBA). For example, a root segment would contain pointer fields in the prefix for, at a minimum, all of the dependent segment types under the root. IMS will automatically define the minimum set of pointers to maintain the hierarchical structure. The database designer can also specify additional predefined types of pointers, in addition to those necessary for the minimum hierarchical structure. This pointer selection can influence the performance of applications using the databases. Figure 8-3 on page 86 shows database segments with their pointers: physical twin forward (PTF), physical twin backward (PTB), and physical child forward (PCF).

Figure 8-3. Database Segments and Pointers


Physical Segment Design

When designing segments, the physical parameters are important. The following list discusses the details of these physical parameters.

  • Segment length: IMS uses the segment length as it is defined in the DBD to store each segment. If you leave free space at the end of the segment for future use, that space is physically held space on DASD unless you compress the segment. If the application is likely to have additional segment length requirements later, it might be easier to make use of this free space than to increase the segment length later. Balance the cost of making the change to the databases and programs against the cost of wasted DASD space.

  • Number of occurrences per segment per parent: Avoid using long twin chains, which are many occurrences of a particular segment type under one parent. Estimate chain lengths in terms of the number of blocks needed to store each such segment.

  • Location of segments in the hierarchy: Position the segments that are used together most often with the root segment into one control interval or block. The segments are initially physically stored in hierarchical sequence, so the most frequently used segments should be on the left of the structure (low segment codes).

  • Average database record size: The average database record is calculated by the total bytes of all segments under the root segment. Although they might have almost the same number of bytes, small segments with more twins result in better performance and space usage than larger segments with fewer twins.



Introduction to IMS. Your Complete Guide to IBM's Information Management System
An Introduction to IMS: Your Complete Guide to IBMs Information Management System
ISBN: 0131856715
EAN: 2147483647
Year: 2003
Pages: 226

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net