click below
click below
Normal Size Small Size show me how
F452 Computing
11 Files
Term | Definition |
---|---|
File | Organised collection of data / collection of records. |
Field | One item of data about an instance of an entity (person, object or event). |
Record | A number of data items, can be of different data types, grouped under a single identifier. Individual items called fields can be accessed using field names and dot notation e.g. Gymnast.Name |
Advantages of Records | Data referring to a single entity can be kept together. Makes it easier to manipulate (eg save, copy, search, sort) a whole record. |
Serial file | Records appear in the order in which they are received. New records are appended (to the end of the file). To access a record, you have to search through all preceding records. |
Serial access | Records are read from the first record in the file, in order, until the end of the file is reached. |
Deleting record from serial file | A new file is created. Records are copied from the old file to the new file except the record to be deleted. The new file is renamed as the old file. |
Sequential file | File in which the records are stored in order of key field. |
Advantages of Serial File | Simple and easier to implement. Adding new records is easy. Searching is easy but slow. Suited to a small number of records. |
Sequential access | Records are read in order of key field. |
Sizes of data types | String – 1 byte per character, Integer - 4 bytes, Real/Single – 4 bytes (Double – 8 bytes), Boolean – 1 byte, Date – 8 bytes |
Estimating file size | Decide how many bytes for each field, add up to find size of 1 record, * by number of records, + 10% ‘overheads’ (and / by 1024 for to convert from bytes to kB) |
The need to reset data in file | To initialise values otherwise existing contents of the file may be used and give unexpected results. |
Add record to sequential file | Open new file. Copy from old file to new file: all records before new record, new record, all remaining records from old file. |
Indexed sequential file | Records are sorted according to a primary key. A separate index is kept. Index allows groups of records to be accessed directly. New data needs to be inserted in correct position and index updated. Index must be in the same order as the records. |
Advantages of ISF | With a large number of records accessing a specific record is faster as you do not have to search sequentially from the beginning. Records can be accessed sequentially when all records need to be accessed – this is efficient access |
Disadvantage of ISF | More difficult to manage e.g. adding a new record requires inserting it in the correct position. The index has to be maintained and kept in sync with the data. |
Random file | The address of each record is calculated from the key using a hash algorithm. Records may not be contiguous. |