0% found this document useful (0 votes)
25 views6 pages

Indexing Transaction Examples

The document contains examples of database indexing and transaction scheduling. It discusses primary index characteristics, blocking factors, and the lost update problem in concurrency control. Additionally, it analyzes the serializability of schedules and the effects of interleaved transactions on data integrity.
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)
25 views6 pages

Indexing Transaction Examples

The document contains examples of database indexing and transaction scheduling. It discusses primary index characteristics, blocking factors, and the lost update problem in concurrency control. Additionally, it analyzes the serializability of schedules and the effects of interleaved transactions on data integrity.
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

Example#1

For a primary index, the data and index characteristics:


i. Size of a record = 150 bytes
ii. Size of a block = 4049 bytes
iii. Number of records = 85000 records

Index entery (field + pointer) = 40 byt


a) What is the blocking factor of the data file?

b) What is the blocking factor of the index file?

c) How many block accesses are required to retrieve a record using the index?
Example#2

(1) For a primary index, the data and index characteristics:


iv. Size of a record = 145 bytes
v. Size of a block = 2048 bytes
vi. Number of records = 95000 records
vii. Index entery (field + pointer) = 20 bytes

a. What is the blocking factor of the data file?

b. What is the blocking factor of the index file?

c. How many block accesses are required to retrieve a record using the index?

d. How many block accesses are required to retrieve a record if we do not use
the index?
Example#3

Consider schedule S1:

S1: r3 (X); r1 (X); r2 (Z); w2 (Z); r1 (Z); r3 (Y); r2 (Y); w2 (Z); w3 (Y); w1 (Z);

Place the operations in S1 in the table below according to their execution time.

T1 T2 T3
Draw the serializability (precedence) graph:

Is schedule S1 serializable?why?

No, schedule S1 is not serializable.

Reason:
The precedence graph for S1 contains a cycle between transactions T2 and T3 (T2 → T3 →
T2).
A cycle in the precedence graph means the schedule cannot be transformed into an
equivalent serial schedule.
Therefore, S1 is not conflict-serializable.
Example#4

The following two transactions are based on schedules S and have their operations
interleaved:

T1 T2

Read_item(A);

A := A- X;

Read_item(A);

A:= A + Y;

Write_item(A);

Read_item(B);

Write_item(A);

B: = B + X;

Write_item(B);

(i) These two transactions suffer from one of the concurrency control problems. Name the
problem and explain its effect.

Problem Name: Lost Update Problem

Explanation:

• Both T1 and T2 read the same value of A (80).

• T1 subtracts X = 3 → A becomes 77, then writes it.

• T2 (without knowing T1's update) adds Y = 2 to the old A = 80 → A becomes 82 and writes
it.

• The update from T1 is overwritten by T2’s write.

Result:
T1’s update is lost, and the final value of A is incorrect.
(ii) Assume that the initial values for A=80, B=80, X=3, and Y=2. What would be the values of A
and B after the S finishes.

Given:
A = 80, B = 80, X = 3, Y = 2

Execution Steps (interleaved):

• T1 → A = 77

• T2 → A = 82 (overwrites)

• T1 → B = 83

Final Values:

• A = 82 (should be 77, but was overwritten)

• B = 83

d. The diagram below illustrates a precedence graph of transactions T1, T2, and T3. With reasons,
specify whether it is conflict serializable or not.

Answer:

No, the schedule is not conflict serializable.

Reason:
The precedence graph contains a cycle, which means we cannot reorder
the transactions into a serial schedule without violating the conflicts.

You might also like