Data dictionaries

A data dictionary is required for every Sculptor keyed file used in an application. The data dictionary defines all the file’s fields in the order in which they are to be stored, forming a record layout. Each field must be assigned a name, type and size. Secondary indexes may also be defined for the purpose of accessing the data in a different sequence or by different search data. These secondary indexes are updated and maintained automatically by Sculptor.

Data dictionaries are created using the Sculptor program ddeditor, which enables the precise structure of the keyed file to be defined. Each field that is to be included in the record structure is specified in detail, including:

Key/data

Indicates if the field is a key field or a data field.

Name

The name of the field.

Heading

A default heading for screen display and printing.

Type

The field type - alphanumeric, integer, floating point, etc.

Size

The number of bytes to be allocated to the field.

Dimension

Allows a field to be subscripted in up to four dimensions.

Format

The appearance and layout of the field for display and printing.

Validation

The values or value ranges which are valid for input into the field.

Help

A free format text line for on-line help.

The data dictionary is used by the newkf program, which creates a new, empty keyed file with the size and field structure specified. The newkf program must be run on the data dictionary before the file can be used in a Sculptor program.

The data dictionary is also used by the program compiler scc when compiling a program that uses the file.

If the data dictionary is amended and the file contains records, it may be necessary to run the reformat and kfbuild programs to update the existing data. See Changing an existing data dictionary for full details of the changes which require these utilities to be run.


Printing a data dictionary

A summary of the information contained a data dictionary can be printed by means of the File->Print menu option in ddeditor. The user can specify whether full details or a compact summary are to be printed, and whether or not secondary indexes are to be included.

Additionally, a summary of a file’s data dictionary information can be printed by means of the Sculptor utility pdes.


Retrieving information about a data dictionary within a Sculptor program

A set of functions is provided for this purpose. They are:

FieldProp()

Return details of a specified field in a data directory

IndexFieldProp()

Return details of a specified field in a secondary index

OpenDotd()

Return general information about a data dictionary file

OpenIndex()

Return general information about a secondary index


Changing an existing data dictionary

If certain changes are made to the data dictionary of an existing file which contains records, it may be necessary to do one or more the following:

1

Reformat the data files, modifying the existing data to fit the new layout. This is necessary if changes have been made which affect the physical structure of the file. A reformat is done by means of the Sculptor utility reformat. This program rebuilds secondary indexes automatically.

2

Recompile all programs which declare the file, using the compiler scc. This must always be done if the file has been reformatted.

3

Build secondary indexes which have been added, or rebuild indexes to which structural changes have been made. This is done by use of the Sculptor utilities kfri or kfbuild.

The Sculptor File Manager can be used to run all these utility programs.

The tables below summarise the measures which must be taken if changes have been made:

  1. Primary index

    Change

    reformat

    recompile

    Field inserted, moved or deleted

    yes

    yes

    Type or size

    yes

    yes

    Dimension

    yes

    yes

    Logical type

    yes

    yes

    Name

    no

    yes

    Field changed from key to data or vice versa

    yes

    yes

    Field heading, format or validation *

    no

    yes

    Help text *

    no

    yes

    Others

    no

    no

  2. Secondary index

    Change

    rebuild

    recompile

    New index added

    yes

    yes

    Field inserted, moved or deleted

    yes

    yes

    Type or size

    yes

    yes

    Element

    yes

    yes

    Name

    yes

    yes

    Format *

    no

    yes

    Open status

    no

    yes

    Others

    no

    no

* If these are the only types of changes which have been made, the program will still operate without recompilation, though the changes will not be reflected until the program is recompiled.

If any of the changes which require a reformat or a kfbuild are made on an empty data dictionary - that is, one which has had the newkf program run on it to create new empty files, but into which no records have yet been inserted - the newkf program must be run again to create new empty files matching the new file layout.


RELATED TOPICS

Data dictionary editor

Data fields

Keyed files

Keyed file utilities

Automatic program generation