Previous Topic: Deriving Views from Non-SQL Defined RecordsNext Topic: Creating Indexes


Examples

Identifying Source Records in Different Orders to Change Results

The following diagram illustrates the records being used to derive a view:

The records are identified in the following order:

             Source Record             Derivation Source #

             DEPARTMENT                     01
             EMPLOYEE                       02
             OFFICE                         03

The records are joined on the following set relationships:

     Column #1/Set     Of Der   Oper         Column #2      Of Der

     DEPT-EMPLOYEE       01      ST                           02
     OFFICE-EMPLOYEE     03      ST                           02

The records are obtained as follows:

OBTAIN EACH DEPARTMENT WITHIN area-name
OBTAIN EACH EMPLOYEE WITHIN DEPT-EMPLOYEE
OBTAIN OWNER WITHIN OFFICE-EMPLOYEE

In this example, any employee not connected to a department will not be returned.

The records are identified in the following order:

             Source Record             Derivation Source #

             EMPLOYEE                       01
             OFFICE                         02
             DEPARTMENT                     03

The records are joined on the following set relationships:

     Column #1/Set     Of Der   Oper         Column #2      Of Der

     OFFICE-EMPLOYEE     02      ST                           01
     DEPT-EMPLOYEE       03      ST                           01

The records are obtained as follows:

OBTAIN EACH EMPLOYEE WITHIN area-name
OBTAIN OWNER WITHIN OFFICE-EMPLOYEE
OBTAIN OWNER WITHIN DEPT-EMPLOYEE

In this example, all employees are returned, though not every employee may be connected to a department or an office.

Defining an Ambiguous Path

The previous diagram illustrates the records being used for derivation.

The records are identified in the following order:

             Source Record             Derivation Source #

             DEPARTMENT                     01
             OFFICE                         02
             EMPLOYEE                       03

The records are joined on the following set relationships:

     Column #1/Set     Of Der   Oper         Column #2      Of Der

     DEPT-EMPLOYEE       01      ST                           03
     OFFICE-EMPLOYEE     02      ST                           03

ASF would attempt to build a retrieval path as follows:

OBTAIN EACH DEPARTMENT WITHIN area-name
OBTAIN EACH OFFICE WITHIN area-name
OBTAIN EACH EMPLOYEE WITHIN DEPT-EMPLOYEE

The OFFICE-EMPLOYEE set join would cause an error because ASF is unable to connect the OFFICE record, which was already obtained, to the EMPLOYEE record obtained through the DEPT-EMPLOYEE set. Since the DEPARTMENT and OFFICE records are not connected through any set relationship, a logical path cannot be built.

Joining Records that Are Already Directly Connected

The following diagram illustrates the records being used for derivation:

The records are identified as follows:

             Source Record             Derivation Source #

             EMPLOYEE                           01
             STRUCTURE                          02

The join information is entered as follows:

    Column #1/Set     Of Der   Oper         Column #2      Of Der

    REPORTS-TO           01      ST                           02
    MANAGES              01      ST                           02

The MANAGES set join would not be allowed because the EMPLOYEE and STRUCTURE records are already directly connected through the first join defined.

Note: To include the MANAGES set in the table, identify the EMPLOYEE record again as a separate derivation source (derivation source #3) and specify the following join information:

Column #1/Set    Of Der   Oper       Column #2     Of Der

REPORTS-TO          01      ST                        02
MANAGES             03      ST                        02

Note that the resulting view returns two records of the same record type. Only the last record obtained will be updated in the database when updates are made through the view.

Joining Records that Are Already Indirectly Connected

The following diagram illustrates the records being used for derivation:

The records are identified as follows:

              Source Record             Derivation Source #

              CUSTOMER                       01
              SALES                          02
              PRODUCT                        03
              ITEM                           04
              ORDER                          05

The join information is entered as follows:

    Column #1/Set     Of Der   Oper         Column #2      Of Der

    CUSTOMER-SALES       01      ST                           02
    PRODUCT-SALES        03      ST                           02
    PRODUCT-ITEM         03      ST                           04
    ORDER-ITEM           05      ST                           04
    CUSTOMER-ORDER       01      ST                           05

The CUSTOMER-ORDER set join would not be allowed because the CUSTOMER and ORDER records are already indirectly joined through the previously defined set relationships.

When you derive a view from non-SQL defined records, the elements of the schema records become the columns for the view. The following considerations apply:

Note: Views derived from non-SQL defined records cannot be used as source tables for other views.