Previous Topic: Extended by RelationNext Topic: Refers to Relation


Example of Using Extended by Relations

Your basic Customer information consists of the following fields:

FIL Customer REF Known by FLD Customer code CDE

FIL Customer REF Has FLD Customer name TXT

FIL Customer REF Extended by FIL Customer detail REF

You may enter additional details about Customers in another file called Customer detail:

FIL Customer detail REF Owned by FIL Customer CDE

FIL Customer detail REF Has FLD Credit limit VAL

FIL Customer detail REF Has FLD Managing Director TXT

This results in the following entries:

 

Customer file

 

 

Customer detail

K

Customer code

Customer name

 

K

Customer code

Credit limit

Managing Director

If you wish to create a function that brings both Customer and Customer detail together, you need to build an access path that contains fields from both files. If you were doing this on the Customer detail file, this would not present a problem since you could specify virtual fields on the Owned by relation

FIL Customer detail REF Owned by FIL Customer CDE

VRT Customer name TXT

FIL Customer detail REF Has FLD Credit limit VAL

FIL Customer detail REF Has FLD Managing Director TXT

However, if you wish to attach your function to the Customer file, you would not be able to obtain the customer details unless you had an Extended by relation. Using the Extended by relation, you can specify virtual fields as follows:

FIL Customer detail REF Known by FLD Customer code CDE

FIL Customer detail REF Has FLD Customer name TXT

FIL Customer detail REF Extended by FIL Customer detail REF

VRT Credit limit VAL

VRT Managing Director TXT

Each Customer may have only one Customer detail record: there is a one-to-one correspondence between files.

There are two implementation reasons why you may consider using the Extended by relation rather than simply including the data from the extended file in the basic file: