Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

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

You might also like