## Solutions - Relational Algebra Workshop 9

---

### Problem 1: Lost Update Problem

	* Outcome: Final X = 110 (T1’s update is lost because T2 overwrites later)
	* Final DB: X = 110 (T1’s +50 lost)
	
### Problem 2: Temporary Update (Dirty Read) Problem

	* Outcome: T2 commits Y based on dirty value; T1 aborts → inconsistent state
	* Final DB: X = 100 (rolled back), Y = 15 (committed from dirty read) → inconsistent
	
### Problem 3: Incorrect Summary Problem

	* Outcome: T1’s sum = 210 (incorrect), because it reads A before the transfer and B after
	* Final DB: A=90, B=110, total=200; T1 reported 210 (incorrect summary)
	
### Problem 4: Unrepeatable Read Problem

	* Outcome: T1’s second read differs from the first
	* Final DB: P=120; T1 observed unrepeatable read (100 then 120)
	
### Problem 5: Deadlock (with read_locks and write_locks)

	* Locks: read_lock(X), write_lock(X); upgrade to write needed before writing X
	* Outcome: Circular wait → deadlock; system aborts one transaction to resolve
	* Final DB: A=90, B=110; Deadlock resolved by aborting T2
	
---

 Remember that there are multiple ways to solve these problems, if you are unsure, post your solution in the workshop forums for discussion. 
