Home  Back Topics CD Orders  INDEX 
File Update
The data on a transaction file is used to update some of the fields on a master file.

The transaction file must be sorted in the same order as the master file.

 

This is generally done in a batch processing system where the transactions are recorded on the transaction file and later used to update the master file.
How it works (in words) :
  1. A new master file is created.
  2. For each transaction record, the records of the master file are read and written onto the new master file until a matching record is found.
  3. The data is updated and the record written onto the new master file.
  4. When the last transaction record has been processed, the remaining records on the master file are read and written onto the new master file.
How it works (System flowchart) :

 

Here, the transaction and master files are stored on magnetic tape and used as input for the update process.

All updated (and unaltered) records are stored on the new master file.

 

Example :

A master file of stock is kept for a clothes shop. Some of the records are shown in this table :

ID Garment Price No Sold this year
305 Sweater (Red) £25.00 12
308 Sweater (Blue) £25.00 8
309 Shorts (Size 12) £12.00 14
315 Shorts (Size 14) £12.00 9
316 Socks(Grey) £1.99 34
317 Socks(Black) £1.99 28
The key field is the ID field.

The master file in practice would have many more fields than this ...and many more records!

Todays transactions are shown in the transaction file below....
ID No Sold today
305 3
309 1
316 2
317 1
The transaction file must be sorted in the same order as the master file (using the key field)
The resulting new master file is shown in the next table :
ID Garment Price No Sold this year
305 Sweater (Red) £25.00 15
308 Sweater (Blue) £25.00 8
309 Shorts (Size 12) £12.00 15
315 Shorts (Size 14) £12.00 9
316 Socks(Grey) £1.99 36
317 Socks(Black) £1.99 29
The updated data is shown in red. Note that some records will have remained unchanged.
Exercise :
The contains all the main data for a system. A contains recent data which is used to update the master file.

A is created onto which the updated or unchanged records are written. The old master file can then be archived.

The transaction file must be before the update process takes place.

 

(Green indicates success)