Mapping IMS and FOCUS Relationships

In this section:

The join is an important technique for reporting from any database system. A join enables you to report from more than one database at the same time by matching values of fields from each database.

With most FOCUS adapters, you can join separate databases or files that share a common field by describing each file as a segment in one multi-structure Master File. This embedded join technique is not available with the Adapter for IMS/DB since each Master File must describe one PCB and each PCB must describe one DBD.

The following sections describe the techniques available for relating separate IMS databases.


Top of page

x
IMS Logical Relationships

In IMS, a PCB can describe a logical database, and a logical DBD can describe a relationship between multiple IMS databases. Therefore, a Master File can describe a join between separate IMS databases if there is a PCB for a DBD that describes the join.

The adapter cannot distinguish between a DBD for a physical database and a DBD for a logical database. You create the Master Files using identical techniques and attributes.


Top of page

x
Alternating Between Databases

The PSB provides the ability to report from separate IMS databases. The PSB can contain PCBs for multiple databases, and an application can use all PCBs from a PSB. However, this is not a join since there is no automatic matching of common field values from the separate databases and, in fact, the databases do not have to be related in any way.


Top of page

x
The Dynamic JOIN

FOCUS provides the dynamic JOIN command for joining separate data sources. You can issue a JOIN command at run time to join IMS databases that have PCBs in the same PSB. In fact, with the appropriate adapters installed, you can implement joins between IMS databases and non-IMS data sources or files (for example, DB2 tables and FOCUS data sources).

FOCUS provides two types of dynamic joins, equijoins and conditional joins. With equijoins, the data sources to be joined must have at least one field that shares common values. With conditional joins, the JOIN command specifies an expression used to relate the data sources.

The JOIN command can create either an inner join (only matching records in both data sources are displayed) or a left outer join (all records from the host data source display and, if no record matches in the target data source, default values display).

In order to join "to" an IMS database using an equjoin, you must join to a key field or secondary index in the root segment.

For more information about the dynamic JOIN command, see the Creating Reports manual.

The following diagram illustrates a dynamic equijoin between separate IMS databases:

  1. Shows two IMS DBDs. DBD1 has a field called SOCSEC that is not a key and not in the root segment. DBD2 has a field called SSN that shares the same values as SOCSEC. The field SSN is the root key of DBD2.
  2. Is a PSB that has PCBs for DBD1 and DBD2. Each PCB is sensitive to the segment containing the shared field.
  3. Is the FOCPSB. It associates the first PCB with Master File FILEA and the second PCB with Master File FILEB.
  4. Is a FOCUS session or FOCEXEC that issues the JOIN command to join the two Master Files. Notice that the "to" field in the JOIN command is a key in the root segment.


Information Builders