Fixed Length Fields

A fixed length field is one which contains a set number of characters.

With fixed length fields, the fields may need to be padded out to the right length, eg with <space> characters.

eg If a Surname field is set at 10 characters then the name SIMPSON would need 3 <Space>s added on to the end of it.

Advantage - Every record is the same size, so it is possible for the computer to calculate exactly where each record starts in the file and therefore it is quicker for the computer to find a particular record.

Example 1

Each record of this file has 4 fields.

Number Surname FirstName Form
91230 Sam Fenella B
91231 Sanders Michael G
91232 Saunders Ian B
91233 Sealey Kelly R
91234 Shaw Lucy S
91235 Shaw Oliver N

The field sizes may be fixed at ...

Field Name Field Size
Number 5
Surname 10
Firstname 10
Form 1

The first three records of the file would therefore be stored as in the following table (each square represents one byte):

9 1 2 3 0 S a m               F e n e l
l a       B 9 1 2 3 1 S a n d e r s    
  M i c h a e l       G 9 1 2 3 2 S a u
n d e r s     I a n               B    
                                       

Each record takes up 26 bytes of storage space.

The first three records of the file take up 78 bytes of storage.

 

Exercise : Fixed Length fields
If fixed length fields are used, each field size . The fields may need to be padded out with extra characters.

Advantages :

Disadvantage :

 

(Green indicates success)