Docsity

Storage and Indexes-Introduction to Databases-Tutorial 17-Computer Science, Study Guides, Projects, Research of Introduction to Database Management Systems

Toggle sidebar
bg1
Today
• Review of Directory of Slot Block Organizations
• Heap Files
• Program 1 Hints
• Ordered Files & Hash Files
•RAID
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Storage and Indexes-Introduction to Databases-Tutorial 17-Computer Science and more Study Guides, Projects, Research Introduction to Database Management Systems in PDF only on Docsity!

Today

Review of Directory of Slot Block Organizations

Heap Files

Program 1 Hints

Ordered Files & Hash Files

RAID

Directory of Slots Example

Heap File Example

Favor, Sue Paradise, Sal 231

123

Mach, Chris

401

Rodgers, Bill

616

Smith, Mary Yost, Ned

819

Alm, LouisLink, StevePatch, Linda

Jones, Jim

983

183 14 93 281

Ming, YaoTuring, Alan

709 933

block 1 of file

block 2 of file

block N of file

Name

ID

Name

ID

Name

ID

assuming N data blocks, R records per block, I/O cost of D and“record processing time” of C what are the costs of: 2D+C2D+C

N(D+RC) N(D+RC)/

N(D+RC)

inserting a record,deleting record given RID

(ignore reclaiming space)

scan,search for “key” w/ equality selection,search w/ range selection?

Prog 1 Hints

check slot numbers to make sure they are valid

sizeof(), memcpy(), memmove()

man

is your friend

test patterns –

make sure you handle

error cases correctly

error reporting

// **********************************************************// page class constructor void HFPage::init(PageId pageNo){

nextPage = prevPage = INVALID_PAGE;slotCnt

// no slots in use

curPage

= pageNo;

usedPtr

= sizeof(data);

// offset of used space in data array

freeSpace = sizeof(data) + sizeof(slot_t); // amount of space available

// (initially one unused slot)

init()

getNextPage(), setNextPage()

getPrevPage(), setPrevPage()

insertRecord(), deleteRecord()

firstRecord(), nextRecord()

getRecord(), returnRecord()

available_space()

empty()

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 periodicallymerged 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 log

2

of the file blocks on the

average, an improvement over linear search.

•^

Reading the records in order of the ordering field is quite efficient.

File of Ordered Records

Hashed Files (contd.)

Hashed Files (contd.)

•^

There are numerous methods for collision resolution, including thefollowing:

Open addressing

: Proceeding from the occupied position specified by

the hash address, the program checks the subsequent positions inorder until an unused (empty) position is found.

Chaining

: For this method, various overflow locations are kept, usually

by extending the array with a number of overflow positions. In addition,a pointer field is added to each record location. A collision is resolved byplacing the new record in an unused overflow location and setting thepointer of the occupied hash address location to the address of thatoverflow location.

Multiple hashing

: The program applies a second hash function if the

first results in a collision. If another collision results, the program usesopen addressing or applies a third hash function and then uses openaddressing if necessary.

Hashed Files - Overflow handling

Fill in This Table

HeapSortedHashed

scan

equality

range

insert

delete

search

search