Upload
lesley-chase
View
212
Download
0
Embed Size (px)
Citation preview
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 132.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
Index High Key
1 1000
2 2000
3 3000
4 4000
5 5000
Address Key
5212 3101
5212 3102
5212 3103
5212 3104
5213 3105
5213 3106
Index High Key
72 3100
73 3200
74 3300
75 3400
76 3500
77 3600
4
Searching for 3105
73
Page 13
4. • 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.