Elmasri_dv845023
Chapter 13Disk Storage, Basic File Structures, andHashing.
awtri_4c UPDATE_color
Copyright © 2004 Pearson Education, Inc.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-3
Chapter Outline
Disk Storage Devices
Files of Records
Operations on Files
Unordered Files
Ordered Files
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Disk Storage Devices
Basic unit of data stored in disks is a single bit torepresent data in 0/1 form.
Bits are grouped into Byte.
The capacity of disk: the amount of bytes it can store.
FloppyDiskd: 400KBytes- 1.5MBytes
Hard disks: several hundred Mbytes – tera Bytes.
 
Chapter 13-4
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-5
Disk Storage Devices (cont.)
Preferred secondary storage device for highstorage capacity and low cost.
Data stored as magnetized areas on magneticdisk surfaces.
disk pack  contains several magnetic disksconnected to a rotating spindle.
Disks are divided into concentric circulartracks  on each disk surface.  Track capacitiesvary typically from 4 to 50 Kbytes.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-6
Disk Storage Devices (cont.)
Because a track usually contains a largeamount of information, it is divided intosmaller blocks or sectors.
The division of a track into sectors is hard-coded onthe 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.
A track is divided into blocks. The block size B isfixed for each system. Typical block sizes range fromB=512 bytes to B=4096 bytes. Whole blocks aretransferred between disk and main memory forprocessing.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-7
Disk Storage Devices (cont.)
 13.02.gif                                                      0001035BEeyore                         B91DCF3B:
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-8
Disk Storage Devices (cont.)
A read-write  head moves to the track that contains the block tobe transferred. Disk rotation moves the block under the read-write head for reading or writing.
physical disk block (hardware) address consists of acylinder number (imaginery collection of tracks of same radiusfrom all recoreded surfaces), the track number or surface number(within the cylinder), and block number (within track).
physical disk block address = cylinder number + track number +block number
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Disk Storage Devices (cont.)
Reading or writing a disk block is time consumingbecause of the seek time s and rotational delay(latency) rd.
Double buffering can be used to speed up the transferof contiguous disk blocks.
Chapter 13-9
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-10
Disk Storage Devices (cont.)
 13.01.gif                                                      0001035BEeyore                         B91DCF3B:
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-11
Typical DiskParameters

Table1301.tif                                                  0000732BEeyore                         BC0F1D1E:
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-12
Records
Data is usually stored in the form of records.
A File is a sequence of records.
Fixed and variable length records
Records contain fields which have values of a particulartype (e.g., amount, date, time, age)
Fields themselves may be fixed length or variable length
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-13
Blocking
Blocking: refers to storing a number of records in oneblock on the disk.
Blocking factor (bfr) refers to the number of records perblock.
There may be empty space in a block if an integralnumber of records do not fit in one block.
Spanned Records: refer to records that exceed the size ofone or more blocks and hence span a number of blocks.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-14
Files of Records
A file is a sequence  of records, where each record is acollection of data values (or data items).
file descriptor  (or file header ) includes informationthat describes the file, such as the field names  and theirdata types, and the addresses of the file blocks on disk.
Records are stored on disk blocks. The blocking factorbfr for a file is the (average) number of file recordsstored in a disk block.
A file can have fixed-length  records or variable-lengthrecords.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-15
C:\Users\Rehab\Desktop\spann-unspannRecord.png
Spanned and Unspanned records
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-16
Files of Records (cont.)
File records can be unspanned  (no record can span twoblocks) or spanned  (a record can be stored in more thanone block).
The physical disk blocks that are allocated to hold therecords of a file can be contiguouslinked, or indexed.
In a file of fixed-length records, all records have thesame format. Usually, unspanned blocking is used withsuch files.
Files of variable-length records require additionalinformation to be stored in each record, such asseparator characters  and field types. Usually spannedblocking is used with such files.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-17
Operation on Files
Typical file operations include:
OPEN: Reads the file for access, and associates apointer that will refer to a current  file record at eachpoint in time.
FIND: Searches for the first file record that satisfies acertain condition, and makes it the current file record.
FINDNEXT: Searches for the next file record (fromthe current record) that satisfies a certain condition, andmakes it the current file record.
READ: Reads the current file record into a programvariable.
INSERT: Inserts a new record into the file, and makesit the current file record.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-18
Operation on Files (cont.)
DELETE: Removes the current file record from thefile, usually by marking the record to indicate that it isno longer valid.
MODIFY: Changes the values of some fields of thecurrent file record.
CLOSE: Terminates access to the file.
REORGANIZE: Reorganizes the file records. Forexample, the records marked deleted are physicallyremoved from the file or a new organization of the filerecords is created.
READ_ORDERED: Read the file blocks in order of aspecific field of the file.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-19
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 filerecords is necessary. This requires reading andsearching half the file blocks on the average, and ishence quite expensive.
Record insertion is quite efficient.
Reading the records in order of a particular fieldrequires sorting the file records.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-20
Ordered Files
Also called a sequential file.
File records are kept sorted by the values of an orderingfield.
Insertion is expensive: records must be inserted in thecorrect order.
binary search  can be used to search for a record on itsordering field value. This requires reading and searchinglog2 of the file blocks on the average, an improvementover linear search.
Reading the records in order of the ordering field is quiteefficient.
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-21
Ordered Files(cont.)
 13.09.gif                                                      0001035BEeyore                         B91DCF3B:
square
Copyright © 2004 Ramez Elmasri and Shamkant Navathe
Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition
bar2
Chapter 13-22
Average Access Times
The following table shows the average access time toaccess a specific record for a given type of file

Table1302.tif                                                  0000732BEeyore                         BC0F1D1E: