bdfg1m0f | General Information |
TPFDF lets you read LRECs from, and add LRECs to, a subfile in any file in the database, without having to worry about the physical structure of the file. You do need to know, however, how the file is split into subfiles, and what type of index support (if any) is being used with the file.
In a file, LRECs are distributed and accessed as follows:
If a file contains more than one subfile, TPFDF must be able to calculate into which subfile any particular LREC belongs. The database administrator supplies this information as an algorithm. TPFDF uses this algorithm and the algorithm argument, passed as a parameter with a TPFDF macro or function, to determine where an LREC belongs.
For example, use an algorithm to divide a small customer file into 26 subfiles where each subfile contains the LRECs for a group of customers who all share the same initial surname letter: A, B, C, ..., Z.
The database administrator gives TPFDF this information by specifying a particular algorithm in the DSECT macro for the file. In the example, the required algorithm is #TPFDB01.
Provide an algorithm argument as a macro or function parameter to add LRECs to the file. In the example, the argument is the first letter of the customer name. TPFDF uses the algorithm argument, together with the algorithm specified for the file (#TPFDB01), to calculate the appropriate subfile for the LREC that contains details about this customer.
There are many different algorithms from which to choose. They are explained in TPFDF Database Administration.
Algorithms provide one method of distributing LRECs between subfiles; basic index support provides another. With the simplest type of basic index support, TPFDF uses an LREC in one file, the index file, to point to (reference) a subfile in another file, called the detail file.
Figure 6 shows a basic index support structure for an application program that processes customer data. For example, the application program is processing information for a customer named JONES. TPFDF searches the high-level index to find the reference to the detail file for JONES.
Figure 6. TPFDF Basic Index Support
Basic index support is transparent to the application program. The application program does not depend on the storage structure or the access path to the data. The actual steps involved in retrieving or building an indexed file are done automatically by TPFDF.
Indexed file structures are an effective way to store large, variable quantities of data. TPFDF supports:
Block index support optimizes retrieval of data in a TPFDF file that has many chains. Figure 7 shows a block index structure for an application program that processes customer data. For example, the application program is processing information for a customer named FOX.
Without the block index facility, TPFDF searches the prime block and five chained blocks to find the data. With the block index facility, TPFDF searches the prime block to find the direct reference to the block that contains the data.
Figure 7. TPFDF Block Index Facility
B+Tree index support is similar to block index support. Like block indexing, B+Tree index support uses index LRECs (also known as technical LRECs or TLRECs) to identify the first data LREC contained in each block of a subfile. Unlike block indexing, these TLRECs are not maintained in the prime block of the subfile. Instead, these TLRECs are maintained in a separate B+Tree structure.
Instead of reading all the LRECs in a subfile until it locates the desired LREC, TPFDF can go directly from the B+Tree structure to the block containing the requested LREC. LRECs are then searched sequentially in that block.
The B+Tree structure, maintained by TPFDF, is transparent to the application program. The database administrator must specify that a file is using B+Tree indexing in the DSECT and DBDEF statements. TPFDF then maintains technical logical records (TLRECs) in the B+Tree structure associated with the subfile. Every TLREC in the lowest level of the B+Tree structure points to a data block of the subfile.
For more information about B+Tree indexing, see TPFDF Database Administration.
A data file that uses B+Tree indexing has a B+Tree index file associated with it. The data file consists of data blocks that contain LRECs. The B+Tree index file consists of node blocks that contain TLRECs.
Figure 8 shows data file GR91SR, which uses B+Tree index file IR73SR. Data file GR91SR shows nine data blocks. B+Tree index file IR73SR shows a root node and three leaf nodes.