Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 13 Disk Storage, Basic File Structures, and Hashing.

Slides:



Advertisements
Similar presentations
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 17 Disk Storage, Basic File Structures, and Hashing.
Advertisements

Disk Storage, Basic File Structures, and Hashing
Databasteknik Databaser och bioinformatik Data structures and Indexing (II) Fang Wei-Kleiner.
Chapter 7 Indexing Structures for Files Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Chapter 14 Indexing Structures for Files Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Indexing Structures for Files.
Advance Database System
METU Department of Computer Eng Ceng 302 Introduction to DBMS Disk Storage, Basic File Structures, and Hashing by Pinar Senkul resources: mostly froom.
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Indexing Structures for Files.
1 CS 728 Advanced Database Systems Chapter 17 Database File Indexing Techniques, B- Trees, and B + -Trees.
DISK STORAGE INDEX STRUCTURES FOR FILES Lecture 12.
Indexing dww-database System.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 5, 6 of Elmasri “ How index-learning turns no student.
Chapter 14-1 Chapter Outline Types of Single-level Ordered Indexes –Primary Indexes –Clustering Indexes –Secondary Indexes Multilevel Indexes Dynamic Multilevel.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
CHAPTER 13:DISK STORAGE, BASIC FILE STRUCTURES, AND HASHING Disk Storage, Basic File Structures, and Hashing Copyright © 2007 Ramez Elmasri and Shamkant.
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.
Disk Storage, Basic File Structures, and Hashing
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
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 Index Structures. 2 Chapter : Objectives Types of Single-level Ordered Indexes Primary Indexes Clustering Indexes Secondary Indexes Multilevel Indexes.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Indexing Structures for Files by Pinar Senkul resources: mostly froom Elmasri, Navathe and.
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.
Indexing Structures for Files
1 Chapter 2 Indexing Structures for Files Adapted from the slides of “Fundamentals of Database Systems” (Elmasri et al., 2003)
Nimesh Shah (nimesh.s) , Amit Bhawnani (amit.b)
1 Overview of Database Design Process. Data Storage, Indexing Structures for Files 2.
Chapter- 14- Index structures for files
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.
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 Slide
Chapter 6 Index Structures for Files 1 Indexes as Access Paths 2 Types of Single-level Indexes 2.1Primary Indexes 2.2Clustering Indexes 2.3Secondary Indexes.
Chapter 14 Indexing Structures for Files Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18 Indexing Structures for Files.
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
10/3/2017 Chapter 6 Index Structures.
Indexing Structures for Files
Disk Storage, Basic File Structures, and Hashing
Indexing Structures for Files
Chapter Outline Indexes as additional auxiliary access structure
Indexing Structures for Files
Chapter # 14 Indexing Structures for Files
Lecture 20: Indexing Structures
Disk Storage, Basic File Structures, and Hashing
9/12/2018.
11/14/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
Indexing Structures for Files
Advance Database System
8/31/2019.
Lec 6 Indexing Structures for Files
Presentation transcript:

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 Chapter Outline Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files Dynamic and Extendible Hashing Techniques RAID Technology

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Disk Storage Devices Preferred secondary storage device for high storage capacity and low cost. Data stored as magnetized areas on magnetic disk surfaces. 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 or more

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Disk Storage Devices (contd.) A track is divided into smaller blocks or sectors because it usually contains a large amount of information 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.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Disk Storage Devices (contd.)

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Disk Storage Devices (contd.) 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 (imaginary collection of tracks of same radius from all recorded 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.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Disk Storage Devices (contd.)

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 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.”

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Blocking Blocking: Refers to storing a number of records in one block on the disk. Blocking factor (bfr) refers to the number of records per block. There may be empty space in a block if an essential number of records do not fit in one block. Spanned Records: Refers to records that exceed the size of one or more blocks and hence span a number of blocks.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 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.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Files of Records (contd.) 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. Usually spanned blocking is used with such files.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Hashed Files (contd.) 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).

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 14 Indexing Structures for Files

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Chapter Outline Types of Single-level Ordered Indexes Primary Indexes Clustering Indexes Secondary Indexes Multilevel Indexes

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Indexes as Access Paths A single-level index is an auxiliary file that makes it more efficient to search for a record in the data file. The index is usually specified on one field of the file (although it could be specified on several fields) One form of an index is a file of entries, which is ordered by field value The index is called an access path on the field.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Indexes as Access Paths (contd.) The index file usually occupies considerably less disk blocks than the data file because its entries are much smaller A binary search on the index yields a pointer to the file record Indexes can also be characterized as dense or sparse A dense index has an index entry for every search key value (and hence every record) in the data file. A sparse (or nondense) index, on the other hand, has index entries for only some of the search values

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Indexes as Access Paths (contd.) Example: Given the following data file EMPLOYEE(NAME, SSN, ADDRESS, JOB, SAL,... ) Suppose that: record size R=150 bytesblock size B=512 bytesr=30000 records Then, we get: blocking factor Bfr= B div R= 512 div 150= 3 records/block number of file blocks b= (r/Bfr)= (30000/3)= blocks For an index on the SSN field, assume the field size V SSN =9 bytes, assume the record pointer size P R =7 bytes. Then: index entry size R I =(V SSN + P R )=(9+7)=16 bytes index blocking factor Bfr I = B div R I = 512 div 16= 32 entries/block number of index blocks bl= (r/ Bfr I )= (30000/32)= 938 blocks binary search needs log 2 bI= log 2 938= 10 block accesses This is compared to an average linear search cost of: (b/2)= 30000/2= block accesses

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Types of Single-Level Indexes Primary Index Defined on an ordered data file The data file is ordered on a key field Includes one index entry for each block in the data file; the index entry has the key field value for the first record in the block, which is called the block anchor A similar scheme can use the last record in a block. A primary index is a nondense (sparse) index, since it includes an entry for each disk block of the data file and the keys of its anchor record rather than for every search value.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Primary index on the ordering key field

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Types of Single-Level Indexes Clustering Index Defined on an ordered data file The data file is ordered on a non-key field unlike primary index, which requires that the ordering field of the data file have a distinct value for each record. Includes one index entry for each distinct value of the field; the index entry points to the first data block that contains records with that field value. It is another example of nondense index where Insertion and Deletion is relatively straightforward with a clustering index.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Another Clustering Index Example

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Types of Single-Level Indexes Secondary Index A secondary index provides a secondary means of accessing a file for which some primary access already exists. The secondary index may be on a field which is a candidate key and has a unique value in every record, or a non-key with duplicate values. The index is an ordered file with two fields. The first field is of the same data type as some non-ordering field of the data file that is an indexing field. The second field is either a block pointer or a record pointer. There can be many secondary indexes (and hence, indexing fields) for the same file. Includes one entry for each record in the data file; hence, it is a dense index

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Example of a Dense Secondary Index

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide An Example of a Secondary Index

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Properties of Index Types

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Multi-Level Indexes Because a single-level index is an ordered file, we can create a primary index to the index itself; In this case, the original index file is called the first-level index and the index to the index is called the second-level index. We can repeat the process, creating a third, fourth,..., top level until all entries of the top level fit in one disk block A multi-level index can be created for any type of first- level index (primary, secondary, clustering) as long as the first-level index consists of more than one disk block

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide A Two-level Primary Index

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Multi-Level Indexes Such a multi-level index is a form of search tree However, insertion and deletion of new index entries is a severe problem because every level of the index is an ordered file.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Summary Types of Single-level Ordered Indexes Primary Indexes Clustering Indexes Secondary Indexes Multilevel Indexes