Home Index list of chapters
previous chapter
Appendix C
Notes on the new index structure (v.9.70 and greater)
One of the problems with earlier versions of Powerbase concerns the familiar situation where you need to enter a large number of records from data which is presented in key order — especially primary key order. This could happen, for example, if you were presented with a batch of forms with names in alphabetical order where the primary key was derived from the name. Instead of an efficient search tree being generated the keys would form a degenerate tree or linear list. This might not matter in a small database but when thousands of records are involved searching for individual records and insertion of new ones become progressively slower. Users were therefore recommended to mix up the data so that records were created in a more random fashion, and also to balance indexes from time to time using the utility on the iconbar menu.
The new index structure is of a self-balancing type (Andersson tree, for the programmers among you) which makes it possible to enter such data in strict alphabetical order (or reverse alphabetical order for that matter) and still have a balanced index tree — in fact ordered entry actually produces better results than randomised entry! This doesn't mean that index trees remain absolutely optimal all the time, but any imbalance goes only so far and then corrects itself as more records are added. The utilities for examining index trees have been retained so you can examine the development of your indexes if you wish. What you're likely to see is a number of records at the tail-end of the index which are a level or two down from their optimum position. This is unimportant but if it really offends you the option to balance the tree still exists. What you can be sure of is that you'll never see a really badly unbalanced index, even if there are few distinct key values so that a large number of repeated keys occur.
You can easily demonstrate the effectivness of the new index structure as follows:
- Create a database with just one Numeric field to hold at least two characters.
- Enter the numbers 1-14.
- Examine the resulting tree structure using Utilities=>View index from the iconbar menu. You will see that the tree has a decided bias to the right.
- Add 15 and examine the tree again to see how it rebalances!
- Clear all records by choosing Miscellaneous=>Move/delete from the main menu and selecting Delete in the resulting window.
- Enter the numbers in reverse order, i.e. 15 to 2, and note the imbalance as in 3.
- Insert 1 and observe how balancing takes place producing exactly the same tree as in 4.
- Clear the records again.
- Create 14 records entering the same number in every record. The tree exhibits the same right bias as before.
- Enter the 15th record and everything comes right!
More subfiles
While devising the new index structure the opportunity was taken to increase the number of available subfiles from 6 to 16. This will be found useful for anyone who is, for example, cataloguing a photo collection and wishes to group items according to subject. As in previous versions you may use just one subfile and the others won't get in your way or reduce the number of records you can store, but if you want as many as 16 categories of records in one database you can have them. Users of older versions of Powerbase will notice the changes to the Subfile control window necessitated by the increased number of subfiles, and also (in the Match window) to the method of selecting the subfiles to be included in a report.
Compatibility with pre-existing databases
Powerbase 9.70 can load and use indexes of the old type. It can also convert them to the new type but they will then not be usable on earlier versions of the program. When you open a database with old style indexes you will be offered the option of converting them or proceeding with them as they are. If you decide not to convert them you can always do so later from the Convert entry on the Indexes sub-menu. (If you decide not to convert the indexes RISC OS 3.5 or later will give you the option of preventing this choice being offered every time the database is opened.)
You are strongly advised to convert to the new index type and gain the advantages described above. The only reason not to do so is if you intend to use the database on another computer with an earlier version of Powerbase, in which case why not update the software on that computer? It should be noted that if you insist on using the old indexes you will not be able to create any further indexes or redefine the primary key; v.9.70 can only create new-style indexes. If during conversion everything goes pear-shaped (it shouldn't) you can retrieve the old indexes which will have been copied into a subdirectory called OldInds inside the database directory. All you need do is delete the PrimaryKey index file and the subsidiary files inside the Indexes subdirectory and replace them with the ones saved in OldInds. Once you have added any new data the indexes in OldInds will be out of date and should be deleted.
Note that new index files are easily distinguished from old ones by their icons which are predominantly orange rather than pale yellow.
Home Index list of chapters
previous chapter