Location Mode

This topic contains information about the location mode of a physical database structure, CALC, VIA, and Direct location mode.
Location mode is the user-specified method that determines where record occurrences are stored within an area. The following methods are available:
  • CALC- A record is stored on or near a page that is calculated by the database engine (DBMS) using the value of the element comprising the CALC key.
  • VIA (Clustering)- A set member record is stored on or near the page containing its owner record occurrence. If the owner and member are assigned to different areas, the member record is stored at the same relative position in its area as the owner record is in its area.
  • DIRECT- A record is stored on or near a user-specified page.
The location mode is used to determine the target page for a new record. The new occurrence is placed on the target page if there is sufficient space. If not, DBMS places it on the next page in the area that has sufficient space. If the end of the area is reached without locating a page, the DBMS searches from the beginning of the area for the first page with sufficient space available. If a record cannot be placed on the target page due to space limitations, it is said to
overflow
.
CALC Location Mode
The CALC location mode requires the specification of a CALC key made up of one or more record elements. Usually, a CALC key is chosen so that its value is unique across all record occurrences, although this is not a requirement. At Commonweather, for example, EMPLOYEE records are stored CALC. The EMP-ID, a four-digit number unique to each employee, is chosen as the CALC key element.
The CALC method is used for:
  • Randomization - Records are distributed evenly over all the pages in the area using a randomizing algorithm, which minimizes overflow and leaves space for VIA occurrences.
  • Direct Retrieval by Symbolic Key- A record occurrence can be retrieved with a single access using its CALC key (rather than by reading all records in an area or searching through an index).
A record whose location mode is CALC can be retrieved by simply specifying the value of its CALC key; DBMS automatically converts the CALC key into the same target page member as that used to store the record. If the CALC record had overflowed to another page when it was added to the database, the DBMS can locate it using an internally maintained set called a CALC set whose owner resides on the record's original target page.
VIA Location Mode
The VIA location mode is used to group (cluster) records that are likely to be accessed together on the same page or as close to each other as possible. This location mode is also sometimes referred to as
clustering
.
At Commonweather, for example, employee expertise is retrieved in conjunction with information about an employee. Therefore, EXPERTISE records are stored through the EMP-EXPERTISE set so that they can be clustered around their owning EMPLOYEE record.
In the following figure, the EMPLOYEE records are randomly located on four pages using the CALC location mode. The EXPERTISE records are located on the same pages as their respective owners in the EMP-EXPERTISE set through the VIA location mode. This enables both employee and expertise information to be retrieved with single-page access.
VIA Location Mode
It is also possible to store records via a system-owned index. In this situation, the target page for a new record is the page of the prior record within the index. Consequently, the indexed record occurrences tend to be physically placed within the area in the same order as their entries occur within the index. If the index is sorted on a symbolic key, the record occurrences tend to be physically sequenced in the order of their respective index key values.
DIRECT Location Mode
DIRECT location mode allows the user to suggest the page on which to store a record. It is used less frequently than CALC or VIA because it places the burden of locating records on the application program.
One use of DIRECT mode is to store records serially in an area, which is accomplished by targeting each new record to the page of the most recently stored record. (The database key of the record just stored is returned to the program). The DBMS either stores the record on the suggested target page or on the next page with sufficient space.