home *** CD-ROM | disk | FTP | other *** search
- Indices
- =======
-
- The record data is stored in a file called 'Database' which is inside the
- database's application directory. The order of records within 'Database' is
- determined purely by the order in which the records are entered. In order to
- access the records in a logical order we need one or more INDICES. Powerbase
- contains no sorting facilities (other than the ability to sort a validation
- table or, under special circumstances, a report) all ordering of data being
- achieved by the use of indices.
-
- The most important index is index #0. This is always called 'PrimaryKey' and
- is created as part of the process of setting up a database (see 'Create').
- You will find the file 'PrimaryKey' inside the database directory.
-
- Other, subsidiary, indices may be created as and when required up to a
- maximum of 10. (This number will be found in the text file 'Config', in the
- 'Resources' subdirectory inside the Powerbase directory. It may be increased
- if necessary.) All indices except 'PrimaryKey' are stored in the
- subdirectory 'Indices' and all have an icon bearing an 'I'. When a database
- is opened any indices in this subdirectory will be loaded automatically
- (indices operate in memory, for speed, not directly from disc.) Changes to
- the database cause the indices to be updated and closing the database (or
- quitting Powerbase itself) causes the updated indices to be written back to
- the disc.
-
- Note that the more indices you use the longer it will take to add and delete
- records or to make alterations to records which involve changing several
- indices. The ideal situation would be to have ALL fields indexed and, given
- an ARM3-based machine and a record structure which hasn't very many fields,
- this might well be feasible. Remember, however, that fields which are very
- repetitive (i.e. those which have only a few distinct values, these being
- repeated throughout many records) do not index efficiently.
-
- The file '!Tutorial' gives simple examples showing how keys and indices
- work.
-
- Indexing a field
- ================
- Click MENU over the required field and follow the 'Index field' choice from
- the 'Field' sub-menu. The tag of the field you clicked on will appear in the
- first 'Key field(s)' icon. If you wish to use a composite key (see 'Create')
- you can use the "bump" icons to bring the tag of the second required field
- into view. Alternatively, the field may be selected from a menu. Enter the
- numbers of characters from words 1-4 to be used in constructing the key (see
- 'Create'). Select the 'Case sensitive' switch if required (see file
- 'Create') and click on 'OK'. If the field is already indexed you will be
- warned of this and asked if you wish to overwrite the existing index. When
- indexing is complete you will see that the descriptor of the indexed field
- has changed from black to dark blue.
-
- Clicking on the "key" buttons on the keypad causes the red highlighting
- which indicates the current key to move from one indexed field to another.
- When you have a secondary key selected as the current key it works just like
- the primary key as regards browsing, searching and printing.
-
- There is nothing to stop you indexing one field whilst a secondary index
- based on another field is the currently-active one, thus producing the
- effect of a "sort within a sort". You should NOT however try to index a
- field when the currently-active index is on that same field!
-
- Using an index to speed up printing
- ===================================
- The time taken to generate a report can sometimes be shortened dramatically
- by the use of a subsidiary. Selecting the 'Use index' button on the 'Match'
- window will use an index to find the matching records IF the search formula
- contains a simple test for equality on an indexed field.
-
- Suppose, for instance, you are preparing a list of all transition elements
- from the 'Elements' sample database. The search formula would be GP=T.
- Without the use of an index such a list (with just the name of the element
- selected) will take about 6.5 seconds on a hard disc. If you create an index
- on the GP field and then select 'Use index' before clicking on 'OK' the same
- list takes only about 2.5 seconds.
-
- Note that the search formula may be much more complex than in the above
- example as long as it contains at least one search element of the form
- TAG=VALUE where TAG is an indexed field. The index involved need not be the
- currently selected one.
-
- Automatic saving of indices
- ===========================
- The loss of an index can be a serious matter, especially if it is the
- primary key index. As mentioned above an open database stores its indices in
- memory and normally writes them back to the disc only when it is closed. It
- would be most unfortunate if, after a long working session, the power were
- to fail or some kind person reset your computer for you or switched it off
- altogether. You are advised, therefore, to save the indices from time to
- time during a working session, just as you would (presumably!) save a long
- wordporcessor document at intervals. The 'Force update' button on the keypad
- causes all indices (and all validation tables, as a matter of fact) to be
- saved to disc. If you don't want to have to bother remembering to do this
- you can automate the process as follows.
-
- Find the 'Save indices' entry on the 'Miscellaneous' sub-menu. It leads in
- turn to another sub-menu with three choices:-
-
- (1) Automatic Indices will be saved automatically at intervals
- specified by you. The default is 10 minutes.
-
- (2) Warning The 'Force update' button will flash briefly,
- accompanied by a discreet beep, at intervals
- determined by you. No saving is performed and you
- may ignore the warning if you wish or click on
- 'Force update'.
-
- (3) Manual The user saves the indices as desired by clicking on
- 'Force update'. This is the default setting.
-
-