Indexed Sequential files

Each record of a file has a key field which uniquely identifies that record.

An index consists of keys and addresses (physical disc locations).

An indexed sequential file is a sequential file (i.e. sorted into order of a key field) which has an index.

A full index to a file is one in which there is an entry for every record.

 

 

Indexed sequential files are important for applications where data needs to be accessed.....

  • sequentially
  • randomly using the index.

An indexed sequential file allows fast access to a specific record.

Example: A company may store details about its employees as an indexed sequential file. Sometimes the file is accessed....

  • sequentially. For example when the whole of the file is processed to produce payslips at the end of the month.
  • randomly. Maybe an employee changes address, or a female employee gets married and changes her surname.

An indexed sequential file can only be stored on a random access device
eg magnetic disc, CD.

 

 

Multi-level indexes

A multi-level index is one where the index is too large and so is split into a number of separate indexes. There would then be an index for these indexes! In fact, a number of different levels of index may exist.

 

 

An example of a multi-level index.

The first level of index may look like this.

High Key Address(Index)
1000 1
1500 2
2000 3
2500 4
3000 5

Suppose we are searching for a record with key field 2354. The computer searches sequentially down the keys until it finds the first key which is greater than 2354. This would be 2500 and the computer would now need to look at ....

Index 4....

High Key Address(Index)
2100 10
2200 11
2300 12
2400 13
2500 14

A similar process,searching through the keys for one greater than 2354 shows that the computer should now look at ...

Index number 13...

High Key Address(Index)
2310 60
2320 61
2330 62
2340 63
2350 64
2360 65
2370 66
2380 67
2390 68
2400 69

...and lastly index 65...

Key Address
2351 781040
2352 781041
2353 781042
2354 781043
2355 781044
2356 781045
2357 781046
2358 781047
2359 781048
2360 781049

...so the record with key 2354 would be found at address 781043.