0% found this document useful (0 votes)
8 views

Assignment 3

The document outlines Assignment 3 for the CS3402 Database Systems course at City University of Hong Kong, focusing on database indexing and transaction schedules. It includes detailed questions on calculating blocking factors, index entries, block accesses, and serialization graphs related to SMARTPHONE records and transactions. The assignment consists of three main questions, each requiring calculations and justifications based on given data and scenarios.

Uploaded by

LL 3708
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment 3

The document outlines Assignment 3 for the CS3402 Database Systems course at City University of Hong Kong, focusing on database indexing and transaction schedules. It includes detailed questions on calculating blocking factors, index entries, block accesses, and serialization graphs related to SMARTPHONE records and transactions. The assignment consists of three main questions, each requiring calculations and justifications based on given data and scenarios.

Uploaded by

LL 3708
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Department of Computer Science

City University of Hong Kong

CS3402 Database Systems (Sem B, 2024-2025)

Assignment 3
================================================================
Question 1. (50 marks)
Suppose that you have formatted your disk with a block size of 4096 bytes and assume
that we have 10,000 SMARTPHONE records of fixed length. A block pointer is 10
bytes long (P=10), and a record pointer is 8 bytes long (Pr=8). Each SMARTPHONE
record has the following fields: Brand (20 bytes), Model (20 bytes), Color (10 bytes),
Size (60 bytes), Weight (10 bytes), Price (8 bytes), Year (8 bytes), and Remarks (160
bytes). The file is ordered by the key field Brand, and we want to construct a primary
index on Brand.
Justify your answers and state any assumptions that you make!

(a) Calculate the blocking factor (bfr) and the number of file blocks needed to store the
SMARTPHONE records. Assume that records are stored unspanned. How much
space remains unused per block? [10 marks]

(b) Calculate the index blocking factor bfri. [5 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) Suppose we are going to retrieve a record based on the value of Brand. What is
the number of block accesses needed to search for a record without using the
primary index? And what is the number of block accesses using the single-level
index in sub-question (c)? [10 marks]

(e) Now, suppose that we want to make the primary index a multilevel index. How
many levels are needed and what is the total number of blocks required by the
multilevel index? [10 marks]

(f) Consider the multilevel index from sub-question (e). What is the number of block
accesses needed to search for and retrieve a record from the file, given its Brand
value? [5 marks]
Question 2. [30 marks]
Suppose that the size of a search key field is V=64 bytes, the size of a data (record)
pointer is Pr=8 bytes, and the size of a block pointer/tree pointer is P=8 bytes, the
block size B is 4096 bytes.
(a) If we want to construct a B+ tree, what is the maximum number of tree pointers in
an internal node? What is the maximum number of data pointers in a leaf node?
[15 marks]

(b) Assume that we have 15,000 SMARTPHONE records of fixed length; compute the
total number of blocks needed if (internal and leaf) nodes are approximately 60%
full. [15 marks]

Question 3. [20 marks]

Consider three transactions, T1, T2, and T3, and a schedule S, which are given below:

T1: r1 (X); r1 (Y); w1 (X); w1 (Y);


T2: r2 (Y); w2 (Z); w2 (Y); r2(Z);
T3: r3 (X); r3 (Z); w3 (Z); w3 (X);

S:r1(X); r2(Y); r3(X); r1(Y); r3(Z); w1(X); w2(Z); w1(Y); c1; w2(Y); w3(Z); w3(X); c3;
r2(Z); c2;

Notes: r1(X) denotes that T1 reads X, w2(Z) denotes that T2 writes Z, and c3 denotes
that T3 commits.
(a) 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). [10 marks]

(b) Determine the strictest recoverability condition (non-recoverable, recoverable,


cascadeless, or strict) that S satisfies. [10 marks]

You might also like