You are on page 1of 5

1

Branch : CSE & IT Batch : Hinglish


Database Management System
File Org & Indexing DPP 02

[NAT] record length R = 200 bytes. Now assume that the


1. Consider the following specification of system with ordering key field of the file is V= 18 bytes long, a
disk block size 2048 bytes, block pointer size 14 bytes, block pointer P = 12 bytes long, and we have construed
record pointer size 18 bytes long and file size 60,000 a primary index for the file. Let p and q be the number
records. Each record of file is 256 bytes long and of blocks required to access a record in case of without
record of the size is sorted on the key field. If the index and with primary index using binary search
primary index (sparse) is built on the key field (ESN) respectively, Then the values of p + q is .
which is 18 bytes long. What is the Index blocking (a) 18 (b) 19
factors (That is number of indexes per block) (c) 20 (d) 21
Assuming unspanned file organization _________.
[MCQ]
[NAT] 6. Consider an unordered file of 106 records with records
2. Common data for next two Questions: size of 200 bytes stored on blocks of 8KB with a
Consider a disk blocking size B = 1024 bytes. A block spanned records organization. We will assume that no
pointer (BP) = 12 bytes long and a record pointer (RP) system related information is stored within a block,
= 7 bytes long. A file has r = 60,000 patient records of then how many blocks would it be need to store this
fixed length. The size of record is 230 bytes. Suppose file?
the file is not ordered by the key field PSN (18 bytes) (a) 24400 (b) 24405
and we want to construct a secondary index on key (c) 24410 (d) 24415
attributes (PSN).
[MCQ]
The number of first level index entries are x and
7. Consider the following statements:
number of second level index entries are y then find the
S1: For any given data file, it is possible to create two
value of x + y?
different sparse first level indexes on various keys.
S2: For any given data file, it is possible to create two
[MCQ]
different denes first level indexes on various keys.
3. The number of first level index blocks are x and Select the correct statements.
number of second level index blocks are y then (a) Only S1 correct
x +y ? (b) Only S2 correct
(a) 1600 (b) 1500 (c) Both S1 and S2 is correct
(c) 45 (d) 1545 (d) Neither is S1 nor S2 is correct.
[NAT]
[MCQ]
4. Consider a file of r = 40,000 records, each record is
R = 100 bytes long and its key field is of size v = 20 8. Which of the following is NOT a benefit of using
bytes. The file is ordered on a key field, and the file Indexes in a database?
organization is unspanned. The file is stored in a file (a) Improved query performance
system with block size B = 2000 bytes, and size of (b) reduced disk I/O
block pointer is 20 bytes. If the primary index is built (c) Increased storage space
on the key field of the file and multilevel index scheme (d) Faster data retrieval
is used to store the primary index, then the total number
of blocks required by the multilevel index is . [MCQ]
9. Which of the following best describes an index in a
[MCQ] database.
5. Assume that we have an ordered file with r = 60,000 (a) A column that stores unique identifiers for each
records stored on a disk with block size B = 2048 bytes. row in a table.
File record are of fixed size & are unspanned with
2

(b) A data structure that allows for fast searching and (d) None of the above.
retrieval of data, based on certain criteria.
(c) A set of constraints that enforce rules for data
integrity
3

Answer Key
1. (64) 6. (d)
2. (61500) 7. (b)
3. (d) 8. (c)
4. (41) 9. (b)
5. (21)
4

Hints & Solutions


1. (64) Number of 1st Level index blocks b1 =  r1 / bfri 
 2048   2, 000 
Number of indexes per blocks =   = 64 = 
14 + 18   = 40
 50 
Number of 2nd level index entries r2 = number of 1st
2. (61500) level block b1 = 40 entries.
Number of first level index entries r1 = Number of files Number of 2nd level index b2 =  r2 / bfri  =  40 / 50 = 1
records r = 60,000.
Since the 2nd level has only 1 block, it is the top index
So, x will be 60000.
level. Hence, the index has 2 levels.
Now, block factor of the first level index =
The total Number of blocks required by the multilevel
 1024 
18 + 7  = 40 index entries per block. index (bi) = b1 + b2 = 40 + 1 = 41 blocks.
 
 Number of index block at first level (that is entries
 60000 
for second level = y) =   = 1500 blocks
 40  5. (d)
 x + y = 60000 + 1500 = 61500 The blocking factor for the file will be bfr = ( B / R )
=  2048 / 200  = 10 records per block.
3. (d)
Now, block factor of the first level index = The number of blocks needed for the file is b =
 1024  ( r / bfr )  = ( 60,000 / 10 ) = 6000 blocks.
18 + 7  = 40 index entries per block.
  A binary search on the data file would need
 Number of index block at first level (that is entries approximately log 2 b  = log 2 6000  = 13 block
 60000 
 = 1500 blocks
for second level = x) =  accesses.
 40  The size of each index entry is Ri = (18 + 12) = 30
Now, block factor of the second level index = bytes.
 1024  So, the blocking factors for the index is bfri =
18 + 12  = 34 index entries per block.
  ( B / R i ) 
 Number of index block at second level (that is
 2048  
1500  =    = 68 entries per block
entries for second level = y) =   = 45 blocks  30  
 34 
The total number of index entries ri is equal to number
 x + y = 1500 + 45 = 1545
of blocks in the data file, which is 6000 blocks.
Hence, the number of index blocks is bi = ( ri / bfri )
4. (41)
File blocking factor bfr = ( B / R ) = 
 000 
 = 89 blocks.
 68 
=  2000 / 100 
To perform a binary search on the index file it would it
= 20 records per block
need ( log 2 / bi ) = log 2 (89 ) = 7 blocks access.
Number of blocks needed for file =  r / bfr 
To search for a record using the index, we need one
 40, 000 
=   = 2000 database blocks additional block access to data file which makes total
 20  of(q) 7 + 1 = 8 = blocks access, an improvement over
Index records size Ri = (V + P) = (20 + 20) = 40 bytes binary search on data file which required 13 block
Index blocking factors bfri =  B / R i  = access.
 2000   p + q = 13 + 8 = 21
 40  = 50 index records per block
 
Number for first level index entries (ri) will be equal to
number of file blocks b = 2000 entries
5

6. (d) S2:(True): Any number of dense indexes is possible to


Blocks size = 8 KB construct. In the dense indexing we have index entries
Records size = 200 bytes for each file records.
8192
The number of records in a block = = 40.96 8. (c)
200
records (Spanned Organization). The correct answer is ‘c’.
As it is spanned hence it takes whole as 40.96 ‘Increase storage space’. This is because adding
1 block contains 40.96 records. indexes to a database can actually increase the amount
 106  of storage space required as the index data structure
 The number of file blocks =   = 24415 blocks. needs to be stored alongside the data. The other answer
 40.96  choices are all benefits of using indexes.
9. (b)
7. (b) Indexing in a database is a data structure that allows for
S1: (false): It is not possible because the requirement of fast searching and retrieval of data based on certain
sparse indexing is that the database must be stored and criteria.
as we know that database is sorted only on one column.

Any issue with DPP, please report by clicking here:- https://forms.gle/t2SzQVvQcs638c4r5


For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if

PW Mobile APP: https://smart.link/7wwosivoicgd4

You might also like