140 likes | 223 Views
Data Structures. Index Sequential Files. Learning Objectives. Explain Indexed Sequential Searches. Access Methods to Data. Computers can store large volumes of data. The difficulty is to be able to get it back.
E N D
Data Structures Index Sequential Files
Learning Objectives • Explain IndexedSequential Searches.
Access Methods to Data • Computers can store large volumes of data. • The difficulty is to be able to get it back. • In order to be able to retrieve data it must be stored in some sort of order. • There are a number of ways of arranging the data that will aid access under different circumstances.
Batch Processing Examples • Printing out statements or bills for all customers. • Printing out pay slips for all workers.
SequentialVRandom Advantage: Fast and immediate direct access because application of a hashing algorithm on the unique field of a particular record gives exact address of the record. Disadvantage: No order so unsuitable for batch processing as records could be missed out because there is no concept of a first or last record. Advantage: Logically ordered so suitable for batch processing as no records can be missed Disadvantage: Only approximate location of a particular record can be found so slow access. Sequential Access Files Random Access Files Increasing Search Speed for a particular record.
Batch Processing and Fast Access • If we want a file which requires batch processing and fairly fast immediate direct access then we use … • See next slide.
Indexed sequential Access File • A sequential file split up by using indexing into what amounts to a number of smaller sequential files.
Indexed sequential Access • Data is accessed sequentially but is indexed. • e.g. Looking up names and numbers in a phone book. • To look up Jawad, a J is found in the table which gives the page number 232, the search is then started at page 232 (where all the Js will be stored). • Faster than ‘normal’ sequential access as the computer knows exactly where to start looking.
Indexed sequential Access File Example • The account numbers for a bank’s customers are used as the key to access the customer accounts. • The accounts are held sequentially and there are approximately 10 million accounts. • There are 7 digits in an account number. • Indexes could be set up which identify the first two digits in an account number. • Dependent on the result of this first index search, there is a new index for the next two digits, which then points to all the account numbers, held in order, that have those first four digits.
Indexed sequential Access File Example • There will be one index at the first level, but each entry in there will have its own index at the second level, so there will be 100 indexes at the second level. • Each of these indexes will have 100 options to point to, so there will be 10,000 blocks of data records. • But each block of records will only have a maximum of 1000 records in it, so adding a new record in the right place is now manageable which it would not have been if the 1million records were all stored together.
Indexed Sequential Access Files Used: • Faster access than ‘normal’ sequential access and suitable for batch processing.
Plenary • Explain IndexedSequential searches.
Plenary • IndexedSequential Access • Data is accessed sequentially but is indexed.