Computers: Universe: Dictionaries

Dictionaries have been mentioned in passing several times in earlier sections without a full explanation of their use: we will now examine them in detail.

To begin with, whenever you create a UniVerse file, you are actually creating two files: a data file, and a dictionary file. The terminology here is somewhat confusing at first until you get used to it. Let's say you create a file called CUSTOMER.INVOICES. The term file is used to refer both to the thing you've created (ie. the CUSTOMER.INVOICES file, complete with data and dictionary portions), and to the data file and dictionary file individually. You get used to it.

Let's try this as an example:

>CREATE.FILE CUSTOMER.INVOICES DYNAMIC
WARNING: An operating system file will be created with a truncated name.
Creating file "CUSTOMER.001" as Type 30.
Creating file "D_CUSTOMER.001" as Type 3, Modulo 1, Separation 2.
Added "@ID", the default record for RetrieVe, to "D_CUSTOMER.001".
>

As you can see, there are two 'Creating...' messages. The first refers to the creation of the data file (which has a UNIX filename of CUSTOMER.001), and the second to the creation of the dictionary file (which has a UNIX filename of D_CUSTOMER.001). This makes it clear that the files are physically entirely separate. They are associated by the F (file) type VOC record CUSTOMER.INVOICES, the second field of which points to the data file CUSTOMER.001, and the third line of which points to the dictionary file D_CUSTOMER.001 (see File Pointers). When you use the word CUSTOMER.INVOICES in a UniVerse command, UniVerse consults the VOC file and therefore knows where to find both the data and dictionary files.

In the data file, each record represents an invoice, and be 'keyed' by the invoice number. The fields of each record would each carry some piece of information about an invoice. While a real invoicing file might have hundreds of such fields, a simple layout for the purposes of illustration might run:

Key

Invoice number

Field 1

Customer name

Field 2

Product description

Field 3

Unit price

Field 4

Quantity invoiced

You could start entering these records simply by using the editor. Try the examples below (for the sake of argument, we'll assume the pricing is in €uros):

>ED CUSTOMER.INVOICES 0001
New record.
----: I
0001= ACME Widgets Limited
0002= Castellated Grommets
0003= 10.38
0004= 2000
0005= (Press RETURN)
Bottom at line 5.
----: FI
"0001" filed in file "CUSTOMER.INVOICES".
>ED CUSTOMER.INVOICES 0002
New record.
----: I
0001= Universal Thingies Inc.
0002= Revolving Stud Pins
0003= 427
0004= 7
0005= (Press RETURN)
Bottom at line 5.
----: FI
"0002" filed in file "CUSTOMER.INVOICES".
>ED CUSTOMER.INVOICES 0003
New record.
----: I
0001= Imperial Exporters plc
0002= Galvanised Retention Sprockets
0003= 38
0004= 104
0005= (Press RETURN)
Bottom at line 5.
----: FI
"0003" filed in file "CUSTOMER.INVOICES".

As you can see, you were able to create the file and enter records without a dictionary. So why do you need a dictionary?

Their primary use is to explain the structure of their records to the Retrieve enquiry language. This language is explained in detail later (turn to The Retrieve Query Language), but a few simple examples will be used here to illustrate the use of dictionaries.

Let's say you wanted to enquire on the records you had just entered. The simplest way to do this would be to use the LIST command. Try this:

>LIST CUSTOMER.INVOICES

LIST CUSTOMER.INVOICES 11:51:31 08-06-99 PAGE 1
CUSTOMER.INVOICES

0001
0002
0003

3 records listed.
>

This is fine as far as it goes: you have a complete listing of the keys of the records you entered on your screen. But to show the contents of those records, you must define dictionary records. The following sections describe the different types of dictionary record, how to create them, and how they are used.