File can be thought of as “logical” or a “physical” entity. File as a logical entity: a sequence of records. Records are either fixed size or variable size. A file as a physical entity: a sequence of fixed size blocks (on the disk), but not necessarily physically contiguous (the blocks could be dispersed). Blocks in a file are either physically contiguous or not, but the following is generally simple to do (for the file system):
»Find the first block
»Find the last block
»Find the next block
»Find the previous block
Records are stored in blocks
» This gives the mapping between a “logical” file and a “physical” file
Assumptions (some to simplify presentation for now)
»Fixed size records
»No record spans more than one block
»There are, in general, several records in a block
»There is some “left over” space in a block as needed later (for chaining the blocks of the file)
We assume that each relation is stored as a file, Each tuple is a record in the file.
A file is a sequence of records, where each record is a collection of data values (or data items).
A file descriptor(or file header includes information that describes the file, such as the field names and their data types , and the addresses of the file blocks on disk. Records are stored on disk blocks. The blocking factor bfr or a file is the (average) number of file records stored in a disk block. A file can have fixed-length records or variable-length records.
File records can be unspanned or spanned
Unspanned : no record can span two blocks
Spanned : a record can be stored in more than one block
The physical disk blocks that are allocated to hold the records of a file can be contiguous, linked, or indexed. In a file of fixed-length records, all records have the same format. Usually, unspanned blocking is used with such files. Files of variable-length records require additional information to be stored in each record, such as separator characters and field types.