TOPIC 4.3: DATA MANAGEMENT

ORGANISING FILES

Files stored on magnetic media can be organised in a number of ways, just as in a manual system.

There are advantages and disadvantages to each type of file organisation, and the method chosen will depend on several factors such as:

- how the file is to be used;

- how many records are processed each time the file is updated;

- whether individual records need to be quickly accessible.

TYPES OF FILE ORGANISATION

The available methods include:

1) Serial

2) Sequential

3) Indexed Sequential

4) Random

SERIAL FILE ORGANISATION

USE OF SERIAL FILES

SEQUENTIAL FILE ORGANISATION

 

 

ADDING AND DELETING RECORDS ON A SERIAL FILE

ADDING AND DELETING RECORDS ON A SEQUENTIAL FILE

USE OF SEQUENTIAL FILES

MERGING TWO SEQUENTIAL FILES

Perennial File (A) Pot Plant File (B)
111 Fragrant dianthus

112 Dwarf shasta daisy

117 Bellflower

171 Bee balm

200 Dwarf aster

201 Geranium

203 Swallow-wort

156 Patio Dahlia

185 Cape Fuschia

187 Hanging Carnations

266 Begonia

268 Marguerite

 

 

Procedure Merge

   Read a record from File A

   Read a record from File B

   Repeat

     If Key_of_A < Key_of_B then

         write Record A to File C

         if not end-of-file A read another record from File A

         else set Key_of_A to HighValue

        endif

     else write Record B to File C

        if not end-of-file B read another record from File B

        else set Key_of_B to HighValue

        endif

     endif

  until no more records on either file

INDEXED SEQUENTIAL FILE ORGANISATION

cylinder hi-key
0

1

.

.

19

20

21 **

.

.

199

193

346

...

...

4382

5495

6608

...

...

49999

Searching this index, the first number which is greater than or equal to 5584 is 6608. This shows that our record, if it exists, is on cylinder 21.

Thus, the read/write heads are moved to cylinder 21. On arrival, the surface index is located on surface 0 and is read:

surface hi-key
0 5510
1 ** 5622
2 5843
. ...
. ...
7 6608

This means that record 5584 should be on surface 1, so the read head for that surface is activated.

The sector index located on sector 0 of cylinder 21, surface 1 is then read:

sector hi-key
0 5521
1 5538
2 5560
3 5568
4 5583
5 5597
6 5606
7 5622

This tells the system that the record with key 5584 should be in sector 5, so that sector 5 is read into main store. it will then be serially searched until the correct record is located. If it is not found, then

All this disk accessing and searching is time consuming, but still much faster than a serial search of a sequential file for finding an individual record. However the indexes take up quite a lot of space, and this is a disadvantage of indexed sequential organisation. The major advantage of this file organisation is that it can be processed either randomly using the indexes, or sequentially without using the indexes.

OVERFLOW

        1. a home area where the records are initially stored.

        2. One or more index areas set aside to hold the indexes.

        3. One or more overflow areas to hold records that are added at a later date and will  not fit in their correct home sectors or blocks.

BLOCKS

        - making file access as quick as possible;

        - dealing with additions and deletions to the file as efficiently as possible;

        - making the most efficient use of storage space.

FILE REORGANISATION

INDEXED FILES ON FLOPPY DISKS

USE OF INDEXED SEQUENTIAL FILES

RANDOM FILES

        75481/997 = 75 remainder 706. Address = 706.

USE OF RANDOM FILES

SYNONYMS

FIXED AND VARIABLE LENGTH RECORDS

In some circumstances records in a file may not all be the same length. Variable length records may be used when either

A variable length record has to have some way of showing where each field ends, and where the record ends, in order that it can be processed. There are two ways of doing this;

SH12345*laser printer * QMS PS410*750.00*999.99*7#
MH452*colour flatbed scanner*Microtek Scanmaker II*150.00*289.00*3#
8SH1234514aser printer 10 QMS PS4105750.005999.9937#
6MH45223colour flatbed scanner22Microtek Scanmaker II5150.005289.0033#

The advantage of allowing variable length records is that it is more economical in terms of disk storage space. The advantage of fixed length records is that they are simpler to process, and allow an accurate estimate of storage requirements. When held in a direct access file, fixed length records can be updated because the new record will occupy exactly the same amount of space as the old record.


RESOURCE: P M Heatcote, [A Level Computing, 3rd. Edition], Letts Educational Ltd., 1998.

Hosted by www.Geocities.ws

1