database’system’ assignment5’solution’ 1.’’winston/courses/dms/4... ·...

7
Database system Assignment 5 Solution 1. 2. Original tree (a) (b) 4 page read, 5 page write

Upload: others

Post on 25-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Database’system’ Assignment5’Solution’ 1.’’winston/courses/dms/4... · Assignment5’Solution’ 1.’’ ’ ’ 2.’Original’tree ... 2^(d-l) (b) When does the directory

Database  system  Assignment  5  Solution  1.    

 

 2.  Original  tree

 (a)  

 

(b)  4  page  read,  5  page  write  

 

Page 2: Database’system’ Assignment5’Solution’ 1.’’winston/courses/dms/4... · Assignment5’Solution’ 1.’’ ’ ’ 2.’Original’tree ... 2^(d-l) (b) When does the directory

(c)  

 (d)  

 (e)  

 (f)  

   

Page 3: Database’system’ Assignment5’Solution’ 1.’’winston/courses/dms/4... · Assignment5’Solution’ 1.’’ ’ ’ 2.’Original’tree ... 2^(d-l) (b) When does the directory

3.Extendible Hashing Index(a) Show the index after inserting an entry with hash value 68.

(b) Show the original index after inserting entries with hash values 17 and 69.

Page 4: Database’system’ Assignment5’Solution’ 1.’’winston/courses/dms/4... · Assignment5’Solution’ 1.’’ ’ ’ 2.’Original’tree ... 2^(d-l) (b) When does the directory

(c) Show the original index after deleting the entry with hash value 21. (Assumethat the full deletion algorithm is used.)

(d) Show the original index after deleting the entry with hash value 10. Is a merge triggered by this deletion? If not, explain why. (Assume that the full deletion algorithm is used.)

The deletion of the data entry 10 which is the only data entry in bucket C doesn’t trigger a merge because bucket C is a primary page and it is left as a place holder. Right now, directory element 010 and its split image 110 already point to the same bucket C. We can’t do a further merge.

Page 5: Database’system’ Assignment5’Solution’ 1.’’winston/courses/dms/4... · Assignment5’Solution’ 1.’’ ’ ’ 2.’Original’tree ... 2^(d-l) (b) When does the directory

4. Linear Hashing Index(a) Show the index after inserting an entry with hash value 4.

(b) Show the original index after inserting an entry with hash value 15.

Page 6: Database’system’ Assignment5’Solution’ 1.’’winston/courses/dms/4... · Assignment5’Solution’ 1.’’ ’ ’ 2.’Original’tree ... 2^(d-l) (b) When does the directory

(c) Show the original index after deleting the entries with hash value 36 and 44. (Assume that the full deletion algorithm is used.)

5. Answer the following question about Extendible Hashing:(a) Supposed a Extendible Hashing has a global depth d and a bucket with local depth l. How many directory elements point to that bicket?

2^(d-l)

(b) When does the directory need to be double?

The directory is overflow and its local depth is equal to global depth.

(c) Does doubling the directory require us to examine all buckets with local depth equal to global depth?

No, only the splitting bucket requires to be examined.

(d) If the search key k is skewed (very nonuniform), why this situation is not aproblem in practice?

Even if the distribution of search key is skewed, the choice of a good hashing function typically yields a fairly uniform distribution of hash values; skew is therefore not a problem in practice.

(e) Why do you use the least significant bits of the hash value to determine thedirectory slot of a data item?

The reason is that a directory can then be doubled simply by copying it.

Page 7: Database’system’ Assignment5’Solution’ 1.’’winston/courses/dms/4... · Assignment5’Solution’ 1.’’ ’ ’ 2.’Original’tree ... 2^(d-l) (b) When does the directory

6. Answer the following questions about Linear Hashing:(a) For uniform distributions and skewed distributions of data, which situation has better performance in Linear Hashing and Extendible Hashing?

omitted

(b) How does Linear Hashing avoid a directory?

The new idea behind Linear Hashing is that a directory can be avoided by clever choice (i.e. round-robin splitting) of the bucket to split.