Fields, Records and Files
Data is usually organized as collection of Fields, Records and Files. What are these terms?
- Field-It is defined as a unit of meaningful information about an entity like date of flight, name of passenger, address etc.
- Record– It is a collection of units of information about a particular entity. Passenger of an airplane, an employee of an organization, or an article sold from a store.
- File-A collection of records involving a set of entities with certain aspects in common and organized for some particular purpose is called a file. For example collection of records of all passengers.
There are three file organizations- sequential, Indexed sequential and relative.
- In a sequential file, records are stored one after another on a storage device such that accessing any record can be done only after accessing all records stored before it.
- A sequential file is physically placed on a storage device by storing the sequence of records in adjacent locations on a track. If the file is stored in a direct access storage device like drum and the file is larger than the amount of space on a track, then the records are placed on adjacent tracks. The basic operations to be performed on a sequential file are read, write and update.
- Some operating systems provide file-accessing facilities which allow a file to be extended by writing records after the last stored record. It also allows forward and backward movement of pointer that points to the current record of the file without reading or writing.
Indexed Sequential File
- A file organization where the records can be accessed directly as well as sequentially is called indexed sequential file. The capability of directly accessing a record based on a key can only be achieved if the external storage device supports this type of access i.e. magnetic drums and disks.
- Index is a sequential file which contains index as its record. Index files contain two fields for each file i.e. a Key field and a pointer pointing to some record in the main file. To find a specific field in main file, index is searched for the key value required. The pointer related to key field searches the record at the location it points to.
- Index sequential file has the advantage that the search time is reduced but maintains the sequential nature of file. To make this type of file organization more efficient multiple levels of index are used. Lower level indexes are the sequential file and its higher level is used as its index file.
- A file organization where the records are ordered by their relative key is called relative file. The relative key is record number that represents the record location relative to where the file starts. If the first record in the file has a relative record number of 6, the hundrendth record has a relative record number of 106. The relative files have the advantage of having records that can be of fixed length or variable length.
- The relative files can have the storage of records sequentially, randomly, or dynamically. If a relative files is accessed or stored sequentially, the ordering is meant to organize the relative record numbers.