Manipulating Existing Data

The BOOK-CATALOG file describes the inventory for the mail-order publishing business. The table below shows the contents of three of the Attribute Definition items in the BOOK-CATALOG dictionary.

Item-ID

AUTHOR

TITLE

PRICE

AMOUNT

D/CODE

A

A

A

A

A/AMC

1

2

3

0

S/NAME

Author

Title

Price

Amount

V/CONV

 

 

MR2$

MR2$

V/CORR

 

 

 

A;N(QTY)*N(PRICE)

V/TYP

L

T

R

R

V/MAX

20

20

8

10

The preceding Attribute Definition items describe the structure of a BOOK-CATALOG data file item. For example, the data item for the book whose code is N01 contains the following information:

>LIST-ITEM BOOK-CATALOG 'N01'

 

 N01

001 STRANG

002 OPERATING SYSTEM CONCEPTS

003 2000

The data stored in the BOOK-CATALOG file is relatively stable (the prices of the books might change, but the book titles and authors remain the same). It makes sense, therefore, to maintain inventory information in this file and to reference (not duplicate) it in the ORDERS file.

The dictionary entry for AMOUNT contains a correlative used to derive its value by manipulating other values in the database. The correlative A;N(QTY)*N(PRICE)) multiplies the data in two other numeric attributes in the ORDERS file to derive the data for AMOUNT. Specifically, this correlative multiplies QTY by PRICE.

The A code is used to specify the processing. The N function identifies the attribute by name. Attributes can also be referenced by AMC. For example, A;2*3 multiplies the value of Attribute 2 by the value of Attribute 3. The expression A;2*"3" multiplies the value of Attribute 2 by the number 3. In other words, the amount of sale is determined automatically by multiplying the number of books ordered by the price of a single book.

See Also

Deriving Data from Attributes

B Code

C Code

Extracting Data

S Code

Testing Data