Search 75,731 tutors
FIND TUTORS
Ask a question
0 0

Under what circumstances would you use a sequential file over a database?

Tutors, please sign in to answer this question.

2 Answers

A sequential file would be used when the data is character based and not binary, and when the entire file is to be read, and there are considerations for portability. One example would be a file that held a game's high score information. The data would consist primarily of strings, and there would be no specific queries made to that data. There would be little performance requirements. Information returned to the calling code would most likely only need to be parsed from beginning to end with any further filtration to be handled outside of the core file reading functionalitly. As a standard text file there would be little concern for portability issues, and little memory resources would be required since no large database application would need to be instantiated. 

A database would be more beneficial if there were numerous queries expected, and when functions were required on specific portions of data, and/or when the data contained more complex data such as objects or mutimedia. In such cases to read a file from beginning to end would pose performance issues. A database file would not have those issues because it could query the data at any point within the data and could make changes anywhere within that data without having to iterate through the entire file from start to finish for each call. Basic data manipulation such as sorting, filtering, adding or deleting could be handled by the database relieving the need to have to write all of the supporting code for those functions. 
 
The two permanent storage types could be used interchangeably if the program required both types of data interaction. In such a case the program would most likely make calls only to the database file with the database being responsible for creation and manipulation (rewrite) of the sequential file by means of import and export.
 
Typical candidates for a sequential file would include
 
- the application is applying changes in a transactional mode
- changes are applied in a batch mode with no user access to the data while updating is going on
- only a single user is involved, eliminating concurrency issues
- data access is either not real-time or high access speed is not critical
 
Both types could be used concurrently, but in such a case the sequential data would most likely be both small in scope and relatively static (as opposed to volatile.) An typical example would be code/decode lookup files.