Master and Transaction File

A PowerPoint presentation showing the principle of master & transaction files

Master file
Holds descriptive data; the actual data that is supposed to be processed and holds the resultant data after the process is completed (ex. names, addresses, sales, etc.). The data can be organized using keys.

Transaction file
Contains the transactions; changes that are supposed to be made to the data in the master file.
  • In batch processing all transactions are collected in the transaction file and the changes are applied to the master file sequentially in a single pass. For this to be possible, both the master and transaction file have to be sorted first.
  • In an online system the changes are applied to the master file the moment the transactions occur or are recorded.

Key - Unique identifier for a record.

Algorithm to update the Master file
  1. Order transaction file by key.
  2. Create new master file.
  3. Compare first keys in master file to first key in transaction file.
  4. Continue this until end of both master and transaction file.
    1. Apply any changes defined by the transaction file to the record.
    2. Write the record with the lowest key to the new master file.
    3. Go to the next record in the original master file and the transaction file.
    4. Compare keys as in step 3.
  5. Close all files.
oldmaster.png
Example how the master & transaction file could work


Edited by Jocbe
Last update: 8. November 2010

Sources: