9618 · 13.2
File organisation and access
File organisation is how we arrange data records in storage, while file access is how we find and read them. The way you organise your data determines how efficiently you can access it.
Need to know
What you need to know
- **Use Case:** Ideal for transaction logs, error logs, or streaming data where order of arrival is important.
- **Adding Data:** Very fast, as new records are simply added to the end.
- **Searching:** Very slow. To find a specific record, you must start at the beginning and read every record until you find it (sequential access).
- **Updating/Deleting:** Inefficient. Typically, the entire file must be read into memory, modified, and then written back out.
Explanation
A Library for Data
- Organisation: First, decide how to physically arrange records in the file. They can be added one after another, sorted by a key, or placed at calculated addresses.
- Access Method: Next, choose how to retrieve a record. This is dictated by the organisation method used.
- Sequential Access: To find a record, you must start at the beginning and read through every preceding record. This is simple but can be slow.
- Direct Access: To find a record, you calculate its exact location and jump straight to it. This is very fast but requires a more complex file organisation.