Mainframe Path Start learning free
Core11 min readLesson 2 of 4

Hierarchical data: segments, DBDs and PSBs

An IMS database is a tree. Each record starts with a root segment, with child segments hanging beneath it. The DBD describes the tree; a PSB describes which parts a particular program may see and how it may use them.

Segments instead of rows

Where DB2 stores rows in tables and joins them, IMS stores segments in a fixed parent-child structure. One database record is a root segment plus all its dependents.

One customer database record
CUSTOMERroot segment: one per customer
ACCOUNTchild of CUSTOMER: one per account
TRANSACTchild of ACCOUNT: one per transaction
ADDRESSanother child of CUSTOMER

The DBD: what the database looks like

A DBD (database description) defines the segments, their fields, which fields are keys, and how the database is stored. It is generated by a DBA with the DBDGEN utility.

Access methodIn short
HDAM / PHDAMRoot segments found by hashing the key; fast direct access
HIDAM / PHIDAMRoot segments found through an index; supports sequential processing by key
HISAMIndexed sequential; mostly older or special-purpose databases
DEDBFast Path data entry database for very high volume and availability

The 'P' versions are HALDB (High Availability Large Database), which split a large database into partitions that can be reorganised and recovered separately.

The PSB: what a program may see

A program does not see the whole database. Its PSB (program specification block) contains one PCB per database it uses, listing the sensitive segments (SENSEG) it can access and a processing option (PROCOPT) such as G (get), I (insert), R (replace), D (delete) or A (all).

A PCB in a PSB (simplified)
PCB    TYPE=DB,DBDNAME=CUSTDB,PROCOPT=G,KEYLEN=20
SENSEG NAME=CUSTOMER,PARENT=0
SENSEG NAME=ACCOUNT,PARENT=CUSTOMER
PSBGEN LANG=COBOL,PSBNAME=CUSTINQ

This read-only program can see customers and accounts but not transactions or addresses. Online programs also receive an I/O PCB for exchanging messages with the terminal or client. Before use, DBDs and PSBs are combined into application control blocks (ACBs).

Common mistakes

Thinking in SQL joins

IMS paths are fixed by the DBD. To reach TRANSACT you go through CUSTOMER and ACCOUNT. Design and read programs along the hierarchy.

Forgetting the PSB limits what you see

If a segment is not a SENSEG in your PCB, it simply does not exist for your program.

Changing a DBD without the ACB and PSB steps

Database structure changes need DBDGEN, related PSBGENs and an ACB generation, coordinated by the DBA.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← What IMS is and where it runsDL/I calls from COBOL →