Page 13 1.a) A block is a group of records. A block is referred to as the UNIT of TRANSFER In computer files as when a record is searched / updated the whole block containing the record is transferred to main store (not just the record) b) Blocks are used to save time. They save time in 2 ways It is quicker to search in main store, therefore the more data that can be placed in main store (rather than disk) the quicker it is to search The Indexes can be smaller thus making them quicker to search Block size is limited by the amount of main store available
Page 13 2.a) The payroll file is an Indexed sequential file, this means it can be accessed in 2 ways i)sequentially – when all records need updating - In the monthly pay run the transactions (time Information) would be merged with the main file sequentially to create a new (updated) main file and printouts of payslips ii) Using the index – when few records need updating – If something someone's record changes e.g. address For a monthly payroll run option 1 would be best because all records are processed
Page 13 2.b) The record needs to be inserted into the correct place because the file is organised sequentially The key of the record is compared to the primary index. This locates a secondary index The key of the record is compared to the secondary index. This locates a tertiary index The tertiary index locates the block where the record needs to be added This block is loaded into main memory. The record is inserted and the indexes are updated to show that the record is now there. (if there is not sufficient room for all of the record in this block then some of the data is placed in an overflow area on disk and a pointer is inserted to show this) The block is written back to the appropriate location on disk
Page 13 2.c) The key of the record is compared to the primary index. This locates a secondary index The key of the record is compared to the secondary index. This locates a tertiary index The tertiary index locates the block where the record needs to be added is found The block containing the record is read to main store. The block is quickly searched in main store and the record found
Page 13 3.a) A hierarchy of indexes is when a very large index is split into different levels A Primary index is used to load a secondary index which locates and loads a third index. The third index points to the address in the file of the block containing the record
Example of a Hierarchy Index Structure IndexHigh Key AddressKey IndexHigh Key Searching for
Page Over time a large file will become ‘untidy’ and inefficient. This can be due to gaps left by deleted records or overflow from inserted records A Housekeeping routine is used to rewrite the file and reorganise the indexes, getting rid of gaps left by deleted records and removing overflow by reorganising the blocks.