Creating logical relationships

Logical relationships resolve conflicts in the way application programs need to view segments in the database.

With logical relationships, application programs can access:

An alternative to using logical relationships to resolve the different needs of applications is to create separate databases or carry duplicate data in a single database. However, in both cases this creates duplicate data. Avoid duplicate data because:

By establishing a path between two segment types, logical relationships eliminate the need to store duplicate data.

To establish a logical relationship, three segment types are always defined:

The following database types support logical relationships:

Two databases, one for orders that a customer has placed and one for items that can be ordered, are called ORDER and ITEM. The ORDER database contains information about customers, orders, and delivery. The ITEM database contains information about inventory.

If an application program needs data from both databases, this can be done by defining a logical relationship between the two databases. As shown in the following figure, a path can be established between the ORDER and ITEM databases using a segment type, called a logical child segment, that points into the ITEM database. The following figure shows a simple implementation of a logical relationship. In this case, ORDER is the physical parent of ORDITEM. ORDITEM is the physical child of ORDER and the logical child of ITEM.

In a logical relationship, there is a logical parent segment type and it is the segment type pointed to by the logical child. In this example, ITEM is the logical parent of ORDITEM. ORDITEM establishes the path or connection between the two segment types. If an application program now enters the ORDER database, it can access data in the ITEM database by following the pointer in the logical child segment from the ORDER to the ITEM database.

Figure 1. A simple logical relationship
begin figure description. This figure is described in the surrounding text. end figure description.

The physical parent and logical parent are the two segment types between which the path is established. The logical child is the segment type that establishes the path. The path established by the logical child is created using pointers.