Disk Storage, Basic File Structures, and Hashing

Slides:



Advertisements
Similar presentations
3/31/2017.
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 17 Disk Storage, Basic File Structures, and Hashing.
Disk Storage, Basic File Structures, and Hashing.
Disk Storage, Basic File Structures, and Hashing
Databasteknik Databaser och bioinformatik Data structures and Indexing (II) Fang Wei-Kleiner.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 17 Disk Storage, Basic File Structures, and Hashing.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
2P13 Week 11. A+ Guide to Managing and Maintaining your PC, 6e2 RAID Controllers Redundant Array of Independent (or Inexpensive) Disks Level 0 -- Striped.
File Organizations Sept. 2012Yangjun Chen ACS-3902/31 Outline: File Organization Hardware Description of Disk Devices Buffering of Blocks File Records.
Advance Database System
File Organizations and Indexes ISYS 464. Disk Devices Disk drive: Read/write head and access arm. Single-sided, double-sided, disk pack Track, sector,
METU Department of Computer Eng Ceng 302 Introduction to DBMS Disk Storage, Basic File Structures, and Hashing by Pinar Senkul resources: mostly froom.
Efficient Storage and Retrieval of Data
Copyright © 2004 Pearson Education, Inc.. Chapter 13 Disk Storage, Basic File Structures, and Hashing.
CS 728 Advanced Database Systems Chapter 16
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 13 Disk Storage, Basic File Structures, and Hashing.
Database Systems Chapters ITM 354. The Database Design and Implementation Process Phase 1: Requirements Collection and Analysis Phase 2: Conceptual.
Physical Storage Organization. Advanced DatabasesPhysical Storage Organization2 Outline Where and How data are stored? –physical level –logical level.
DISK STORAGE INDEX STRUCTURES FOR FILES Lecture 12.
1 Lecture 7: Data structures for databases I Jose M. Peña
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 5, 6 of Elmasri “ How index-learning turns no student.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Today Review of Directory of Slot Block Organizations Heap Files Program 1 Hints Ordered Files & Hash Files RAID.
CHAPTER 13:DISK STORAGE, BASIC FILE STRUCTURES, AND HASHING Disk Storage, Basic File Structures, and Hashing Copyright © 2007 Ramez Elmasri and Shamkant.
Physical Storage Organization. Advanced DatabasesPhysical Storage Organization2 Outline Where and How are data stored? –physical level –logical level.
Disk Storage Copyright © 2004 Pearson Education, Inc.
1 Chapter 1 Disk Storage, Basic File Structures, and Hashing. Adapted from the slides of “Fundamentals of Database Systems” (Elmasri et al., 2003)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 17 Disk Storage, Basic File Structures, and Hashing.
Lecture 9 of Advanced Databases Storage and File Structure (Part II) Instructor: Mr.Ahmed Al Astal.
Chapter 13 Disk Storage, Basic File Structures, and Hashing. Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Basic File Structures and Hashing Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
Chaps17&18-1 CSE 4701 Chapters 17 & 18 6e, 13 & 14 5e: Design/Storage/Index Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The.
1 Chapter 17 Disk Storage, Basic File Structures, and Hashing Chapter 18 Index Structures for Files.
Chapter 9 Disk Storage and Indexing Structures for Files Copyright © 2004 Pearson Education, Inc.
1) Disk Storage, Basic File Structures, and Hashing This material is a modified version of the slides provided by Ramez Elmasri and Shamkant Navathe for.
Database Management Systems,Shri Prasad Sawant. 1 Storing Data: Disks and Files Unit 1 Mr.Prasad Sawant.
1 Overview of Database Design Process. Data Storage, Indexing Structures for Files 2.
Physical Storage Organization. Advanced DatabasesPhysical Storage Organization2 Outline Where and How data are stored? –physical level –logical level.
Chapter Ten. Storage Categories Storage medium is required to store information/data Primary memory can be accessed by the CPU directly Fast, expensive.
Chapter 13 Disk Storage, Basic File Structures, and Hashing. Copyright © 2004 Pearson Education, Inc.
Storage Structures. Memory Hierarchies Primary Storage –Registers –Cache memory –RAM Secondary Storage –Magnetic disks –Magnetic tape –CDROM (read-only.
File Structures. 2 Chapter - Objectives Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files Dynamic and.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 13 Disk Storage, Basic File Structures, and Hashing.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Lec 5 part2 Disk Storage, Basic File Structures, and Hashing.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe.
Chapter 15 Disk Storage, Basic File Structures, and Hashing. Copyright © 2004 Pearson Education, Inc.
Chapter 5 Record Storage and Primary File Organizations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Lec 5 part1 Disk Storage, Basic File Structures, and Hashing.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
File Organization Record Storage and Primary File Organization
Disk Storage, Basic File Structures, and Hashing
Oracle SQL*Loader
Disk Storage, Basic File Structures, and Hashing
9/12/2018.
Chapters 17 & 18 6e, 13 & 14 5e: Design/Storage/Index
Disk Storage, Basic File Structures, and Hashing
Disk Storage, Basic File Structures, and Buffer Management
Disk storage Index structures for files
Disk Storage, Basic File Structures, and Hashing.
1/17/2019.
Advance Database System
Lec 7:Disk Storage, Basic File Structures, and Hashing
CHAPTER 16 Disk Storage, Basic File Structures, Hashing, and Modern Storage Architectures.
Disk Storage Devices Preferred secondary storage device for high storage capacity and low cost. Data stored as magnetized areas on magnetic disk surfaces.
Presentation transcript:

Disk Storage, Basic File Structures, and Hashing Chapter 13 Byung-Hyun Ha bhha@pusan.ac.kr

Table of Contents Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files RAID Technology

Introduction Computer storage media Primary storage Secondary storage Memory hierarchies and storage devices Primary storage level cache memory – static RAM DRAM Secondary storage level magnetic disks CD-ROM, optical jukebox memories, DVD magnetic tapes, tape jukeboxes Flash memory Storage of databases

Disk Storage Devices High storage capacity and low cost Preferred secondary storage device for Magnetic disk surfaces Data stored as magnetized areas A disk pack contains several magnetic disks connected to a rotating spindle Disks are divided into concentric circular tracks on each disk surface track capacities vary typically from 4 to 50 Kbytes divided into smaller blocks or sectors

Disk Storage Devices A single-sided disk (a) and a disk pack (b)

Disk Storage Devices Different sector organizations on disk (a) Sectors subtending a fixed angle (b) Sectors maintaining a uniform recording density.

Disk Storage Devices Blocks Transferring disk blocks Because a track usually contains a large amount of information, it is divided into smaller blocks 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 Transferring disk blocks 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 12 to 60 msec (Seek time / rotational delay / block transfer time)

Disk Storage Devices Double buffering

Placing File Records on Disk 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”

Placing File Records on Disk (a) A fixed-length record with six fields and size of 71 bytes (b) A record with variable-length fields and fixed-length fields (c) A variable-field record with three types of separator characters

Files of Records Block File Unit of data transfer A sequence of records each record is a collection of data values (or data items) File descriptor 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

Files of Records Unspanned or spanned records

Operation on Files Typical file operations OPEN FIND FINDNEXT READ INSERT DELETE MODIFY CLOSE REORGANIZE READ_ORDERED

Files of Unordered Records Also called a heap or a pile file New records are inserted at the end of the file linear search through the file records 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

Files of Ordered Records 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

Files of Ordered Records An example

Files of Ordered Records Binary search for an key value K of a disk file Algorithm: Binary search on an ordering key of a disk file l  1; u  b; (* b is the number of file blocks*) while (u  l) do begin i  (l + u) div 2; read block i of the file into the buffer; if K < (ordering key field value of the first record in block i) then u  i – 1 else if K > (ordering key field value of the last record in block i) then l  i + 1 else if the record with ordering key field value = K is in the buffer then goto found else goto notfound; end; goto notfound;

Average Access Times

Hashing Technique Hashing Search using hash function of yielding address for hash key The search condition must be an equality condition on hash field Collision hash("apple") = 5 hash("watermelon") = 3 hash("grapes") = 8 hash("cantaloupe") = 7 hash("kiwi") = 0 hash("strawberry") = 9 hash("mango") = 6 hash("banana") = 2 hash("honeydew") = 6

Hashing Technique Collision resolution Open addressing / chaining / multiple hashing

External Hashing for Disk Files Hashing for disk files is called External Hashing The file blocks are divided into M equal-sized buckets 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

External Hashing for Disk Files Matching bucket numbers to disk block addresses

External Hashing for Disk Files To reduce overflow records, a hash file is typically kept 70-80% full The hash function h should distribute the records uniformly among the buckets otherwise, search time will be increased because many overflow records will exist. Main disadvantages of static external hashing Fixed number of buckets M is a problem if the number of records in the file grows or shrinks Ordered access on the hash key is quite inefficient (requires sorting the records).

External Hashing for Disk Files Overflow handling

Dynamic Hashing Technique Hashing techniques are adapted to allow the dynamic growth and shrinking of the number of file records These techniques include the following Extendible hashing and linear hashing Extendible hashing Use the binary representation of the hash value h(K) in order to access a directory Directory is an array of size 2d where d is called the global depth

Dynamic Hashing Technique Extendible hashing

Dynamic Hashing Technique Linear hashing This is another dynamic hashing scheme, an alternative to Extendible Hashing. Motivation: Ext. Hashing uses a directory that grows by doubling… Can we do better? (smoother growth) LH: split buckets from left to right, regardless of which one overflowed (simple, but it works!!)

Example of Linear Hashing

Example of Linear Hashing

Example of Linear Hashing

Example of Linear Hashing

Example of Linear Hashing

Example of Linear Hashing

Example of Linear Hashing

Example of Linear Hashing

Other Primary File Organizations Files of mixed records Connecting fields Logical vs. physical file reference Physical clustering B-Tree and other data structures

Parallelizing Disk Access Secondary storage technology must take steps to keep up in performance and reliability with processor technology A major advance in secondary storage technology is represented by the development of RAID, which originally stood for Redundant Arrays of Inexpensive Disks The main goal of RAID is to even out the widely different rates of performance improvement of disks against those in memory and microprocessors

RAID Technology A natural solution is a large array of small independent disks acting as a single higher-performance logical disk. A concept called data striping is used, which utilizes parallelism to improve disk performance. Data striping distributes data transparently over multiple disks to make them appear as a single large, fast disk.

Improving Reliability with RAID Likelihood of failure Mean Time To Failure (MTTF) One disk: 200,000 hours n disks: (200,000 / n) hours Improving reliability Introducing redundancy Mirroring or shadowing Storing extra information parity bits or hamming codes

Based on striping and redundant information. RAID Technology Based on striping and redundant information. Raid level 0 uses 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 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

RAID Technology Multiple level of RAID