BTREE File Structure

The BTREE file structure is a true variable-level recursive structure. The host automatically balances the BTREE structure as keys are added and deleted; therefore no periodic key rebuilds are necessary. In addition, the BTREE algorithms allow you to set the average number of keys per node to optimize key file performance for your particular file and system characteristics.

The BTREE data structure allows any data-level file to have keys defined for it. Dictionary, MD, or SYSTEM level files may not have keys defined. When a file has keys set up, a total of four elements are necessary in order for the BTREE system to operate:

  1. The data file itself is flagged by the BTREE system as a DB type file. The change of the file from a D to a DB type file is automatic and requires no action by you.

  2. The keys themselves are stored in an additional data portion under the same dictionary. This additional data portion has the same name as the main data portion with a $ appended to the end. For example, a key file for a file named CUSTOMER would be named CUSTOMER,CUSTOMER$. This naming convention allows multiple data portion files to each have individual key files. Note that with this naming convention, some file names are not valid:

  3. The key definitions are stored in an intermediate format in an item in the file’s dictionary called SMART-TREE-DEF.

  4. A control item is created for each data portion in the file’s dictionary. This item has the same name as the data file name with the addition of a CHAR(164) appended to the end. This item will appear to have the same item-ID as the D-pointer for the key file (a CHAR(164) is a $ character with the high order bit set).

See Also

Using the BTREE File Structure System

Interfacing with Applications

Defining Key Structures

Using Lookup and Browse Routines

Source Code to Lookup Routines

Maintaining Key File Performance

Optimizing Keys

Sizing Key Files

Stack Code Calculator Function

Estimating a Key's Location and File Size

Rebuilding Keys

Key Storage Requirements