edited by
13,028 views
14 votes
14 votes

Consider a database of fixed-length records, stored as an ordered file. The database has $25,000$ records, with each record being $100$ bytes, of which the primary key occupies $15$ bytes. The data file is block-aligned in that each data record is fully contained within a block. The database is indexed by a primary index file, which is also stored as a block-aligned ordered file. The figure below depicts this indexing scheme.

Suppose the block size of the file system is $1024$ bytes, and a pointer to a block occupies $5$ bytes. The system uses binary search on the index file to search for a record with a given key. You may assume that a binary search on an index file of $b$ blocks takes $\left\lceil\log _{2} b\right\rceil$ block accesses in the worst case.

Given a key, the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is _____________.

edited by

2 Answers

20 votes
20 votes

Given that One block should fully contain within block so here it means that they are saying that you should use unspanned file organization.

Given that ,

$No. of Record$ $(Rn)$ $=25000$

$Record Size$  $(Rs)$ $=100Byte$

$Key Size$ $ (Ks)$ $=15 Byte$

$Block Pointer Size $ $(Ps)$ $=5Byte$

So that $ Index Size$  ($Is$) $=15 + 5 = 20 Byte$

$Disk$ $Block$ $Size(Bs) $ $=1024Byte$


 

No. of Record per Block$ =(Bs / Rs)$ $= \left \lfloor1024B/100B\right \rfloor$

                                                                $=\left \lfloor10.24\right \rfloor$

                                                                $=10.$

 

No of Block Required for blocks =$ceilvalue$( no of record / no of record per block)

                                                    = $\left \lceil 25000/10 \right \rceil$ 

                                                     = 2500 Block Required  to store all records

“The database is indexed by a primary index file” it means that here we have to use sparse indexing 


NO of Index per Block $= \left \lfloor(Bs/Is)\right \rfloor$ = floorValue($1024$/$20$) = $51$

NO of Block Required for indexes = CeilValue($No.OfIndex$/$No.OfIndexPerBlock$)

                                                      =  CeilValue($2500$/$51$) = 50 Blocks


 

Given That Binary Search is used to search the desired block and we know that it takes $log(n)$ Time to search in worst case where n= no of comparision Required = No. of Index Block here.

 

 the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is.

= $log(50)$ = $6$ $Blocks$

 

edited by
Answer:

Related questions

9 votes
9 votes
2 answers
1
admin asked Feb 15, 2023
7,656 views
Consider the following table named $\text{Student}$ in a relational database. The primary key of this table is $\text{rollNum}.$$\text{Student}$$\begin{array}{|c|l|c|c|}\...
0 votes
0 votes
0 answers
2