File Organisation Flashcards
Give examples of different tile types
Word processing, spreadsheet files and so on
How is the content stored in a file?
Defined binary code that allows the file to be used in the way intended
What do computers, that store files for a specific purpose, store them as?
Binary File or
Text File
What is meant by a text file?
It contains data stored by a defined character code (ASCII).
How can you create a text file?
Using a text editor
How does a binary file store data?
In its internal representation i.e. an integer value might be stored in 2 bytes in 2s complement representation
How is a binary file created?
Via a specific program
How are binary files organised?
Based on a record
Explain what is meant by a record?
A file contains a record, and each record contains fields. Each field consists of a value
What is meant by a serial file?
It contains records which have no defined order.
How is a serial file used?
For banks to record transactions involving customer accounts. A program would be running. Each time there was a withdrawal or a deposit the program would receive the details as data input and would record these in a transaction file. The records would enter the file in chronological order but otherwise the file would have no ordering of the records.
What type of file is a text file?
Serial but it the file has repeating lines which are defined by an end of line character or characters. There is no end of record character.
Why must must a record in a serial file have a defined format?
To allow correct input and output
What is meant by a sequential file?
Records that are ordered
Why use sequential files?
For long term storage of data
What would be an alternative to a sequential file?
Database
What is the difference between a sequential file and a serial file?
In banking, a sequential file could be used as a master file for an individual customer account. Periodically, the transaction file would be read and all affected customer account master files would be updated
How are sequential files ordered?
Using a key field where the values are unique and sequential but not always consecutive
What is the difference between a key field and a database primary key?
Primary key values are required to be unique but not sequentia
How are records in a sequential file found?
By sequentially reading the value of the key field until the required value is found.
State what is meant by direct access files?
It is known as random-access files where the randomness is only that the access is not defined by a sequential reading of the file.
Where is direct access files used?
For large files
Why is direct access used for large files?
It saves time compared to searching through a sequential file
How is data stored in a direct access file?
In an identifiable record where finding it may involve an initial direct access to a nearby record followed by a limited serial search
How is the chosen position for a record, when searching direct access, selected?
Using hashing algorithm
How does a hashing algorithm work?
- Take the key field value as an input
- Outputs a value for the position of the record relative to the start of the file
- It will take into account the length of the file (number of records)
Give an example of a hashing algorithm in action
1.If the key field has a numeric value then divide the value by a suitably large number
2. use the remainder from the division to define the position
3.The method will not create a unique position.
4.If a hash position is calculated that duplicates one already calculated by a different key, the next position in the file is used.
This is why a search will involve a direct access followed by limited serial search.
State what is meant by file access
How is stored data in a file going to be used
How should a serial file read an individual data item?
Successively read record by record until the required data is read.
How should a sequential file read an individual data item?
Process is similar to serial but only the value in they key field has to be read.
How should direct-access read an individual data item?
The value in they key field is submitted to the hashing algorithm which then provides the same value for the position in the file that was provided when the algorithm was used at the time of data input.
How are files deleted or editted?
Sequential Files -
- create a new version of the file
- Data is copied from the old file to the new file until the record is reached which needs deleting or editing
- if deletion is needed, reading and copying of the old file continues form the next record
- If a record has changed, an edited version of the record is written to the new file
- remaining records are copied to the new file
Direct-Access:
- No need to create new file (unless file is full).
- A deleted record has a flag set so in the next reading process, the record is skipped over.
Where is serial file organisation best used?
Batch processing or backing up data on magnetic tape
Where is direct-access file organisation best used?
If a problem needs a file in which individual data items might be read, updated, or deleted then direct-access file organisation is most suitable -> serial least suitable