Explore BrainMass

Compare the Two Non-Sequential File Structure Models

Compare the two non-sequential file structure models: the random (hashed) file and the index file. What advantages does the first one have over the second and what advantages does the second have over the first? What would be your criteria for choosing one over the other for different applications?

Solution Preview

If selection queries are frequent, sorting the file or building an index is important.
Hash-based indexes only good for equality search.

The advantage of ordering records in a sequential file according to a key is that you can then search the file more quickly. If you know the key value that you want, you can use one of the relatively fast searches. The disadvantage is that when you insert, you need to rewrite at least everything after the insertion point, which makes inserts very expensive unless they are done at the end of the file.

An indexed file approach keeps a (hopefully) small part of each row, and some kind of "pointer" to the row's location within the data file. This allows a search to use the index, which is ordered by the index and (again hopefully) much smaller and therefore much faster than scanning the entire data file for the indexed data.

- Indexed files allow direct access and sequential ...

Solution Summary

This solution discusses the pros, cons and further background information on indexed files and hashed files in 589 words.