Comprehensive Educational information on Computer Programming!: IMS DB - Logical Database

Saturday, February 23, 2019

IMS DB - Logical Database

IMS database has a rule that each segment type can have only one parent. This limits the complexity of the physical database. Many DL/I applications require a complex structure that allows a segment to have two parent segment types. To overcome this limitation, DL/I allows the DBA to implement logical relationships in which a segment can have both physical and logical parents. We can create additional relationships within one physical database. The new data structure after implementing the logical relationship is known as the Logical Database.

Logical Relationship

A logical relationship has the following properties −
  • A logical relationship is a path between two segments which are related logically and not physically.
  • Usually a logical relationship is established between separate databases. But it is possible to have a relationship between the segments of one particular database.
The following image shows two different databases. One is a Student database, and the other is a Library database. We create a logical relationship between the Books Issued segment from the Student database and the Books segment from the Library database.
std and library database
This is how the logical database looks when you create a logical relationship −
Logical DataBase

Logical Child Segment

Logical child segment is the basis of a logical relationship. It is a physical data segment but for DL/I, it appears as if it has two parents. The Books segment in the above example has two parent segments. Issued books segment is the logical parent and Library segment is the physical parent. One logical child segment occurrence has only one logical parent segment occurrence and one logical parent segment occurrence can have many logical child segment occurrences.

Logical Twins

Logical twins are the occurrences of a logical child segment type that are all subordinate to a single occurrence of the logical parent segment type. DL/I makes the logical child segment appear similar to an actual physical child segment. This is also known as a virtual logical child segment.

Types of Logical Relationships

A DBA creates logical relationships between segments. To implement a logical relationship, the DBA has to specify it in the DBDGENs for the involved physical databases. There are three types of logical relationships −
  • Unidirectional
  • Bidirectional Virtual
  • Bidirectional Physical

Unidirectional

The logical connection goes from the logical child to the logical parent and it cannot go the other way around.

Bidirectional Virtual

It allows access in both the directions. The logical child in its physical structure and the corresponding virtual logical child can be seen as paired segments.

Bidirectional Physical

The logical child is a physically stored subordinate to both its physical and logical parents. To application programs, it appears the same way as a bidirectional virtual logical child.

Programming Considerations

The programming considerations for using a logical database are as follows −
  • DL/I calls to access the database remains same with the logical database too.
  • Program specification block indicates the structure which we use in our calls. In some cases, we cannot identify that we are using a logical database.
  • Logical relationships add a new dimension to database programming.
  • You must be careful while working with logical databases, as two databases are integrated together. If you modify one database, the same modifications must be reflected in the other database.
  • Program specifications should indicate what processing is allowed on a database. If a processing rule is violated, you get a non-blank status code.

Concatenated Segment

A logical child segment always begins with the complete concatenated key of the destination parent. This is known as the Destination Parent Concatenated Key (DPCK). You need to always code the DPCK at the start of your segment I/O area for a logical child. In a logical database, the concatenated segment makes the connection between segments that are defined in different physical databases. A concatenated segment consists of the following two parts −
  • Logical child segment
  • Destination parent segment
A logical child segment consists of the following two parts −
  • Destination Parent Concatenated Key (DPCK)
  • Logical child user data
logical child
When we work with concatenated segments during update, it may be possible to add or change the data in both the logical child and the destination parent with a single call. This also depends on the rules the DBA specified for the database. For an insert, provide the DPCK in the right position. For a replace or delete, do not change the DPCK or the sequence field data in either part of the concatenated segment.

No comments:

Post a Comment