Tutorials for Powerbase

© Derek Haslam
Fully revised Jan.2011 to comply with Powerbase v.9.75 (10-01-2011)

Home   Quick Tutorial    Reference Manual

Main Tutorial

This tutorial is intended to acquaint a new user with the most commonly-used facilities of Powerbase. It explains how to:

The sample database Elements is used to illustrate these activities. Powerbase can provide context-sensitive help via Acorn's interactive Help application and you are advised to make use of this. Detailed information about any topic can be found in the Reference Manual which can be invoked from the PbaseDoc button on the Information window accessed from Powerbase's iconbar menu.

1 Starting Powerbase

Double-click on the Powerbase icon. After a few seconds it will appear on the iconbar with the words "No data" beneath it to show that no database is open. Dragging the Elements icon onto the Powerbase icon on the iconbar will open Elements for use and the words "No data" will be replaced by the name of the database. Double-clicking on the Elements icon has the same effect, in fact if Powerbase isn't already on the iconbar a double-click on Elements will launch it for you provided that the Powerbase application has been "seen" by the filer.

When the database opens the record window appears with the first record in the database (the one for ACTINIUM) displayed. Attached to the left-hand side of the record window is the tool-pane (see below) which enables you to control the browsing, searching and editing functions of Powerbase. Descriptions of many of the tool-pane buttons referred in the tutorial can be accessed rapidly by clicking the mouse over the relevant part of the illustration. A "thumbnail" representation of the tool-pane appears in several places in the right margin and may be clicked to take you back to the tool-pane illustration.top of page
tool pane

2 Browsing and searching

Now that you have a database running we will learn first how to move from record to record and how to access any particular record by using a small group of letters called the key of the record. Most of the tool-pane buttons respond to clicks with both SELECT and ADJUST, and the effects of the two mouse buttons are sometimes exact opposites; in other cases SELECT is the usual button to use and ADJUST has a different but related function.

2.1 Browsing through the records
The buttons at the top of the tool-pane allow you to browse through the records. If you have !Help running as previously suggested it will tell you what each button does. Once you get the general idea you will find the symbols on the buttons logical and self-explanatory. The most commonly used ones act as follows:

(a) ends takes you to the end of the database (with SELECT) and the beginning (with ADJUST), i.e. to ZIRCONIUM and ACTINIUM respectively.

(b) single step moves through the database one record at a time. From ACTINIUM, clicking SELECT takes you to ALUMINIUM, whence ADJUST takes you back to ACTINIUM.

(c) fast-forward/rewind goes through the database by longer jumps. SELECT takes you from ACTINIUM to BISMUTH and ADJUST back to ACTINIUM. The fast forward/rewind interval value is shown in a writable icon. It is initially set to 10 but can be altered by clicking in it with SELECT and entering a new value. Try entering 2 or 5 and fast-forwarding again.

At either end of the database "wrap around" occurs. If you are at the final record (ZIRCONIUM) one record forward takes you to ACTINIUM again. Similarly, one record back from ACTINIUM goes to ZIRCONIUM.

The play and stop buttons resemble the corresponding controls of a cassette player. Play starts an automatic run-through of the records without the need to touch any other buttons. When you get to the place you want, click on stop or type the Esc(ape) key on the keyboard. If the records go past too quickly you can slow the process down by increasing the number in the writable icon (the fast-forward interval).top of page

2.2 Key fields, keys and indexes
When using the buttons described above you will have noticed that the records appear to be arranged alphabetically by the name of the element. The actual order in which records occur in the database is in fact nothing like alphabetical, but the order in which they are accessed is determined by an index which forces them to appear in alphabetical order. Every database must have at least one index, but you can have as many extra ones as you wish.

If you click on the change active index button the record for HYDROGEN is displayed. Now experiment with the top group of buttons as before. You will find that the records no longer appear in alphabetical order of Name but in order of Atomic number instead. What we have done is change to a different index. If a database has several indexes change active index allows you to cycle through them in opposite directions with SELECT and ADJUST. Since Elements has only two indexes (one based on the name and the other on the atomic number) both mouse buttons have exactly the same effect. When you change to a different index the screen always displays the first record as determined by that index.

An index is built from keys which are derived from a particular key field. The way in which the key stored in the index is derived from the key field differs in the two cases. For the Name index the first four letters of the name are used. Since no two elements have names beginning with the same four letters this gives a unique value for the key. (Two letters would not be enough because of names like CHLORINE and CHROMIUM.) The Atomic number index is based on the whole 3-digit maximum length and the ordering is numeric. When a record is displayed the key is shown in the window title.

The record screen shows which fields are key fields and which are not. The labels or descriptors of fields are normally black. Where the fields are key fields they are shown in dark blue instead and the field related to the current index has its descriptor in red. Note also that the background colour of the Name field is pale yellow whereas the rest are white. This indicates that Name is the primary key field. The primary key is more important than the others; the index based on it is the only one which every database must have and is the one selected when a database is first opened.tools/png

2.3 Searching for a record
The search for record button, when clicked with SELECT, opens a small window, the Search window, to the right of the tool-pane. It contains a writable icon in which to enter the key of the record you wish to display.

search Suppose you want to see the record for the element NITROGEN. If the current index is the primary key index (based on Name) then enter NITR and either type the Return key on the keyboard or click on the Find button. The required record quickly appears. If you enter the key of a non-existent record Powerbase briefly displays a warning then displays the record which most nearly matches the key. You don't necessarily need to type the whole key; NIT would do in this case, but NI would be ambiguous (there are elements called NICKEL and NIOBIUM). If you do enter an ambiguous key or part-key the first matching record is displayed and the number of matches is shown in the icon above the Find button. You may then cycle through the matching records by clicking on the arrowheads to the left and right of this icon.

To find NITROGEN when the Atomic number index is active you would need to know that the atomic number of nitrogen is 7. Change index, enter this number and type Return or click on Find. The required record appears. Abbreviated keys are not allowed in this case for obvious reasons; if you want element 103 (LAWRENCIUM) it's no good entering 10 (NEON)!

You might want to examine a group of related records, e.g. the six similar elements LITHIUM, SODIUM, POTASSIUM, RUBIDIUM, CAESIUM and FRANCIUM which are known as the Alkali Metals. You could, of course, look up each in turn by entering its key but there is a better way. Click on the Filter button. The button becomes ticked and the Filter window opens on the right of the tool-pane.

filter This button is what we call an option button and is used to turn a particular feature ON or OFF. The six elements referred to all occur in group 1 of the Periodic Table of the elements so type GP=1 into the writable icon. and click on Apply. The record for CAESIUM is displayed. If you now experiment with the single step button you will find that they behave as if these six were the only elements in the database; all the rest have been "filtered out" so that you access only the ones you are interested in. To return to normal operation either click the Cancel button on the Filter window or deselect the option button on the tool-pane. If you want the Filter window out of the way without cancelling the filter click on Close. The option button on the tool-pane remains selected.
top of page

3 Editing the Database

3.1 Modifying records
Pointing the mouse at any field and clicking SELECT places the caret in that field. The contents of the field may then be edited in the standard way for RISC OS writable icons, with which you will be familiar (if not there's a list at 3.1 in the Quick Tutorial). Changes made to a record cause the record to be written back to the database whenever you display a different record or close the database. There is a button on the tool-pane called Update but you don't normally need to use it.tools/png

3.2 Using the clipboard
It is sometimes necessary to copy the contents of one field into another, either in the same record or a different record. This can be done with the aid of the clipboard which is controlled by buttons copy to clipboard and paste from clipboard. Place the caret in the field you want to copy and click on the first of these. Moving the caret to another field and clicking paste from clipboard writes the data from the clipboard into that field, over-writing its previous contents. You may continue to "paste" the data into new fields as often as you like. Only when you click copy to clipboard again are the contents of the clipboard changed. Data pasted into a field will not be allowed to overflow; if too long for the field it will be cut to the permitted length. As an added precaution you can't paste into a field if there is nothing on the clipboard so accidental blanking of fields is avoided. If you use a wordprocessor, whether on a RISC OS machine or not, you will probably be familiar with the keystrokes Ctrl-C and Ctrl-V for Copy and Paste respectively. You can use these in Powerbase too; they do exactly the same as the tool-pane buttons. If you're copying from one field to another in the same record there's an even easier way; just point the mouse at the field, click SELECT and keep it held down. You can now drag and drop the data to another field.

3.3 Undoing mistakes
You might edit the wrong field by mistake and want to restore the previous contents. Click MENU over the field. The second entry on the main menu contains the tag of the field. Slide off the menu to the right to open the Field sub-menu and choose Undo changes. The previous contents of the field will be restored. Similarly, if you make a mess of a whole record and want to go back to the way it was you can choose Undo changes from the main menu itself. It is important to realise that the Undo facilities will not work if you have looked at another record (or clicked on Update) before using them. You can only recover data which has been altered in or removed from the currently-displayed record.top of page

3.4 Adding new records
First we will add a new record for a fictitious element as described below:

   NAME: TASMANIUM
   SYMBOL: Ts
   ATOMIC NUMBER: 108

Click SELECT on the add record button. A blank record will be displayed with the caret in the Name field. Enter TASMANIUM here. You needn't use the Shift key; input into this field is forced to uppercase regardless. Type Return and the caret will jump to the Symbol field. Enter Ts. You will now need to type Return twice to get to Atomic number (One press takes you to the field after Name where the origin of the element's name is given. The field has no descriptor.) Alternatively you could point the mouse at the Atomic number field and click SELECT. There is no need to type Return after entering a field in order to accept the data; it's just the most convenient way of getting to the next field. When entering data into widely-scattered fields it is more convenient to use the mouse to move the caret.

Having entered the data click any of the browsing buttons so that a different record is shown. Now use search for record to find TASMANIUM by name (its key will be TASM). Change to the Atomic number index and find it by atomic number (108). In both cases try moving to the record just before and just after the new one, noting that it has been placed in its correct position in both indexes: between TANTALUM and TECHNETIUM in the Name index and at the end of the Atomic number index.tools/png

3.5 Data input validation
When entering the above data you may have noticed that the Name field will only accept capital letters and the Atomic number field will only accept numerals. Any others are simply ignored. We call this feature character validation. Another level of data validation, which we will now illustrate, is called table validation Make an entry in the Group field. Type X, for example, then try to move to another field by either typing Return or clicking the mouse. You will find that you can't do so; you get an error message instead. This is because the Group field is linked to a validation table which means that only entries which appear in the table may be used in that field. Fields linked to validation tables are distinguished by using dark green, instead of black, as the foreground colour.

To see what the validation table contains, place the caret in the Group field then click on the Table button. The validation table will be displayed in its own window. Only items in the left column of the table may be entered in the Group field. Element 108 would be a transition metal, so enter T. You will now find that Powerbase accepts your data.

Both character validation and table validation may be turned off and on by means of a button on the Preferences window. The simplest way to access this is to click ADJUST over the Powerbase icon on the iconbar. The rather large window which appears has a collection of option buttons down its left-hand side. The seventh of these (Validate input) is normally selected to indicate that validation is in effect. Click to deselect it then click on Accept. The Preferences window will be removed from the screen and you will find that input is no longer being validated and the Table button on the tool-pane is shaded.top of page

3.6 Deleting records
Since "TASMANIUM" isn't a real element we want to remove it from our database. The delete button, (the one with the dustbin icon), will do exactly that but we won't use it just yet. Make sure that the unwanted record is on the screen and click SELECT on the button above the "dustbin" button. You will now find that TASMANIUM has vanished; the names run from TANTALUM to TECHNETIUM and the atomic numbers end with 103, just as they did before you added the extra record.

Suppose you had clicked the button by mistake and deleted an important record? It isn't a problem; what you have done is made easy because it is far less drastic than it looks; the record hasn't really been deleted at all. To prove this, click SELECT on the change subfile button. TASMANIUM will reappear. You will also find that it appears to be the only record in the database! Don't worry; nothing has been lost. A Powerbase database is treated as sixteen separate subfiles numbered 0-15. When you first open the database you are looking at Subfile 0 and the heading of the record window shows this. If you look at the heading now you will see that it has changed to Subfile 1. The change subfile button advances the subfile number by 1. When you reach subfile 15 the next click takes you to subfile 0. As you might expect, clicking with ADJUST has the opposite effect.

The button above delete does not delete records; it merely moves records from one subfile to another. Clicked with SELECT it moves the displayed record to the next subfile in sequence. Thus, in the above case TASMANIUM has been moved from subfile 0 to subfile 1. A record in subfile 1 would be moved to subfile 2 and so on. When it gets to 15 the next click moves it into subfile 0 where it was originally. As you may have guessed, ADJUST moves records in the opposite direction, i.e. from subfile 1 to 0 or from subfile 0 to 15.

If you do want to lose a record for good you consign it to the dustbin by clicking delete. As this button's action is more drastic than that of the other two you are asked to confirm that this really is what you want to do before the deletion goes ahead.

You might prefer to have a warning message and a request for confirmation when simply moving a record to the next or previous subfile (especially if you sometimes click the move record button by accident). You can enable confirmation by editing the ShiftWarn option in the !Powerbase.Resources.Config file as described in 14.8.tools/png

4 Creating lists (reports)

Before Powerbase can produce a list, or report, as it is usually known in database-speak, it must be told:

4.1 Making the field selection
Specifying the fields you want is easy. To include a field point the mouse at it and click with ADJUST. The selected field will appear with its foreground and background colours reversed. If you change your mind about a field you can de-select it by clicking on it again with ADJUST. The order in which the fields will appear in the report is the order in which you select them. Take care since there is nothing on the screen to indicate in what order the fields were selected (although you can inspect the order once you have opened the Match window — see below). The fields chosen for inclusion in a report make up a field selection which may be saved, using Save selection from the Report submenu, and reloaded for future use. Just for now select Name, Symbol and Group.

4.2 Choosing which records to include
Specifying which records to include is more complicated. Click the Report button on the tool-pane (or type the Print key on the keyboard). The Match window appears. Unless you have selected at least one field as described in 4.1 the menu button labelled Fields selected will be shaded as illustrated. Otherwise, clicking on it will display a list of the selected fields in order of selection. The writable icon is where you specify the criteria which must be met by records for inclusion in the list. If you just click the Report button on the Match window (or type Return) without entering anything here you will obtain a list of the whole database (or, more accurately, the the whole of the current subfile). Try that first.

match The report won't appear until the process of scanning the database is complete. It will then be displayed in a window. If no records at all appear in this window make sure the icon for subfile 0 is highlighted as shown in the illustration. If the mouse pointer is over the main window the hourglass will tell you how far things have progressed. Pressing Escape will cause the process to be aborted. Assuming you now have a list in a window, clicking MENU over it displays a menu which leads to a Save box from which you may save the list as a text file by dragging the file icon to a filer window. If you point to a record in the displayed list and double-click with SELECT Powerbase will retrieve the chosen record and display it in the record window. Moreover, the caret is placed in the field you were pointing to on the list. This is very useful if you spot errors in the data whilst examining a list. A double click on the offending item offers the record with the caret correctly positioned for editing.

Most database reports don't include all the records. You will usually need to enter a search formula in the Match window before clicking Report. You have already used a simple search formula when you typed GP=1 to filter out all but the six Alkali Metal records (see 2.3). Search formulae can be complex and a detailed treatment can be found in Ch.3 of the Reference Manual. Only a few simple examples are shown here.tools/png

Suppose we want a list of all transitional elements. i.e. all those which have T in the Group field. We can do this by entering the search formula GP=T.

Why GP? "Group=T" seems the more obvious choice but Elements contains many fields which have no descriptor, such as the one on the first line which gives the origin of the element's name. Every field which can hold data has to have a handle by which we can refer to it and that handle is called the field tag. Tags are very short, never more than four characters. You have seen some tags already. Look at the report you produced earlier. The three columns are headed with the tags (NAME, SYM and GP) not the descriptors (Name, Symbol and Group). We therefore meet tags in two contexts:

The Report options window, displayed by choosing Options from the Report submenu, lets you change the column headings to field descriptors if you prefer them, but it is always the tags which are used in search formulae. Type GP=T in the space provided and click Report. This time the list will be a much shorter one and you will see that the GP column contains T in every case.

The second example involves listing all elements whose names end in "IUM". What we need to specify is that the Name contains IUM and we do this by entering the search formula NAME{IUM. Note the use of a left brace (curly bracket) to mean "contains". Another way to perform this search is to use a wild-card. Type NAME=$IUM. Clicking Report will produce the same list as before. The "$" is a wild-card character which can represent any number of unspecified characters. The search formula is saying in effect, "I don't care what the first part of the name is as long as it ends with IUM".

We will combine the previous two examples into a two-pronged search for all the TRANSITIONAL elements whose names end in "IUM". The search formula this time can be either NAME{IUM AND GP=T or NAME=$IUM AND GP=T. Note the spaces before and after AND. These are essential.top of page

You might like to try an alternative way of entering a search formula. It is designed for new users of a database or for occasional users who might forget what the tags of the fields are. Proceed as follows: help

  1. Click the Help button on Match window. This opens the Help window.
  2. The tag of the required field is selected either from the pop-up menu or with the "bump" icons. (In this case NAME should already be displayed as the required field).
  3. The displayed Comparison type is not the one we want, so click the pop-up menu button and choose contains.
  4. Enter IUM in the Target string writable icon.
  5. Click Add to formula. The search formula now reads NAME{IUM.
  6. Click the AND button. This enters <space>AND<space> into the formula.
  7. Use the button to the right of the tag display to show the menu of field tags and choose item 6 (GP).
  8. Select the Comparison type is equal to
  9. Enter T in the Target string field.
  10. Click Add to formula
The complete search formula should now be visible so click Report and the list will be produced. The procedure takes far longer to describe than to do and can be a great help to the infrequent Powerbase user who has trouble remembering the syntax of search formulae. If you use complex queries often you may find it convenient to save them for future use. Save query from the Report submenu enables you to do this and the resulting query files may be reloaded into the Match window by double-clicking them.

The biggest problem you are likely to encounter is not knowing the tags for the various fields. By using the above method you can see all the tags displayed in a menu or cycle through them using a pair of arrowheads ("bump" icons). It is also useful to know that clicking with SELECT on a field while holding down Ctrl causes the tag of that field to appear in the search formula icon.

4.3 Browsing and editing in a report
By now you will have noticed the Browse option button at the bottom of the report window and the shaded Edit button beside it. When Browse is selected the first record in the report is highlighted in pale blue. You are now in list edit mode. Try clicking the single step, ends and fast forward buttons on the tool-pane with SELECT and ADJUST. You will see that these buttons now move the highlighting within the report instead of changing the record in the record window. The search for record button can also be used to find a specific record provided it is present in the report. When stepping up and down a list it seems natural to use the up/down cursor arrow keys and these do indeed duplicate the actions of the single step button. What's more, you can combine them with Shift to duplicate fast forward, and with Ctrl to produce the same effect as ends.

When you are in list edit mode the previously shaded Edit button becomes active and allows you directly to edit records in the report. When clicked its legend changes to Update and the caret is placed in the first editable field of the highlighted record. Return or "down arrow" will move the caret from field to field, just as it does on the record window, and "up arrow" moves it back to the previous field. You can alter the contents of the fields and then click the Update button. (Typing Return when the caret is in the last editable field has the same effect as clicking Update.) Not only is the report modified by this procedure; the changes are written back to the database records too! This is an extremely powerful feature for finding and correcting errors in the records.

Deselecting the Browse button causes Powerbase to revert to ordinary record browsing and editing.top of page

4.4 Printing on paper
So far you have displayed reports in a window. If you want to send them to your printer you could try the following method but be warned; it might not work. Run Printers, switch on the printer, then click MENU over the displayed report. The Save as text option leads to a standard Save box from which you can drag the file icon to Printers on the iconbar when, with luck, your printer will spring into action and print the report. You could also drag the icon from the Save box to a directory window to save it. Or you could simply type Return, in which case the report would be saved under a suitable default name in a directory called PrintJobs inside the Elements database directory. Every Powerbase database has a PrintJobs directory to use as a general dumping ground for reports and which needs to be cleared out periodically. Choose Show reports from the Report submenu to display it.

If your printer is one of the more recent inkjets you might not be able to print plain text files by simply dragging them to the Printers icon as described above, because some such printers contain no fonts of their own. What aften happens is that you get page after page with nothing on them but a few characters of gobbledegook. Fortunately Powerbase is able to talk directly to the printer. Click the icon to the left of the Cancel button on the Match window. This is another way of opening the Report Options window, at the top of which is an area marked Destination. Select the Printer button instead of the Window button and click on Accept. You will now find that reports go directly to the printer (provided it is ready for use and Printers is running) without ever appearing in a window.

The Lots more button on the Report options window gives access to many features associated with hard-copy printing but this isn't the place to delve into them. Full details will be found in Ch 3.11 of the Reference Manual.top of page

5 Merging data into an Impression or Ovation Pro document

The distribution disc contains a simple Impression document called MergeTest and an Ovation Pro document called OproMerge. Either may be used in conjunction with the Elements database to illustrate direct data-merging, which is described here for Ovation Pro. Certain preliminaries are necessary to prepare Ovation Pro for direct data-merging:

  1. Open the Applets subdirectory inside OvationPro and copy the !Impulse applet into it. If your OvationPro is a recent version, supplied on CD, you will find this applet in the DavidPilling.Applets directory.
  2. The filer also needs to have "seen" the !TransDDF filter which is in the directory DavidPilling.Filters on the CD. The !Boot and !Run files of this filter need to be modified to load ASCII DDF files as described in the filter's !Help file.
Impression requires no such preparation and the method of mergin the data is identical to that described below for Ovation Pro.
  1. Ensure that Ovation Pro has been "seen" by the filer. (You need not actually load it.)
  2. Open the Elements database and drop OproMerge onto the record window. Ovation Pro will be loaded and the document displayed then the Data merge window will appear.
  3. Click on Merge. You will see that data relating to the record for ACTINIUM has been inserted into the Ovation Pro document. merge
  4. The browse buttons on the tool-pane, may be used to move through the database merging different records into the document.
  5. If a Filter has been specified it will restrict the merge operation to records matching the filter formula.
  6. Print may be used to print the document with the currently-merged data. To print a set of documents, one for each matching element, select Print all before clicking on Merge.
During data-merging Ovation Pro editing is disabled. Clicking on Cancel or closing the Data merge window restores normal editing.

The most widespread use for this powerful facility is mail merging where names, addresses and other information are merged into a standard letter to personalise it. For more information on data-merging, including instructions on how to prepare the Ovation Pro or Impression document, see Ch.9.2 in the Reference Manual.tools/png

6 Backing up

backup You are strongly advised to back up your database whenever you make changes to it and this is made easy by the provision of a Backup button on the tool-pane. However, Powerbase needs to be told where to back up. Clicking ADJUST on the button opens a window which invites you to drop a directory on the large down-pointing arrow icon. The pathname of the directory will then be displayed in place of <no directory>. This will be your backup directory and Powerbase needs to be able to find it in future so your backup choices need to be saved somewhere. If you want to use it for backing up all databases then select the in Powerbase radio button and click Save choices. If it is the backup directory for the current database only, select in database before clicking Save choices. (Ignore the middle radio button, the wording for which might not be "for User".)

Once a backup directory has been specified the stored pathname will be loaded from the choices file when the database is opened and a click with SELECT on the Backup button will make a copy of your database. If you want automatic backups you should select the Back up on closing button before saving the choices. Open directory is also useful for inspecting the contents of the backup directory or retrieving the backup copy if necesssary.top of page

7 Closing down

A database may be closed down by choosing the Close database entry from the iconbar menu. When you do so, all the indexes stored in memory are saved to disc and the database is closed. You do not have to do anything to save the database itself to disc since it has been there all along. Only the current record is in memory at any one time and this is automatically written back to disc when it has been changed in any way. Also saved automatically are validation tables and the link file which holds the links between the main database and the validation tables.

If you are going to use another database straight away just double click on it or drag it to the Powerbase icon on the iconbar. In fact you don't even need to close the previous database before doing this; Powerbase will do it for you. To terminate Powerbase itself use the Quit option on the iconbar menu.top of page

8 Creating a simple database

This section describes the creation of a simple address-book database. Make sure that the Powerbase icon is on the iconbar but with no database open. ("No data" under icon.) Click SELECT on the icon and a Save box appears showing a database icon and offering !Database as the default name. Change this to Addresses (the "!" will be added by Powerbase if you don't include it yourself) and drag the icon to a suitable directory.

Powerbase is now in design mode and the record window is covered with a blue grid to help in laying out the fields. Clicking MENU over this opens a menu different from the one you will have seen previously. Most of the entries will be shaded at this stage, but the one we want is Create field. When you choose this the rather complex Field definition window opens.

create

A lot of the window is shaded at this stage and much of the rest can be ignored for the present — we did say a simple database — so leave the Editable radio button selected and the field-type as Unrestricted. We're going to call the first field Name so type that into the Descriptor icon. Anything you enter there will appear on the record screen as a label for the field. Very important is the Tag which is used to identify a field uniquely. It is limited to 4 characters and we might as well use NAME. (Uppercase is recommended for tags to distinguish them from descriptors.) How long might a name be? 20 characters ought to be enough so enter 20 in Data length.

Click on Create and there's the first field. Easy! But it's not in the right place, is it? So point the mouse at the white rectangle and drag with SELECT until it's where you want it.

We now need several fields for the address; four ought to be enough. The first will obviously have the Descriptor Address but the layout looks neater if the other three are just aligned underneath without descriptors. This is quite permissible; descriptors are optional. Tags, however, are not optional and you can now see why; if a field had neither Descriptor nor Tag there would be no way of querying it by means of a search formula. Create four fields with tags ADD1, ADD2, ADD3 and ADD4. Make them all 20 characters long and drag them so that they line up neatly underneath each other.

That's enough for the present. Click MENU and choose Default database. You will be asked to confirm that Powerbase is to create 100 records with NAME as the primary key field. The first four letters of the field will be used to make up the key unless the field is shorter than that, which it isn't in this example. That sounds acceptable (and can be changed later) so accept the suggestion — and there's your database all ready for you to type data into! This illustrates just how easy Powerbase can be for a beginner, but there are loads of refinements for you to use when you are more used to the program. Go ahead and enter a few records before proceeding to the next stage.top of page

9 Adding other fields

Oh dear! We left something out! There should be a field for the telephone number. And, while we're at it, it would be nice to have a field for general notes too. Here's how these fields can be added without losing any data you might have already entered.

Click MENU on the iconbar icon and choose Utilities=>Alter format. First comes a message telling you what to do next (and what to do if you change your mind) then up comes the blue grid again with your record design displayed. Choose Create field from the menu again.

For the phone number we want an Editable field and we might as well make it Numeric since it's numbers we'll be storing in it. (Although it doesn't really matter; we aren't going to attempt any calculations on phone numbers!) Click the menu button at the top-right corner and choose Numeric. Enter a suitable Descriptor, Tag and Data length, e.g. Phone, TEL and 12. Click on Create and position the field beneath the address.

Now for the Notes field. Most records won't require any additional notes at all but a few may need quite a lot of extra information. How do we decide how much space to allow? There's a way of avoiding the problem altogether. Choose Create field from the menu again but this time select the External radio button. The field-type at top right will now be showing Text instead of Unrestricted. Enter Notes as the Descriptor and NOTE as the Tag. What about the Data length? It's shaded to stop you entering anything. Never mind, you'll soon see why. Click Create and what do you get? Not a white rectangle but a little square button with a small Edit icon on it! Drag it to where you want it and then bring up the main menu. This time it's the final choice, Quit design, which is needed. The message "Reformatting database" appears briefly then we're back in normal data-entry mode.

Now click on the little Notes button. Assuming RISC OS knows the whereabouts of a text editor (and it should at the very least be able to find Edit) a text window will open. Initially it merely contains "Record 0:" but this is for information only and you may delete it if you wish. You can type whatever you like and as much as you like into this window. When you've finished, close the window in the usual way and the editor will prompt you to save the file. Just accept whatever filename is offered and click Save; Powerbase knows where the file should go. Try adding notes to several records and notice how the button changes to a text-file icon when you do so. On returning to these records, clicking the button with SELECT brings up the associated text for editing. The notes you enter are stored as a separate text file for each record, these text files being stored within the database application. "Ordinary" fields like the Name, Address and Phone fields are stored in a large text file called Database but the field you've just added occupies no space in Database at all, which is why we call it an External field and why you weren't expected to assign a Data length to it.top of page

10 Changing the primary key

When you created the address database by choosing Default database you left the choice of primary key to Powerbase. The result of doing this is always a key consisting of the first four characters of the first writable field, in this case the first four letters of the Name field. This is a fairly primitive key-structure, even for such a simple database. Let's assume you're storing the names surname first. If many of the names in your database are of family members some of them are going to have the same key. A much better choice of key would make use of both surname and given name, so let's change our primary key to do that.

pri key

Go to the Utilities submenu on the iconbar and choose New primary key. This displays the Key definition window which tells us that the structure of the key is the four Leftmost characters of the first word in the field whose tag is NAME. It is possible to change all four of these bits of information: the field, the word, the position in the word and the number of characters. You will see also that there is space for three other similar sets of information; in other words you could derive the key from up to four different fields or words.

Leave the first line as it is and click once on the down-pointing "bump" icon on the second line. The Field icon should now read NAME like the first, the rest of the line reading 1, L and 20 (the maximum length of this field). Change the word to 2, leave the position as L (other choices are R, for "right" or a number indicating where the first character comes from). Change the length to 2 and click Create. Powerbase now asks: "Build index with records in same subfile of current database?" Tell it to proceed and the new primary key index will be created.

Looking at the keys as they appear in the title bar of the record window, you will see that they are now six, instead of four, letters long and that they consist of the first four letters of the surname plus the first two of the given name, thus distinguishing (most of the time) between people with the same surname, e.g. "Fred Bloggs" would have the key BLOGFR.top of page

Home   Quick Tutorial    Reference Manual