Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Organization.

Similar presentations


Presentation on theme: "File Organization."— Presentation transcript:

1 File Organization

2 File Organization The database is stored as a collection of files. Each file is a sequence of records. A record is a sequence of fields. We have a file with 2 types of records Fixed length records Variable length records.

3 Fixed Length Records Store record I starting from byte n*(i-1), where n is the size of each record. The record access is simple, but records may cross blocks, Deletion of record I Alternatives Move records i+1, … n to I, … n-1 Move records n to I Do not move records, but link all free records on a free list. Free Lists Store the address of the first deleted record in the file header. Use this first record to store the address of the second deleted record and so on. Can think of these stored addresses as pointers since they “point” to the location of a record. More space efficient representation.

4 Tree list after the deletion of records 1,4,6 in the account records

5 Variable length records
Variable length records arise in database systems in several ways Store of multiple record type in a file Record type that allow variable lengths for one or more fields. Record types that allow repeating fields. Different techniques for implementing variable length records exist. The slotted – page structure is commonly used for organizing record within a block. The slotted page header contains the following information. The number of record entries in the header The end of free space in the block. An array whose entries contain the location and size of each record.

6 Slotted Page structure
Block Header Slotted Page structure

7 Records can be moved around within a page to keep them contiguous with no empty space between them; entry in the heads must be updated. Pointers should not point directly to record – instead they should point to the entry for the record in header.

8 Organization of Records in files

9 Heap file organization
Any record can be placed any where in the file where there is space for the record. There is no ordering of records. There is a single file for each relation Sequential file organization Store records in sequential order, based on the value of the search key of each record. Hashing file organization A hash function is computed on some attribute of each record. The result of the hash function specifies in which block of the file the record should be placed. Generally separate file is used for store the records of each relation. In a multitable clustering file organization records of several different relations can be stored in the same file.

10 Operations on files They are grouped into retrieval operations (not change any data in the file) and update operations (change the file by insertion or deletion or modification) Open – opening a file for reading and writing Reset – sets the file pointer to rthe beginning of the file Find (Locate) – searches for the 1st record that satisfies a search condition Read (or Get) – Reading the current record in the file FindNext – Searches for the next record in the file Delete – Deletes the current records and updates the file pointer Modify – Modify some field values of the current record Insert – Inserts the new records in the file Close – Completes the file access by releasing the buffers These operations are called record at a time operations, because each operation applies to a single record FindAll – Locate all the record in the file Find Ordered – Retrieves all the records in the file in some order Reorganize – Starts the reorganization process.


Download ppt "File Organization."

Similar presentations


Ads by Google