Creating Data Items

It is important to establish the sequence of attribute values and subvalues in a data file item.

The table below shows the contents of the Attribute Definition items in the CUSTOMERS dictionary.

Item-ID

FIRST-NAME

LAST-NAME

STREET

CITY

STATE

PHONE

D/CODE

A

A

A

A

A

A

A/AMC

1

2

3

4

5

6

S/NAME

First Name

Last Name

Street

City

State

Phone

V/CONV

 

 

 

ML(###-###-#### ####)

V/CORR

 

 

 

 

 

 

V/TYP

L

L

L

L

L

r

V/MAX

7

12

20

10

2

17

The Attribute Definition items shown in the table above describe a data file item format consisting of six attributes. The attribute number (A/AMC) references the sequential location of attributes in the data file item.

You have previously seen the CUSTOMERS dictionary that describes the format of items in the CUSTOMERS data file. The following is an example of an item from the CUSTOMERS data file.

AEDWA5224

001 ANTON

002 EDWARDS

003 51 BLAIR AVENUE

004 SUDBURY

005 MA

006 6178897764 223

The item-ID of this attribute is AEDWA5224. The CUSTOMERS file uses an alphanumeric 9-character item-ID that is constructed when the item is created. It is built from the first letter of the customer’s first name, the first four letters of the last name, and an integer representing the date (as stored in internal format) that the item was created. For example, the data item for a customer named Amy Orlando has the following item-ID:

AORLA5993

The date in internal format is 5993; if the date were converted to a normal date format, it would be 28 MAY 1984. Item-IDs such as these are constructed by the application program when a new customer is added to the database.

Each line in the data file item is a separate attribute. Attribute 1 contains the first name, defined by the Attribute Definition item FIRST-NAME in the CUSTOMERS dictionary. Attribute 2 contains the last name, defined by the Attribute Definition item LAST-NAME, and so on.

Assigning Item-IDs

The item-ID allows us to locate the specific item of a customer. The item-ID is a piece of data that must be unique for each customer in the file. For instance, a person’s last name is not a unique identifier. For that reason, sequential numeric item-IDs are often used to insure that the ID is unique. Another benefit of numeric IDs is more even distribution of items across groups. While nothing prevents the user from using alphanumeric keys, a key should not be based on information that is likely to change.

When you have defined the structure of the database in the dictionary, you can create items in the data file.

A simple database containing a small amount of data can easily be created using the Editor. The Editor does not supply prompts or validate input. The user must input the data in the correct order as defined in the dictionary. The following table lists the key sequences for entering system delimiter characters.

Mark

Input in Editor

Attribute

ENTER or CTRL-^

Value

CTRL+]

Subvalue

CTRL+\

A Proc could be written to automate data entry via the Editor, prompting for the data and submitting a series of Editor commands to create a new item and insert multiple lines.

Most applications rely on custom mvBASIC programs for data entry. A typical data entry program prompts a user to supply data and verifies the input before adding a new item to the database. The user can write a generalized data entry program that could be used to create items for any database. Such a program uses a phrase entry in the dictionary to identify the attributes which the user is prompted to enter. If sequential numeric IDs are used, an entry in the dictionary is used to store the last ID number used.

See Also

Creating a File

Selecting a File Name

Selecting a Modulo

Using CREATE-FILE

Creating Dictionary Entries