408 IMS Connectivity in an On Demand Environment: A Practical Guide to IMS Connectivity
Figure 21-2 The layered set of IMS Java class libraries
21.2.2 The basic concepts of relational access to hierarchical databases
In this section, we provide the basic concepts of relational access to the IMS hierarchical
database.
How to make a relational table from a segment
The solution to this problem is very simple. You can identify a type of segment occurrence as
a relational table. In this way, a type of segment relates to a type of relational table, a segment
occurrence relates to a row, and a field in a segment occurrence relates to a column in a
relational table. See Figure 21-3 for an example. The name of a segment becomes the table
name in an SQL query, and the name of a field becomes the column name in the SQL query.
Figure 21-3 Segment occurrences as relational tables
How to deal with the nature of hierarchy
Before coding your SQL to access IMS database, you need to understand another important
concept. As shown in Figure 21-3, the occurrences of segments have a hierarchical
relationship between a root segment and a dependent segment. Also, both the dependent
CEETDLI Interface
JNI
Base
App
DB
JDBC / SQL
XMS
DL/I
Database
View
IMS Java
Application
Customer Code
IMS Java Class Library
C layer Interface to IMS
Your Business Logic
IMS DB Metadata
by DL/I model Utility
IMS Dep. Region
TRX and Message
Processing
Mapping to
DL/I APIs
JDBC, JCA
interface
Java to C
Interface
XML Shredder,
XML Materializer
CUSTNO n NAME n ADDR n TELNO n
Root Segment
CUSTNO2 NAME2 ADDR2 TELNO2
CUSTNO1 NAME1 ADDR1 TELNO1
ORDNO m ORDNAME m
Dependent Segment A
ORDNO12 ORDNAME12
ORDNO11 ORDNAME11
PRODNO s PRODNAME s
PRODNO112 PRODNAME112
PRODNO111 PRODNAME111
Dependent Segment AA
TELNOnADDR nNAME nCUSTNO n
TELNO2ADDR2NAME2CUSTNO2
TELNO1ADDR1NAME1CUSTNO1
ORDNAME mORDNO m
ORDNAME12ORDNO12
ORDNAME11ORDNO11
PRODNAME sPRODNO s
PRODNAME112PRODNO112
PRODNAME111PRODNO111
Root Segment able
Dependent Segment A Table
Dependent Segment AA Table
ORDER
PRODUCT
CUSTOMER