13.2 file organisation and access Flashcards
Serial files
A serial file is a collection of records with no defined order. Records enter the file in chronological order. All records have a defined format so that they can be input and output correctly.
An example of a serial file?
A text file can be considered an example of a serial file: a series of characters are input, in chronological order, to produce a file.
Use of a serial file?
A common use of serial files is for real-time processing. Records can be entered in real time, as quickly as possible, because they do not need to be sorted. This makes serial files efficient.
Sequential file
A sequential file stores records in order of a key field. In order for it to be possible to sort records by key field, this field needs to be unique and sequential but does not need to be consecutive.
In a sequential file, a particular record can be found by reading all of the key fields until you reach the one you are looking for.
Use of a sequential file?
Finding a particular record in a list of records
Random/direct access file
A direct-access file is a collection of records that can be directly accessed without having to check every record. This is acheived using a hash table.
What is a Hash table?
A hash table is a table of data which is ordered not by the key field, but by the hash value of the key field. Thus, data can be directly accessed by hashing the key field, rather than having to look through each record one by one.
What are the two ways to access a specific record in a file?
sequential access
direct access
What can be accessed using sequential access?
serial files
sequential files
What can be accessed using direct access?
Random/direct files
sequential file
What is sequential access?
Sequential access is where each record in the file is read, one by one, until the desired record is found.
What is direct access?
Direct access is where a hashing algorithm is used to jump to a specific record in the file.
How do you delete and edit data in a sequentially accessed file?
In a sequentially accessed file, deleting and editing data requires the creation of a new file. Data is moved from the old file to the new file until the part where the record needs editing is reached.
How do you delete and edit data in a direct accessed file?
However, in a direct-access file, data can be deleted or edited in place: there is no need for a new file.