Chapter 5 Record Storage and Primary File Organizations

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
CS4432: Database Systems II Hash Indexing 1. Hash-Based Indexes Adaptation of main memory hash tables Support equality searches No range searches 2.
1 Hash-Based Indexes Module 4, Lecture 3. 2 Introduction As for any index, 3 alternatives for data entries k* : – Data record with key value k – –Choice.
Chapter 11 (3 rd Edition) Hash-Based Indexes Xuemin COMP9315: Database Systems Implementation.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 17 Disk Storage, Basic File Structures, and Hashing.
File Organizations Sept. 2012Yangjun Chen ACS-3902/31 Outline: File Organization Hardware Description of Disk Devices Buffering of Blocks File Records.
Advance Database System
1 Hash-Based Indexes Chapter Introduction  Hash-based indexes are best for equality selections. Cannot support range searches.  Static and dynamic.
FALL 2004CENG 3511 Hashing Reference: Chapters: 11,12.
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
1 Hash-Based Indexes Chapter Introduction : Hash-based Indexes  Best for equality selections.  Cannot support range searches.  Static and dynamic.
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.
Spring 2004 ECE569 Lecture ECE 569 Database System Engineering Spring 2004 Yanyong Zhang
E.G.M. PetrakisHashing1 Hashing on the Disk  Keys are stored in “disk pages” (“buckets”)  several records fit within one page  Retrieval:  find address.
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.
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
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.
1 Overview of Database Design Process. Data Storage, Indexing Structures for Files 2.
Hashing and Hash-Based Index. Selection Queries Yes! Hashing  static hashing  dynamic hashing B+-tree is perfect, but.... to answer a selection query.
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.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Indexed Sequential Access Method.
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.
Jun-Ki Min. Slide  Such a multi-level index is a form of search tr ee ◦ However, insertion and deletion of new index entrie s is a severe problem.
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
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:

Chapter 5 Record Storage and Primary File Organizations 1. Disk Storage Devices 2. Files of Records 3. Operations on Files 4. Unordered Files 5. Ordered Files 6. Hashed Files 6.1 Static External Hashing 6.2 Dynamic and Extendible Hashing Techniques

File Organization File organization: is the organization of the data of a file into records, blocks and access structures. This includes the way records and blocks are stored on the storage medium and linked. Access method: provides a group of operations that can be applied to a file.

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 (may be even more).

Disk Storage Devices (continued) 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. 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 address consists of a surface number, track number (within surface), 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.

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 number of file records stored in a disk block.

Files of Records (continued) A file can have fixed-length records or variable-length records. File records can be unspanned (no record can span two blocks) or 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.

Operations on files Operations on files are: Update operations Retrieval operations In either case it needs to find the record (s) based on certain criteria such as: SELECT dbx where salary > 30000 So we want the finding the record be efficient

Operations on Files (continued) Typical file operations include: used by high level program (DBMS) OPEN: Readies the file for access, and associates a pointer that will refer to a current file record at each point in time. FIND: Searches for the first file record that satisfies a certain condition, and makes it the current file record. FINDNEXT: Searches for the next file record (from the current record) that satisfies a certain condition, and makes it the current file record. READ: Reads the current file record into a program variable.

Operations on Files (continued) INSERT: Inserts a new record into the file, and makes it the current file record. 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: Reads the file blocks in order of a specific field of the file.

Unordered Files Also called a heap or a pile or a sequential file. It is simplest file organization. Insertion is easy. New records are inserted at the end of the file. The process is: last block is moved to MM new record is added the block is copied back into file address of last block is kept in file header

Unordered file (continued) 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. Expensive

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.

Ordered Files (continued) 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.

Hashing Hashing is either internal or external Internal hashing is implemented using hash table. The hash function maps the key to a table location. Collisions are handled using: Open addressing Multiple hashing Chaining

Hashing (continued) Hashing for disk files is called external hashing Static dynamic Static External Hashing The file blocks are divided into M equal-sized buckets, numbered bucket0, bucket1, ..., bucketM-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.

Hashing (continued) 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 same bucket can be linked together. 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.

Hashing (continued) Main disadvantages of static external hashing: Fixed number of buckets M is a serious problem for dynamic files. If the number of records in the file grows or shrinks we have overflow or wasted space Ordered access on the hash key is quite inefficient (requires sorting the records).

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 linear hashing .

continued 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. d is the first d bits in binary representaion of hash value.

Dynamic and Extendible Hashing Techniques (continued) 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.

continued Dynamic and extendible hashing do not require an overflow area. Linear hashing does require an overflow area but does not use a directory. If a bucket overflows, bucket 0 will split into two buckets 1 and m. The original records in bucket 0 which used hi (k) MOD M will be distributed between bucket 0 and bucket M using hash function hi+1(K) MOD 2M. If any more bucket overflows, bucket 1 will split in the same way. Blocks are split in linear order as the file expands. If all bucket split, then all overflow records will be part of the original (not overflow any more) and uses hi+1 (K) MOD 2M.