Homework3 Sol
Homework3 Sol
(50 marks)
Suppose that you have formatted your disk with a block size of 1024 bytes and
assume that we have 10,000 CAR records of fixed length. A block pointer is 7 bytes
long (P=7), and a record pointer is 5 bytes long (Pr=5). Each CAR record has the
following fields: Model (20 bytes), Registration (8 bytes), Color (9 bytes), License (9
bytes), Location (40 bytes), Mileage (10 bytes), Price (8 bytes), Year (4 bytes),
Manufacturer (16 bytes), and Remarks (200 bytes). The file is ordered by the key
field Model and we want to construct a primary index on Model.
(a) Calculate the blocking factor (bfr) and the number of file blocks needed to store
the CAR records. Assume that records are stored unspanned. How much space
remains unused per block? . [10 marks]
(c) Assume that the primary index is a single-level index. Calculate the number of
index entries and the number of index blocks. [10 marks]
(d) What is the number of block accesses needed to search for a record without
using primary index? And what is the number of block accesses using the single-
level index in subquestion (c)? [5 marks]
(f) Consider the multilevel index from subquestion (d). What is the number of block
accesses needed to search for and retrieve a record from the file given its Model
value? . [5 marks]
#block_access = #level + 1 = 4
internal node:
q*P + (q-1) * V <= B
8q + 16(q-1) <= 1024
q <= 43
leaf node:
(q-1) * (Pr + V) + P <= B
22(q-1) + 8 <= 1024
q <= 47
S: r1(X); r1(Z); r3(X); r2(Y); r3(Y); w1(X); w2(Z); w1(Z); c1; w2(Y); w3(Y);
w3(X); r2(Z); c2; c3;
1) Draw the serialization graph for S and state whether it is serializable or not. If it’s
serializable, write down all equivalent serial schedule(s). If not, write down a
serializable schedule whose equivalent serial schedule is T1->T2->T3. [20
marks]
X
Z
X
Z
This is not serializable. A serializable schedule can be [r1(X), r1(Z), w1(X), w1(Z), c1,
r2(Y), w2(Z), w2(Y), r2(Z), c2, r3(X), r3(Y), w3(Y), w3(X), c3].