---
# System prepended metadata

title: Database Transation
tags: [DBMS]

---

# Database Transation
###### tags: `DBMS`

## Motivation for Conconcurrent Control in DBMS
`reference`: [here](https://www.youtube.com/watch?v=12X58NloDo0&t=755s&ab_channel=Techtud)

* Lost update
Lose update of one if the Transaction since it read the old value:
![](https://i.imgur.com/MApgdvB.png)

* Temporary Update
One of the Transaction fail, and roll back to original value. However, another transaction read the updated value (which is invalid), and have the following transaction based on that
![](https://i.imgur.com/pPzi24s.png)

* Incorrect Summary
One Transaction try to summary; however, another transaction have operation on one of the value that is being summarized, resulting wrong summary value
![](https://i.imgur.com/ZxjcRPV.png)

## Concept of Transaction
### Recovery of DBMS
The DBMS has to ensure it transaction would all or none if it fail at some point. It need to recover the original point before the transatin.

Possible Fail is as the following:
![](https://i.imgur.com/SKZexpc.png)

### Status of Transaction
![](https://i.imgur.com/nqzBOjY.png)

### System Log
Need a log to record all the transaction and status (e.g. commit)

## ACID
`reference`: [here](https://www.youtube.com/watch?v=yaQ5YMWkxq4&ab_channel=theroadmap)
The four principal in DBMS could avoid above mentioned issue
### Atomicity
The transation would be complete without any interference
### Consistency
The Constraint in data field would not be compromised
### Isolation
Multiple transaction occur, each transaction would occur serial
### Durability
Once a transaction is commited, it would be in non-volatile forever