Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 2: IMS DL/I Database


IMS- DL/I Database

DL/I (Data Language/I) is the language IMS programs use to store and retrieve data. Unlike SQL, DL/I does not let you describe what you want in one statement; instead you issue a series of calls that walk a predefined hierarchy. This module explains the hierarchical model behind those calls and the physical database types IMS supports.

The hierarchical model

  • Data is organized as a tree. At the top sits one root segment; below it hang dependent segments, which can have their own dependents, up to 15 levels deep.
  • One root segment plus all of its dependents is a database record. It is always retrieved as a connected tree, never as scattered rows.
  • Each parent can have many children, but each child has exactly one parent. Relationships are fixed when the database is defined, not invented at query time.
  • Example: a STUDENT root has COURSE dependents; each COURSE has GRADE dependents. To find a grade you travel STUDENT to COURSE to GRADE.

Hierarchical vs relational

  • Access path: relational uses SQL and the optimizer chooses the path; hierarchical uses DL/I calls along paths fixed in the DBD.
  • Speed: IMS is extremely fast when the access path is known in advance, because there is no optimizer overhead and no join planning.
  • Flexibility: DB2 answers ad-hoc questions easily; IMS needs a new PCB, a logical database, or program logic for unforeseen access paths.
  • Integrity: the parent-child structure is enforced by IMS itself; a dependent cannot exist without its parent.
  • Use case rule of thumb: fixed, high-volume, predictable transactions favor IMS; exploratory, changing queries favor DB2.

IMS database types (DBD ACCESS=)

  • HSAM (Hierarchical Sequential Access Method): simplest; segments stored in hierarchical sequence, read top to bottom. Batch only, no direct access.
  • HISAM (Hierarchical Indexed Sequential Access Method): HSAM plus an index on the root key, so a root can be fetched directly by key.
  • HDAM (Hierarchical Direct Access Method): root location computed by a randomizing routine from the root key; dependents stored hierarchically after the root.
  • HIDAM (Hierarchical Indexed Direct Access Method): a separate index database maps root key to location; supports both keyed and sequential access. The most common type for online systems.
  • GSAM (Generalized Sequential Access Method): lets a DL/I program read/write plain sequential files (including QSAM/VSAM) with DL/I calls.
  • DEDB / MSDB: Fast Path databases for the most extreme transaction rates; DEDB uses a special area structure.

Physical storage: OSAM and VSAM

  • Under the DBD, segment data lives in OSAM or VSAM data sets. HIDAM/HDAM roots and dependents typically use VSAM ESDS or OSAM.
  • The DBA chooses data set organization at DBDGEN time (the DATASET statement); application programs never see it - they only see segments.
  • Segment size (BYTES=) should fit the control interval comfortably; oversized segments waste space and slow I/O.

How programs see the database: PSB and PCB

  • A program never opens an IMS database directly. It names a PSB (Program Specification Block) at execution time.
  • The PSB contains one or more PCBs. A DB PCB names the database, the processing options (PROCOPT), and the sensitive segments the program may access.
  • A program can only touch segments listed as sensitive in its PCB; anything else is invisible to it. This is both a security and an integrity feature.
  • PSBs are coded with PSBGEN macros. A simple read/write PSB looks like this:
PRINT NOGEN
PCB TYPE=DB,DBDNAME=STUDDBD,PROCOPT=A,KEYLEN=18
SENSEG NAME=STUDENT,PARENT=0
SENSEG NAME=COURSE,PARENT=STUDENT
SENSEG NAME=GRADE,PARENT=COURSE
PSBGEN PSBNAME=STUPSB,LANG=COBOL
END
  • PROCOPT=A means all operations (get, insert, replace, delete). Use PROCOPT=GOT for read-only programs.
  • KEYLEN= is the length of the longest concatenated key the program will use.
  • After PSBGEN, an ACBGEN build makes the PSB usable at execution time.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant