FILES

FILES

FILES

A file is an organized collection of related records.

In computing a file is usually on backing store but the term can be used for data being input or output.

A record is a group of related items of data which together can be treated as a unit. The records are usually similar to one another in the type of data they contain and the way they are set out.

A field is an area of a record reserved for one particular type of data. Each field contains one, or possibly more, data items.

An item of data here means the smallest piece of data that would be dealt with separately­ a single name or a single number, etc.

Examples of files, records, fields and items

1 Each record of a file of student records has the following fields:

Surname Forenames Date of Birth Address One of the records is:

WALTERS DAVID ANDREW 21/02/75 3, BURNSIDE GARDENS, BISHOPSWICK The Date of Birth field contains the item 21/02/75.

2 A payroll file of a firm's employees. One record would be all the data on one employee. The separate items in a record could include the employee's (a) works numbers, (b) name (c) tax code, etc.

3 A file stored on the Police National Computer giving data on stolen cars. One record would be all the data on one car.

The items in a record could include the car's (a) registration number, (b) legal owner, (c) make, (d) colour, etc.

4 Any organized collection of data held on backing store. The following can be regarded as files:

(a) A computer program.

(b) A piece of text stored by a word processor.

S Ally organized set of data even if it is not on a computer medium, for example, a set of index cards in a doctor's surgery. Each record is the data on one patient. The items consist of the patient's name, history of symptoms and treatment.

REASONS FOR USING FILES

Files can be used:

1 In any situation requiring a permanent source of data which is readily accessible.

2 In a computer when the main store is too small for the amount of data being processed.

FIXED AND VARIABLE LENGTH FIELDS

Fields may be of fixed length or variable length.

If the fields are of fixed length then a given field in a record has a set number of character positions reserved for it.

If the fields are of variable length, the number of characters in each is not determined beforehand.

Advantages of variable over fixed length

There is no waste of storage space (there is wastage for fixed length fields because a given field has to be as long as the longest item to go in it, and space is wasted for short items).

Advantages of fixed over variable length

1 Computer operations such as searching can be carried out quickly.

2 Allocation of storage space is more straightforward.

3 Updating of files is simpler-if one record is changed it still takes up the same amount of space, so that other records do not have to be moved to make room for it .

Keys

Usually one particular field of each record of a file contains an item which is used to identify the record uniquely. This field is called the key field, and the item in it is called the key to that record. In a file the keys must all be different from one another, so that there is no confusion over which record is which.

Examples illustrating field lengths and keys

1 A stock file for the sales department of a garden centre. The fields are fixed length and are as follows:

Field

Number of characters

catalogue number

6

name of plant

20

minimum height (feet)

2

maximum height (feet)

2

price (pence)

5

number in stock

3

The key field is catalogue number and the records are in the order of these keys. Four of the records are as follows:

002103ABIES GEORGEI

2

3

250

23

002104ABIES GEORGEI

3

4

350

14

002113ABIES GRANDIS

2

3

250

3

002114ABIES LASIOCARPA

3

4

420

6

 

2 A BASIC program stored on a floppy disc is an example of a file e.g.

20 FOR I=1 TO 20

30 PRINT N$

100 NEXT I

Here each record is a line of the program. It has two variable length fields-the line number and the BASIC statement.

The key item is the line number and is used by the computer to search for a line when editing or running the program .

Labels: