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 🇺🇸

9 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

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!

Chapter 13

Disk Storage, Basic File Structures, and

Hashing. Copyright © 2004 Pearson Education, Inc.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Disk Storage Devices (cont.) Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

z

Preferred secondary storage device for highstorage capacity and low cost.

z

Data stored as magnetized areas on magneticdisk surfaces.

z

A

disk pack

contains several magnetic disks

connected to a rotating spindle.

z

Disks are divided into concentric circular^ tracks

on each disk

surface

. Track capacities

vary typically from 4 to 50 Kbytes.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Disk Storage Devices (cont.) Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Because a track usually contains a largeamount of information, it is divided intosmaller

blocks

or

sectors

z

The division of a track into

sectors

is hard-coded on

the disk surface and cannot be changed. One type ofsector organization calls a portion of a track thatsubtends a fixed angle at the center as a sector. z

A track is divided into

blocks

. The block size B is

fixed for each system. Typical block sizes range fromB=512 bytes to B=4096 bytes. Whole blocks aretransferred between disk and main memory forprocessing.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Disk Storage Devices (cont.) Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

z^

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. z^

A physical disk block (hardware) address consists of a cylindernumber (imaginery collection of tracks of same radius from allrecoreded surfaces), the track number or surface number (withinthe cylinder), and block number (within track). z^

Reading or writing a disk block is time consuming because of theseek time s and rotational delay (latency)

rd

.

z^

Double buffering can be used to speed up the transfer ofcontiguous disk blocks.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Disk Storage Devices (cont.) Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Records

z

Fixed and variable length records z

Records contain fields which have values of a particulartype (e.g., amount, date, time, age) z

Fields themselves may be fixed length or variable length z

Variable length fields can be mixed into one record:separator characters or length fields are needed so that therecord can be “parsed”.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Blocking

z

Blocking: refers to storing a number of records in one block on the disk. z

Blocking factor (

bfr

) refers to the number of records per

block. z

There may be empty space in a block if an integralnumber of records do not fit in one block. z

Spanned Records

: refer to records that exceed the size of

one or more blocks and hence span a number of blocks.

Chapter 13-

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Files of Records (cont.)

z

File records can be

unspanned

(no record can span two

blocks) or

spanned

(a record can be stored in more than

one block). z

The physical disk blocks that are allocated to hold therecords of a file can be

contiguous

,^ linked

, or

indexed

z

In a file of fixed-length records, all records have thesame format. Usually, unspanned blocking is used withsuch files. z

Files of variable-length records require additionalinformation to be stored in each record, such as separator characters

and

field types

. Usually spanned

blocking is used with such files.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Operation on Files

Typical file operations include: z

OPEN:

Readies the file for access, and associates a

pointer that will refer to a

current

file record at each

point in time. z

FIND:

Searches for the first file record that satisfies a

certain condition, and makes it the current file record. z

FINDNEXT:

Searches for the next file record (from

the current record) that satisfies a certain condition, andmakes it the current file record. z

READ:

Reads the current file record into a program

variable. z

INSERT:

Inserts a new record into the file, and makes

it the current file record.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Unordered Files

z

Also called a

heap

or a

pile

file.

z

New records are inserted at the end of the file. z

To search for a record, a

linear search

through the file

records is necessary. This requires reading andsearching half the file blocks on the average, and ishence quite expensive. z

Record insertion is quite efficient. z

Reading the records in order of a particular fieldrequires sorting the file records.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Ordered Files

z

Also called a

sequential file

z

File records are kept sorted by the values of an

ordering

field

z

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 mergedwith the main ordered file. z

A

binary search

can be used to search for a record on its

ordering field value

. This requires reading and searching

log

of the file blocks on the average, an improvement 2 over linear search. z

Reading the records in order of the ordering field is quiteefficient.

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Average Access Times

The following table shows the average access time to

access a specific record for a given type of file

Copyright © 2004 Ramez Elmasri and Shamkant Navathe

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition

Hashed Files

z^

Hashing for disk files is called

External Hashing

z^

The file blocks are divided into M equal-sized

buckets

, numbered

bucket

, bucket 0

, ..., bucket 1

M-

. Typically, a bucket corresponds to

one (or a fixed number of) disk block. z^

One of the file fields is designated to be the hash key of the file. z^

The record with hash key value K is stored in bucket i, wherei=h(K), and h is the

hashing function

.

z^

Search is very efficient on the hash key. z^

Collisions occur when a new record hashes to a bucket that isalready full. An overflow file is kept for storing such records.Overflow records that hash to each bucket can be linked together.