bdfd1m1w | Database Administration |
The following scenario addresses linking logically related data.
A file contains different LREC types. The contents of an LREC depend on the LREC ID, as follows:
Generally, information is requested by type rather than specifically (for example, by name, address, or telephone information). However, there must be a unique link connecting the address, salary, and telephone information to the name. To make this link, you could use a unique value based on the person's name. However, this would waste space because you would have to repeat the value for all LREC types (90, A0, B0) related to a particular name.
The TPFDF product supports a unique key generator that returns a unique value for a file. You can store this value in LRECs that are related to each other. The unique key can define relationships in a file, between files, between subsystems, between systems, and between companies.
The unique key is a 4-byte hexadecimal value.
&SW00OP3 SETC '.......1'
To hold the unique key, you must define a 4-byte field in each LREC.
No changes are necessary if the changes are made in the DSECT macro.
In this example, a subfile is created. Name, address, and salary records are then added:
DBOPN REF=zzzzzz,HOLD DBUKY REF=zzzzzz TPFDF puts the unique value in field SW00UKY
To set up the LREC (including size and primary key fields):
MVC zzzzUKY,SW00UKY Insert the unique key value into the LREC DBADD REF=zzzzzz,KEY1=(PKY=#zzzzK80,UP)