Fixed length records

A file where each records is of the same length is said to have fixed length records.

Some fields are always the same length (eg Postcode is always 7 characters).

 Some fields may need to be 'padded out' so they are the correct length 
(eg Surname - If 15 characters are stored then Jenkins would be stored as 'JENKINS        ' - 7 characters followed by 8 spaces).

Advantage : Access is fast because the computer knows where each record starts. It follows that processing all the data in a file will be fast.

Eg If each record is 120 bytes long then

  • the 1st record starts at [Start of File] + 0 bytes
  • the 2nd record starts at [Start of File] + 120 bytes
  • the 3rd record starts at [Start of File] + 240 bytes etc.....

Disadvantage : Using Fixed length records, the records are usually larger and therefore need more storage space and are slower to transfer (load or save) or transmit down a network.

Example : Any information retrieval system (Eg Train time-table program) where information needs to be accessed quickly.

 

 

In the Example

NUMBER SURNAME FORENAME YEAR FORM DOB
92013 JONES Sidney 12 B 23/04/78
92107 LAIDLAW Lorraine 12 Y 12/11/79
92114 MERRITT Mandy 12 G 08/03/79
92167 NASH Natasha 12 B 19/08/78

...the field lengths (in bytes) may be defined as ...

Number : 5
Surname: 15
Forename: 15
Year: 2
Form: 1
DOB: 8

Each record would be 46 bytes long.

The first record of the example file would be stored as ...(each box represents one byte of storage)..

9 2 0 1 3 J O N E S                    
S i d n e y                   1 2 B 2 3
/ 0 4 / 7 8