---
# System prepended metadata

title: DB Midterm 2022

---

# DB Midterm 2022

## 1. 
(a) explain ACID
(b) explain phantom read
## 2.
Why strict 2 phase lock need Tx to keep all blocks until complete?
## 3.
Why disk-based DBMS need to implement external merge sort than other algorithm?
## 4.
Why does Txs need concurrency?
(need to list at least one on single-core)
## 5.
Does log block need buffer pool? Why or Why not?
## 6.
What is the difference between lock and latch on DBMS?
## 7.
WAL
1) write log
2) write file
3) commit log
4) commit file
Can swap steps 3 and 4? Why or Why not?
## 8.
B(R\): block accessed for all in R
B(S): block accessed for all in S
m: all record in R
n: all record in S
(a)
for a in R:
    for b in S:
        find some a = b
use above to explain how many block accessed in this code
(b)
for BR in R:
    for BS in S:
        for a in BR:
            for b in BS:
                find some a = b
use above to explain how many block accessed in this code

## 9.
![](https://i.imgur.com/4L4giR4.png)
Which of them need to be thread-save?

## 10.

| Tx1 | Tx2 |
| - | - |
| read a | |
| write a | |
| | read a |
| write b | |
|  | write b |
|  | commit  |
| commit | |

(a) Is this serializable? 
If yes, write equivalent Serial. 
If no, why?
(b) Is this recoverable?

## 11.
A log file

disk

What is X, Y, Z, W using undo-redo recovery algorithm?

--- 

# DB Midterm 2023

## Q?.

What is the difference of purpose of er model and relatoonal model when designing your data model

##