Presentation is loading. Please wait.

Presentation is loading. Please wait.

Methods of Access Serial Sequential Indexed Sequential Random Access

Similar presentations


Presentation on theme: "Methods of Access Serial Sequential Indexed Sequential Random Access"— Presentation transcript:

1 Methods of Access Serial Sequential Indexed Sequential Random Access
Need to show advantages, disadvantages, characteristics and applications suitable for each

2 Serial When the items are read/written one at a time from the physical start of the file Slow access to individual items of data Must read all records to know if the one you want is missing Useful for storing transactions as they occur Log files Shop transactions

3 Sequential This is where the items are read, one at a time, from the logical start of the file, in key order. Similar to serial access, but sorted Slow access to individual items of data However, if you come to a record greater than the one you are searching for, you can stop looking Useful when all records need to be accessed updating payroll at the end of every month where every record needs to be accessed Sending out statements or bills to all customers

4 Indexed Sequential Indexed records of a sequential file
This allows both indexed and sequential access techniques to be used Direct access to the file is required For example: To locate “Smith” and index is searched to find the location of the first item beginning with “S”. The pointer moves to this location and then the file is searched sequentially. Useful for monthly access to all records (payroll) selective access to few address changes

5 Indexed Sequential – Multiple Indexes
Sometimes a file is too large to be searched quickly by using one index In this case a set of indexes is used For example: To locate “Smith” an index is searched to find the location of an index for items beginning with “S” The pointer moves to this location and the new index is searched to find the location of the first item beginning with “Sm” The file is searched sequentially There may be several indexes, depending on the file size

6 Random Access Any item can be retrieved almost immediately, provided its position in the file is known. (there is a delay in calculating the address and then moving the the correct area). Sometimes called direct access The address of each record is the sector and track where the record is stored Must use direct access media Requires overheads in maintaining the file position

7 Hashing The process of calculating a numeric value from one or more data items This is an important technique in storing values in a data structure known as a hash table The calculated value can be used to mark the position in the table where the data item should be found, enabling it to be accessed directly, rather than via a sequential search Collisions This occurs when two data items give the same value under hashing and should therefore be stored in the same place in the table

8 Example of Hashing and Collision
Hashing using Modular Arithmetic Divide the key by the number of storage locations and take the remainder as the address: A table with 100 locations – a four digit key: 1537 will be stored at location 37 (1537/100 = 15, remainder 37) Hashing using Folding The key is divided into two or more parts and the parts added together: The number could be split into 847 and If you add them together you get: If you have 100 storage locations, you would take the last two digits: 24

9 Collisions (Overflow)
The collisions can be put into the next available free block If the record is not in the intended block, the file is searched sequentially until the record is found or an empty block is encountered in which case the record does not exist. Looping Integers If the block is full, add 1 to the key, if that block is full add 2 to the key, if that is full add 3 to the key and so on. If the end of the file is reached, start again from the beginning: For example, if the record should be in block 32, try 33, then 35, then 38, then 42 and so on There are many methods for creating hash keys and dealing with overflows. These are only sample methods.


Download ppt "Methods of Access Serial Sequential Indexed Sequential Random Access"

Similar presentations


Ads by Google