Exercises — Chapter 31: IMS/DB Basics
Exercise 31.1: Understanding Hierarchical Structures (Conceptual)
A university wants to model its data in IMS. The hierarchy is:
UNIVERSITY (root)
├── DEPARTMENT
│ ├── PROFESSOR
│ │ └── PUBLICATION
│ └── COURSE
│ └── SECTION
│ └── ENROLLMENT
└── BUILDING
└── ROOM
Tasks: 1. List all the parent-child relationships in this hierarchy. 2. Draw the hierarchical sequence (numbering) for a university with 1 department, 2 professors (one with 2 publications, one with none), 1 course with 2 sections (each with 3 enrollments), 1 building with 3 rooms. 3. If you issue a GN call with an unqualified PROFESSOR SSA starting from the root, what segment will you get? What if you issue GN again? 4. How would you retrieve all courses in the "Computer Science" department? Write the pseudocode using DL/I calls. 5. Explain why this hierarchy makes it difficult to answer: "In which room is Section 3 of CS101 held?" What would you need to add to support this query?
Exercise 31.2: Writing SSAs (Coding)
Given the GlobalBank customer database hierarchy (CUSTOMER → ACCOUNT → TRANSACTION), write the WORKING-STORAGE definitions for:
- An unqualified SSA for each segment type
- A qualified SSA to retrieve customer "C000010001"
- A qualified SSA to retrieve account "ACCT00001234"
- A qualified SSA to retrieve transactions with type = "DEBIT"
- A qualified SSA with the D (path) command code for CUSTOMER
- A qualified SSA combining two qualifications with AND: account type = "SAVINGS" AND account status = "ACTIVE"
Exercise 31.3: DL/I Call Sequences (Analysis)
For each business requirement below, write the sequence of DL/I calls needed. Include the function code and SSA type (qualified/unqualified) for each call.
- Retrieve a specific customer's name and address
- List all accounts for a specific customer
- Find the most recent transaction for a specific account
- Add a new transaction record under an existing account
- Update a customer's address (change phone number)
- Delete all transactions under a specific account (careful — explain why this might not be what you want)
- Count all transactions across all accounts for all customers (sequential scan)
Exercise 31.4: Status Code Handling (Coding)
Write a complete COBOL paragraph that: 1. Issues a GU call for a customer 2. Handles status codes: spaces (success), GE (not found), AI (open failure), and OTHER 3. For GE, sets a NOT-FOUND flag and exits gracefully 4. For AI, displays a diagnostic message and calls an abend handler 5. For OTHER, displays the unexpected status code with the segment name and calls the abend handler 6. Includes debug-level DISPLAY statements controlled by WS-DEBUG-LEVEL
Exercise 31.5: Complete IMS Program (Project)
Write a complete batch DL/I COBOL program that produces a customer statement report. The program should:
- Accept a customer ID from a PARM
- Retrieve the customer segment (GU with qualified SSA)
- Print customer header information
- Loop through all accounts (GNP with unqualified ACCOUNT SSA)
- For each account, loop through all transactions (GNP with unqualified TRANSACTION SSA)
- Print each transaction with running balance
- Print account subtotals
- Print customer totals
- Handle all status codes defensively
- Include a checkpoint every 100 customers (if processing multiple)
Exercise 31.6: IMS vs. Relational Comparison (Analysis)
The GlobalBank customer database hierarchy is:
CUSTOMER → ACCOUNT → TRANSACTION
→ LOAN → PAYMENT
→ ADDRESS
- Draw the equivalent relational schema (ER diagram) with tables, primary keys, and foreign keys.
- Write the SQL equivalent of: GU CUSTOMER(CUST-ID = 'C000010001'), then GNP ACCOUNT (all accounts).
- Write the SQL equivalent of: GU CUSTOMER(CUST-ID = 'C000010001'), GNP TRANSACTION under a specific account.
- Write a query that is easy in SQL but hard in IMS: "Find all customers with a total balance exceeding $1,000,000."
- Write a query that is easy in IMS but hard in SQL: "Retrieve the customer, their first account, and the first transaction under that account in a single operation." (Hint: D command code)
- For a workload of 10,000 random customer lookups per second, which system (IMS with HDAM or DB2 with indexed table) would you expect to perform better, and why?
Exercise 31.7: IMS Modernization (Research)
Research and write a one-page summary on one of the following topics:
- How IMS Connect enables web and mobile access to IMS transactions
- The IMS Universal JDBC driver — how it maps SQL to DL/I
- z/OS Connect Enterprise Edition and RESTful access to IMS
- The role of IMS in hybrid cloud architectures
- Real-world case studies of organizations migrating from IMS to DB2 (or choosing not to)