VA FileMan V. 22 Key and Index Tutorial
[<-- Environment Setup]   Introduction Quiz Button   [Lesson 1 -->]

Introduction to Keys and Indexes


VA FileMan Version 22.0 introduced Key and Index functionality, which provides VISTA application developers the tools to design and develop more robust, efficient, and maintainable code and files. Native support for keys and complex indexes means developers no longer need to simulate these structures with M code.

With this hands-on tutorial, you will learn how you can take advantage of these powerful new tools. The instructions in the tutorial will guide you in creating your own keys and indexes on a test file set up via the A6AKIT set of routines. (See the Environment Setup page for information on how to obtain the A6AKIT routines.)

First, some definitions….


What is a Key?

A key is a set of one or more fields in a file that together uniquely identifies a record in that file. If you define a key, VA FileMan V. 22.0 automatically enforces the integrity of that key.

Key integrity means:

1.  No key field is null.
2.  The key (that is, the combination of fields in a key) is unique for all records in the file.

What is an Index?

An index is a sorted list of field values or associated data that "point" to a particular record in a file. It can be used to sort data and to look up a record via the indexed value, instead of searching the file sequentially.

In an index, VA FileMan stores the index name, the data value or values, and the internal entry number (IEN) of the record, each in its own subscript. To create an index in VA FileMan, you define a cross-reference of a given type.


What is a Cross-Reference?

A cross-reference identifies an action that should take place when the value of a field or fields defined in that cross-reference are changed. Often, the action is the placement of the value(s) into an index, in this case, the terms index and cross-reference are often used interchangeably. Technically speaking though, an index is a sorted list of records, and is built and maintained by defining a cross-reference(s).

Cross-references in Version 22 of VA FileMan can be divided into two broad categories: Traditional and New-style. Traditional cross-references are those cross-references you were able to create in versions of VA FileMan prior to Version 22, and can still create in Version 22. The new kind of cross-references you can create in Version 22 are called New-style cross-references.


Traditional Cross-References

There are seven types of Traditional cross-references:

1. Regular (index)
2. Soundex (index)
3. KWIC (index)
4. Mnemonic (index)
5. MUMPS (index or action)
6. Trigger (action)
7. Bulletin (action)

The first four define indexes, while the last two define actions that should be performed when the field on which the cross-reference is defined is edited. A MUMPS cross-reference may set an index or perform an action, depending on how it's defined.

A Traditional cross-reference is defined on a single field, and its definition is stored under ^DD(file#,field#,1). In general, the logic for a Traditional cross-reference is executed when the field on which it's defined is edited.


New-Style Cross-References

There are two types of New-style cross-references:

1. Regular (index)
2. MUMPS (index or action)

A New-style cross-reference can be composed of one or more fields. Its definition is stored in the INDEX file (#.11), which has the global root ^DD("IX").

New-style cross-references that are composed of a single field are called simple cross-references, and by default have field-level execution, which means that the cross-reference logic is executed immediately after the field is edited.

New-style cross-references that are composed of more than one field are called compound cross-references, and by default have record-level execution. Record-level execution means that the cross-reference logic is executed only after an entire record is edited, after all the fields in the cross-reference have been edited.



Introduction Quiz Button Select this link to test yourself on what you've learned in this lesson.

[<-- Previous Lesson]   Intro [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]   [Next Lesson -->]

 


Reviewed/Updated: March 20, 2007