Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Disk Storage & Files in Database Systems: Storage Devices, Records, & File Operations - Pr, Study notes of Deductive Database Systems

A chapter from the textbook 'elmasri/navathe, fundamentals of database systems, fourth edition'. It covers various aspects of disk storage and files in database systems, including disk storage devices, records, and file operations. Topics include disk parameters, fixed and variable length records, blocking, files of records, unordered and ordered files, hashed files, and dynamic and extendible hashing techniques.

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-j71
koofers-user-j71 🇺🇸

10 documents

1 / 35

Toggle sidebar

Related documents


Partial preview of the text

Download Disk Storage & Files in Database Systems: Storage Devices, Records, & File Operations - Pr and more Study notes Deductive Database Systems in PDF only on Docsity! Fundamentals of DATABASE SYSTEMS F O UR D hie ale) | ON ELMASRI » NAVATHE Chapter 13 Disk Storage, Basic File Structures, and Hashing. Copyright © 2004 Pearson Education, Inc. Chapter 13-5 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Disk Storage Devices (cont.) Because a track usually contains a large amount of information, it is divided into smaller blocks or sectors. The division of a track into sectors is hard-coded on the disk surface and cannot be changed. One type of sector organization calls a portion of a track that subtends a fixed angle at the center as a sector. A track is divided into blocks. The block size B is fixed for each system. Typical block sizes range from B=512 bytes to B=4096 bytes. Whole blocks are transferred between disk and main memory for processing. Chapter 13-6 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Disk Storage Devices (cont.) Chapter 13-7 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Disk Storage Devices (cont.) A read-write head moves to the track that contains the block to be transferred. Disk rotation moves the block under the read- write head for reading or writing. A physical disk block (hardware) address consists of a cylinder number (imaginery collection of tracks of same radius from all recoreded surfaces), the track number or surface number (within the cylinder), and block number (within track). Reading or writing a disk block is time consuming because of the seek time s and rotational delay (latency) rd. Double buffering can be used to speed up the transfer of contiguous disk blocks. Chapter 13-10 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Records Fixed and variable length records Records contain fields which have values of a particular type (e.g., amount, date, time, age) Fields themselves may be fixed length or variable length Variable length fields can be mixed into one record: separator characters or length fields are needed so that the record can be “parsed”. Chapter 13-11 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Blocking Blocking: refers to storing a number of records in one blo ck on the disk. Blocking factor (bfr) refers to the number of records per block. There may be empty space in a block if an integral number of records do not fit in one block. Spanned Records: refer to records that exceed the size of one or more blocks and hence span a number of blocks. Chapter 13-12 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Files of Records 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 for 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. Chapter 13-15 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Operation on Files (cont.) DELETE: Removes the current file record from the file, usually by marking the record to indicate that it is no longer valid. MODIFY: Changes the values of some fields of the current file record. CLOSE: Terminates access to the file. REORGANIZE: Reorganizes the file records. For example, the records marked deleted are physically removed from the file or a new organization of the file records is created. READ_ORDERED: Read the file blocks in order of a specific field of the file. Chapter 13-16 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Unordered Files Also called a heap or a pile file. New records are inserted at the end of the file. To search for a record, a linear search through the file records is necessary. This requires reading and searching half the file blocks on the average, and is hence quite expensive. Record insertion is quite efficient. Reading the records in order of a particular field requires sorting the file records. Chapter 13-17 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Ordered Files Also called a sequential file. File records are kept sorted by the values of an ordering field. Insertion is expensive: records must be inserted in the correct order. It is common to keep a separate unordered overflow (or transaction ) file for new records to improve insertion efficiency; this is periodically merged with the main ordered file. A binary search can be used to search for a record on its ordering field value. This requires reading and searching log2 of the file blocks on the average, an improvement over linear search. Reading the records in order of the ordering field is quite efficient. Chapter 13-20 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Hashed Files Hashing for disk files is called External Hashing The file blocks are divided into M equal-sized buckets, numbered bucket0, bucket1, ..., bucket M-1. Typically, a bucket corresponds to one (or a fixed number of) disk block. One of the file fields is designated to be the hash key of the file. The record with hash key value K is stored in bucket i, where i=h(K), and h is the hashing function. Search is very efficient on the hash key. Collisions occur when a new record hashes to a bucket that is already full. An overflow file is kept for storing such records. Overflow records that hash to each bucket can be linked together. Chapter 13-21 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Hashed Files (cont.) There are numerous methods for collision resolution, including the following: Open addressing: Proceeding from the occupied position specified by the hash address, the program checks the subsequent positions in order until an unused (empty) position is found. Chaining: For this method, various overflow locations are kept, usually by extending the array with a number of overflow positions. In addition, a pointer field is added to each record location. A collision is resolved by placing the new record in an unused overflow location and setting the pointer of the occupied hash address location to the address of that overflow location. Multiple hashing: The program applies a second hash function if the first results in a collision. If another collision results, the program uses open addressing or applies a third hash function and then uses open addressing if necessary. Chapter 13-22 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Hashed Files (cont.) Chapter 13-25 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Dynamic And Extendible Hashed Files Dynamic and Extendible Hashing Techniques Hashing techniques are adapted to allow the dynamic growth and shrinking of the number of file records. These techniques include the following: dynamic hashing , extendible hashing , and linear hashing . Both dynamic and extendible hashing use the binary representation of the hash value h(K) in order to access a directory. In dynamic hashing the directory is a binary tree. In extendible hashing the directory is an array of size 2d where d is called the global depth. Chapter 13-26 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Dynamic And Extendible Hashing (cont.) The directories can be stored on disk, and they expand or shrink dynamically. Directory entries point to the disk blocks that contain the stored records. An insertion in a disk block that is full causes the block to split into two blocks and the records are redistributed among the two blocks. The directory is updated appropriately. Dynamic and extendible hashing do not require an overflow area. Linear hashing does require an overflow area but does not use a directory. Blocks are split in linear order as the file expands. Chapter 13-27 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Extendible Hashing Chapter 13-30 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition RAID Technology (cont.) Different raid organizations were defined based on different combinations of the two factors of granularity of data interleaving (striping) and pattern used to compute redundant information. Raid level 0 has no redundant data and hence has the best write performance. Raid level 1 uses mirrored disks. Raid level 2 uses memory-style redundancy by using Hamming codes, which contain parity bits for distinct overlapping subsets of components. Level 2 includes both error detection and correction. Raid level 3 uses a single parity disk relying on the disk controller to figure out which disk has failed. Raid Levels 4 and 5 use block-level data striping, with level 5 distributing data and parity information across all disks. Raid level 6 applies the so-called P + Q redundancy scheme using Reed-Soloman codes to protect against up to two disk failures by using just two redundant disks. Chapter 13-31 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Use of RAID Technology (cont.) Different raid organizations are being used under different situations Raid level 1 (mirrored disks)is the easiest for rebuild of a disk from other disks – It is used for critical applications like logs Raid level 2 uses memory-style redundancy by using Hamming codes, which contain parity bits for distinct overlapping subsets of components. Level 2 includes both error detection and correction. Raid level 3 ( single parity disks relying on the disk controller to figure out which disk has failed) and level 5 (block-level data striping) are preferred for Large volume storage, with level 3 giving higher transfer rates. Most popular uses of the RAID technology currently are: Level 0 (with striping), Level 1 (with mirroring) and Level 5 with an extra drive for parity. Design Decisions for RAID include – level of RAID, number of disks, choice of parity schemes, and grouping of disks for block-level striping. Chapter 13-32 Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Use of RAID Technology (cont.)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved