Sie sind auf Seite 1von 3

Database Design and Applications(SSZ G518)

2nd Semester 2017-18

Homework SOLUTIONS

Topic: Indexing
Date: 21-03-2018

Q1: Assume that we have an ordered file with 2,70,000 records stored on disk. The disk block size is
512 Bytes. The record length is fixed and it is 45 Bytes. The Key field (PK) length is 5 Bytes and block
pointer takes 8 Bytes. Consider unspanned record organization.

Design a multilevel index on primary key. Now, answer the following.


What is the blocking factor for data file.
What is the fan-out of the multilevel index.
How many levels are there in the indexing structure, in total.
How many blocks are there in each level (indexing).
How many block accesses are needed to access a record?
How many records are there in top level index block.
How many blocks are needed to store data.
How many block accesses are needed to access a record with just one level of indexing?
How many block accesses are needed to access a record, if no indexing done?

Answer: Assume that we have an ordered file with 2,70,000 records stored on disk. The disk block size
is 512 Bytes. The record length is fixed and it is 45 Bytes. The Key field (PK) length is 5 Bytes and block
pointer takes 8 Bytes. Consider unspanned record organization.

Design a multilevel index on primary key. Now, answer the following.


What is the blocking factor for data file. (11)
What is the fan-out of the multilevel index.(39)
How many levels are there in the indexing structure, in total.(3)
How many blocks are there in each level (indexing). (L1=630; L2=17; L3=1)
How many block accesses are needed to access a record? (3+1=4)
How many records are there in top level index block. (16)
How many blocks are needed to store data. (24546)
How many block accesses are needed to access a record with just one level of indexing?
Ceil(log 630)+1 = 10+1=11
How many block accesses are needed to access a record, if no indexing done?
Ceil(log 24546)= 15
Q2: We need to design a B+ tree indexing for a relation, on the PK of the relation. The PK attribute
is of 7 bytes length. The Disk block size is 512 Bytes. If the tree-pointer takes 4 bytes, for the
above situation, design the best possible number of pointers per node(internal) of the above B+
tree. Each internal node is a disk block which contains search key values and pointers to subtrees.

Answer:In each internal node, Let number pointers=n; number of keys=n-1


(nX4)+(n-1)7 ≤ 512
4n+7n-7 ≤ 512
11n-7 ≤ 512
11n≤ (512+7)
11n ≤ 519
n ≤ 519/11 (take lower int) hence n=47,
Hence the number of pointers in each internal node =47, then no keys=46
Hence order of the B+ tree=47.
Q3. Construct a B+ tree with fan-out (order- P) equal to 3 for the following set of key values.

72, 28, 34, 50, 98, 15, 63, 48, 4. Assume that the tree is initially empty and the values are added in the
order given. For the B+ tree Pleaf = 2.Show the tree after each insertion.
Answer:

Prof.R Gururaj
Course IC for SSZG518

Das könnte Ihnen auch gefallen