home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / utilities / powerbase / pbasedoc / indices < prev    next >
Encoding:
Text File  |  1994-01-05  |  5.9 KB  |  110 lines

  1.                                 Indices
  2.                                 =======
  3.  
  4. The record data is stored in a file called 'Database' which is inside the
  5. database's application directory. The order of records within 'Database' is
  6. determined purely by the order in which the records are entered. In order to
  7. access the records in a logical order we need one or more INDICES. Powerbase
  8. contains no sorting facilities (other than the ability to sort a validation
  9. table or, under special circumstances, a report) all ordering of data being
  10. achieved by the use of indices.
  11.  
  12. The most important index is index #0. This is always called 'PrimaryKey' and
  13. is created as part of the process of setting up a database (see 'Create').
  14. You will find the file 'PrimaryKey' inside the database directory. 
  15.  
  16. Other, subsidiary, indices may be created as and when required up to a
  17. maximum of 10. (This number will be found in the text file 'Config', in the
  18. 'Resources' subdirectory inside the Powerbase directory. It may be increased
  19. if necessary.) All indices except 'PrimaryKey' are stored in the
  20. subdirectory 'Indices' and all have an icon bearing an 'I'. When a database
  21. is opened any indices in this subdirectory will be loaded automatically
  22. (indices operate in memory, for speed, not directly from disc.) Changes to
  23. the database cause the indices to be updated and closing the database (or
  24. quitting Powerbase itself) causes the updated indices to be written back to
  25. the disc.
  26.  
  27. Note that the more indices you use the longer it will take to add and delete
  28. records or to make alterations to records which involve changing several
  29. indices. The ideal situation would be to have ALL fields indexed and, given
  30. an ARM3-based machine and a record structure which hasn't very many fields,
  31. this might well be feasible. Remember, however, that fields which are very
  32. repetitive (i.e. those which have only a few distinct values, these being
  33. repeated throughout many records) do not index efficiently. 
  34.  
  35. The file '!Tutorial' gives simple examples showing how keys and indices
  36. work.
  37.  
  38. Indexing a field 
  39. ================ 
  40. Click MENU over the required field and follow the 'Index field' choice from
  41. the 'Field' sub-menu. The tag of the field you clicked on will appear in the
  42. first 'Key field(s)' icon. If you wish to use a composite key (see 'Create')
  43. you can use the "bump" icons to bring the tag of the second required field
  44. into view. Alternatively, the field may be selected from a menu. Enter the
  45. numbers of characters from words 1-4 to be used in constructing the key (see
  46. 'Create'). Select the 'Case sensitive' switch if required (see file
  47. 'Create') and click on 'OK'. If the field is already indexed you will be
  48. warned of this and asked if you wish to overwrite the existing index. When
  49. indexing is complete you will see that the descriptor of the indexed field
  50. has changed from black to dark blue. 
  51.  
  52. Clicking on the "key" buttons on the keypad causes the red highlighting
  53. which indicates the current key to move from one indexed field to another.
  54. When you have a secondary key selected as the current key it works just like
  55. the primary key as regards browsing, searching and printing.
  56.  
  57. There is nothing to stop you indexing one field whilst a secondary index
  58. based on another field is the currently-active one, thus producing the
  59. effect of a "sort within a sort". You should NOT however try to index a
  60. field when the currently-active index is on that same field!
  61.  
  62. Using an index to speed up printing
  63. ===================================
  64. The time taken to generate a report can sometimes be shortened dramatically
  65. by the use of a subsidiary. Selecting the 'Use index' button on the 'Match'
  66. window will use an index to find the matching records IF the search formula
  67. contains a simple test for equality on an indexed field. 
  68.  
  69. Suppose, for instance, you are preparing a list of all transition elements
  70. from the 'Elements' sample database. The search formula would be GP=T.
  71. Without the use of an index such a list (with just the name of the element
  72. selected) will take about 6.5 seconds on a hard disc. If you create an index
  73. on the GP field and then select 'Use index' before clicking on 'OK' the same
  74. list takes only about 2.5 seconds.
  75.  
  76. Note that the search formula may be much more complex than in the above
  77. example as long as it contains at least one search element of the form
  78. TAG=VALUE where TAG is an indexed field. The index involved need not be the
  79. currently selected one.
  80.  
  81. Automatic saving of indices
  82. ===========================
  83. The loss of an index can be a serious matter, especially if it is the
  84. primary key index. As mentioned above an open database stores its indices in
  85. memory and normally writes them back to the disc only when it is closed. It
  86. would be most unfortunate if, after a long working session, the power were
  87. to fail or some kind person reset your computer for you or switched it off
  88. altogether. You are advised, therefore, to save the indices from time to
  89. time during a working session, just as you would (presumably!) save a long
  90. wordporcessor document at intervals. The 'Force update' button on the keypad
  91. causes all indices (and all validation tables, as a matter of fact) to be
  92. saved to disc. If you don't want to have to bother remembering to do this
  93. you can automate the process as follows.
  94.  
  95. Find the 'Save indices' entry on the 'Miscellaneous' sub-menu. It leads in
  96. turn to another sub-menu with three choices:-
  97.  
  98.         (1) Automatic   Indices will be saved automatically at intervals
  99.                         specified by you. The default is 10 minutes.
  100.  
  101.         (2) Warning     The 'Force update' button will flash briefly,
  102.                         accompanied by a discreet beep, at intervals
  103.                         determined by you. No saving is performed and you
  104.                         may ignore the warning if you wish or click on
  105.                         'Force update'.
  106.  
  107.         (3) Manual      The user saves the indices as desired by clicking on
  108.                         'Force update'. This is the default setting.
  109.  
  110.