0% found this document useful (0 votes)
24 views15 pages

File Org & Indexing - DPP 03 (Of Lec 06) 2

The document contains a series of multiple-choice questions (MCQs) and numerical answer type (NAT) questions related to Database Management Systems, specifically focusing on file organization and indexing concepts. It includes questions about B+ trees, B trees, and their properties, as well as calculations for block sizes and orders of nodes. Additionally, the document provides an answer key and hints for solving the questions presented.

Uploaded by

om717102
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views15 pages

File Org & Indexing - DPP 03 (Of Lec 06) 2

The document contains a series of multiple-choice questions (MCQs) and numerical answer type (NAT) questions related to Database Management Systems, specifically focusing on file organization and indexing concepts. It includes questions about B+ trees, B trees, and their properties, as well as calculations for block sizes and orders of nodes. Additionally, the document provides an answer key and hints for solving the questions presented.

Uploaded by

om717102
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1

Branch : CSE & IT Batch : Hinglish


Database Management System
File Org & Indexing DPP 03

[MCQ] [NAT]
1. The order of a leaf node in a B+ tree is the maximum 6. The order of a node in B tree is the maximum number
number of (value, data record pointer) pairs it can hold. of block pointers it can hold. Given that the block size
Given that the block size is 1K bytes, data record
is 2K bytes, data record pointer is 8 bytes long, the
pointer is 8 bytes long, the value field is 10 bytes long
and a block pointer is 6 bytes, then what is the order of search key is 9 bytes long and a block pointer is 5 bytes
the leaf node? long. The best possible order of B tree node is .
(a) 53 (b) 54
(c) 55 (d) 56 [NAT]
7. The order of a leaf node (P) in a B+ tree is the maximum
[NAT]
number of (value, data record pointer) pairs it can hold.
2. The order of a node in B+ tree is defined as the number
of pointers it can hold. What is the maximum number Given that P=36, data record pointer is 8 bytes long,
of keys that a B+ tree of order 4 and height 4 can have the search field is 6 bytes long and a block pointer is 8
? __________ bytes long. The permissible block size is .
(Assume that the height of a root node is 1)
[NAT]
[MCQ]
3. Given a block can hold either 3 records or 10 key 8. (Assume that the level of root node is1)
pointers. A database contains P records, then how The order of different nodes in B+ tree/B tree are given
many blocks do we need to hold the data file and the as-
dense index? 2 to P block pointers in root node.
P P P
(a) (b)
30 3  2  to P block pointers in internal node.
 
13P P
(c) (d) P
30 10  2  –1 to (P–1) keys in leaf node.
 

[NAT] Let a and b be


4. The order of an internal node in B+ tree index is the The minimum number of keys in
maximum number of children it can have. Assume that B tree and B+ tree node of order
a child pointer takes 6 bytes, the search field value P = 5 and level = 5. The value of (a + b) is .
takes 34 bytes and the blocks size is 2048 bytes. The
order of the internal node is ________. [NAT]
[NAT] 9. (Assume that the level of root node is1)
5. Assume a disk with block size B = 1024 Bytes, A block The order of different nodes in B+ tree/B tree are given
pointer is PB = 12 bytes long and a record pointer is PR as-
= 18 bytes long. A file has 1,00,000 patients records of 2 to P block pointers in root node.
size 100 bytes. Suppose the file is ordered by the key P
field PID and we want to construct a secondary (dense)  2  to P block pointer is internal node.
 
index on non-key field DeptID (14 bytes), then
minimum of how many blocks are required to store P
 2  –1 to (P–1) keys in leaf node.
index file assuming an unspanned organisation?  
(a) 3000 (b) 3100 Let a and b be the maximum number of keys in B tree
(c) 3125 (d) None of the above and B+ tree node of order P = 5 and level = 5. The value
of (a +b) is .
2

[NAT] [MSQ]
10. Consider the keys (1– 5000) are going to be interested 12. Which of the following is/are true reading B+ tree?
(a) Records can be fetched in equal number of disk
into a B+ tree. Assume, all the order are available
access.
before insertion. The orders P for B+ tree node is (b) Height of the tree remains balanced and less as
defined as- compared to B tree.
2 to P pointer for root (c) Keys are used for indexing
P (d) Faster search queries as the data is stored only on
 2  to P pointer for another node. the leaf nodes.
 
The maximum possible levels in a B+ tree index for P [NAT]
= 9 is _________. 13. Consider the keys (1– 5000) are going to be interested
(Assume that level of the root node is 1) into a B+ tree. Assume, all the order are available
before insertion. The orders P for B+ tree node is
[MCQ] defined as-
11. Consider the following statements: 2 to P pointer for root
S1: In a B+ tree, data pointers are stored only at the leaf
nodes of the tree. P
 2  to P pointer for another node.
S2: The leaf node has an entry for every value of the  
search field, along with the data pointer to the The minimum possible levels in a B+ tree index for P =
record. 9 is _________.
Choose the correct statements. (Assume that level of the root node is 1)
(a) Only S1 is true
(b) Only S2 is true
(c) Both S1 and S2 are true
(d) Neither S1 nor S2 is true
3

Answer Key
1. (d) 8. (269)
2. (255) 9. (5624)
3. (c) 10. (6)
4. (52) 11. (c)
5. (c) 12. (a, b, c, d)
6. (93) 13. (4)
7. (512)
4

Hints & Solutions


1. (d) 5. (c)
Disk block Blocking factor, bfr = 1024 / 100
= 10 records per block
Number of blocks needs for file = r/bfr 
Given data, = 100000/10 = 10000
Disk block size = 1K byte = 210 bytes = 1024 bytes Index records size Ri= (Non – Key DeptID + PR))
Block pointer (B) = 6 bytes = 14 + 18 = 32 bytes
Key field (K) = 10 bytes Index blocking factors bfri = B / R i  = 1024 / 32
Record/ data pointer (R) = 8 bytes
= 32
Order of leaf node= P st
Number of 1 level index entries r1 = number of –
B + (P)(K + R) < D records in the file = 100000 entries.
6 + (P)(10 + 8) < 1024 Number of first level index blocks b1 =  r1 /bfri 
18 P < 1024 – 6
= 100000/32 = 3125 blocks
1018 
P=  
 18  6. (93)
 P = 56 Order P: maximum blocks pointers per node.
Maximum number of (value, data record pointer) Block size > P × (Block size pointer) + (P –1) × (size
of keys + size of record pointers)
Pairs = 56
Block size > P ×5 + (P – 1) × (9 + 8)
The order of the leaf node is 56. 2048 > 5P + 17P – 17
22P ≤ 2065
2. (255)  2065 
A B+ tree of order n and height h can have at most nh – P=   = 93
 22 
1 keys. Therefore, maximum number of keys-
= 44 –1 = 255. 7. (512)
Order P: maximum number of (value, data record
3. (c) pointer) pairs
For storing the records, numbers of blocks required = Block size > P × (keys size + Record pointer size) + 1×
P (Block pointer size)
and for storing the keys in dense index number of Block size > P × (6 + 8) + 1 × (8)
3
Block size > 14 * 36 + 8
P Block Size = 512 bytes
blocks required = .
10
P P 13 P 8. (269)
So, total blocks required are + =
3 10 30
Level Minimum Minimum Minimum
4. (52) Number of number of number of
Size of child pointer = 6 bytes Nodes Blocks pointer keys
Size of search field value = 34 bytes 1 1 2 1
Block size = 2048. 2 2 5 2×2
Order of internal node = P 2 × = 6
2
( Number of blocks pointer in any node)
3 6 6 × 3 = 18 6×2
(P –1)34 + P × 6 < 2048
4 18 18 × 3 = 54 18 × 2
34P + 6P < 2048 + 34
40P < 2082 5 54 54 × 3 = 162 54 × 2
2082 a = minimum number of keys in B tree → 161
P< For a B+ tree, keys are present in last level only b = 108
40
= 52.05 52  a + b = 161 + 108 = 269
5

9. (5624) 11. (c)


S1(True): In a B+ tree, data pointers are stored only at
Level Max. No. Max. No. Max. No. of the leaf nodes of the tree.
of nodes of Blocks keys S2(True): the leaf nodes have an entry for every value
pointer of the search field, along with the data pointer to the
1 1 5 4 record.
2 5 5×5 5×4
3 25 25 × 5 25 × 4 12. (a, b, c, d)
4 125 125 × 5 125 × 4 True: Records can be fetched in equal number of
5 625 625 × 5 625 × 4 accesses
a = maximum number of keys in B tree → 3124 True: Height of the tree remains balanced and less as
For a B+ tree, keys are present in last level only b = compared to B tree.
2500. True: We can access the data stored in a B+ tree
sequentially as well.
10. (6) True: Faster search queries as the data is stored only
For maximum possible levels, minimum number of on the leaf node.
keys should be present in an index node.
13. (4)
 5000 
Number of nodes in the last level =   = 1250 For minimum possible levels, maximum number of
 4 
keys should be present in index node.
 9 
[Minimum    − 1 keys for other node]  5000 
 2  =   = 625
 8 
 625 
=   = 70
 9 
 70 
=   = 8 Minimum number of level = 4
9
8
=   = 1 node
9

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


1

Branch : CSE & IT Batch : Hinglish


Database Management System
File Org & Indexing DPP 01

[MCQ] (b) P2 only


1. Assume a relational database system that holds (c) P3 only
relation: C(colleges) with the following (d) P1, P2 and P3
characteristics
• Records are stored as fixed length, fixed format [MCQ]
records, length is 256 bytes.
4. Consider the following specification of system-
• There are 16384 records.
Disk block size = 2048 bytes
• Records contains key attribute CollegeNumber
(C.N), length 22 bytes and other fields. Block pointer size = 16 bytes
Record pointer size = 20 bytes long
• Unspanned organization is used to store the
information or record. file contains 30,000 records.
Let’s suppose we want to build a sparse primary index Each record of the file has the following fields:
on C.N then how many numbers of 4096-byte blocks Fields Size (in Bytes)
are needed to store the primary index when block EmpName 5
pointer size is 10 bytes ______?
EmpNum 10
(a) 7 (b) 8 DeptNum 9
(c) 9 (d) 10 Addr 20
PhNum 9
[NAT] DOB 1
2. Assume a relational database system that holds Sex 1
relation: Product (P) with the following characteristics Job 3
• Records are stored as fixed length, fixed format Sal 5
records, with the length of 256 bytes.
An extra/additional byte is used per record to represent
• There are 262144 records. end of the record.
• Records contain attribute P.I (The identifier of the What is the block factor of the database file assuming
product involved), with the length 24 bytes, and an unspanned file organization?
attribute P.C (the cost of product), with the length (a) 16 (b) 32
32 bytes and other fields. (c) 48 (d) 64
• Unspanned organization is used to store the record.
Assume that we want to build a dense secondary index [MSQ]
on P.C, then how many numbers of 4096-byte blocks 5. Which one of the following statements is/are True
needed to store the dense secondary index. When regarding indexing?
record pointer size is 32 bytes? _______. (a) A database file can contain multiple clustered
indexes.
[MCQ] (b) A database file can consist of only one clustered
3. Consider a SQL statement SELECT P1, P2, P3 from Q index with multiple secondary indexes.
WHERE P2 = ‘Pavan’ is frequently executed, which (c) A database file can consist of multiple primary
column(s) should be considered for indexing based indexes.
only on the statement itself? (d) A database file can consist of both primary and
clustered index.
(a) P1 only
2

[NAT] [MCQ]
6. Consider a database of fixed-length records stored as 7. Consider the following statements-
an ordered file. The database has 25,000 records with S1: If the records of a relation X are physically
each records being 100 bytes, of which the non-key ordered over a non-key field P and an index is
attribute on which clustering index is formed occupies build over the key-field of relation X, then the
10 bytes. The data file is completely block aligned. index is necessarily a secondary index over key
Suppose, block size, of the file system is 512 bytes attribute.
and a pointer to the block occupy 5 bytes. You may S2: More than one secondary indexes are possible.
assume that a binary search on an index file of b
block may take log2b accesses in worst case. Which of the given statement(s) is/are CORRECT?
Given that a cluster consumes 2 blocks, the number of (a) S1 only
block accesses required to identify the desired data in (b) S2 only
the worst case is ______. (c) Both S1 and S2
(d) Neither S1 nor S2
3

Answer Key
1. (b) 5. (b)
2. (4096) 6. (9)
3. (b) 7. (c)
4. (b)
4

Hints & Solutions


1. (b) 5. (b)
In the primary index, number of entries in the index (a) False: A database file can contain one clustered
block equals to number of blocks of relation. index because the database is sorted on one field
Number of database records in a single block B = only.
4096/256 = 16 (b) True: A database file can consist of one
Number of blocks of relation C = 16384/16 = 1024 clustered index and multiple secondary index.
Size of indexes = size of key field (c) False: The index on a unique field on which
+ size of block pointer database is sorted is primary index and there can
be only one primary index.
= 22 + 10 = 32 bytes
(d) False: A database file can consist of either a
Number of indexes records present in single block =
4096/32 = 128 primary or clustered index but not both.

 Total number of blocks required to store primary


index = 1024/128 = 8. 6. (9)
 512 
Block factor of database file = 
2. (4096)  100 
In dense secondary index, number of entries in the = 5 records/block
index blocks equals to number of records of relation. Number of blocks required to store 25,000 records
• Number of records in the relation P = 262144  25000 
=  
Size of index = size of key field  5 
+ size of record pointer = 5000 blocks
Each cluster consumer 2 blocks
= 32 + 32 = 64 bytes
5000
• Number of index entry in single block Number of entries in index file = = 2500
2
= 4096/64 = 64  512 
Block factor of index file =  = 34 entries/block
So, the total number of blocks required to store  15 
primary index = 262144/64 = 4096.
 2500 
Number of blocks in index file =  = 74
 34 
3. (b) The number of block accesses in worst case
The column on which condition gets applied should be = log 2 74  + 1 + 1
considered for indexing.
  
P2 is the answer. st nd
for index Accessing 1 Accessing 2
file search block of cluster block of cluster

4. (b) = 7 + 1 + 1 = 9 blocks access required


Blocking factor (i.e number of records per block)
Block size 7. (c)
=
record size S1: Records are ordered over non-key field. It is
Record size of file = Sum of all field + additional bytes unordered over key field.
= 63 + 1 = 64 Hence, secondary index if formed over unordered
2048 key-field. Hence, its CORRECT.
 Number of records per block = = 32
64 S2: CORRECT. More than one secondary index is
possible.
5

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


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  accesses.
for second level = x) =   = 1500 blocks
 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