Coconote
AI notes
AI voice & video notes
Export note
Try for free
Lecture on Transactions
Jul 1, 2024
Lecture on Transactions
Definition of Transaction
A
set of operations
used to perform a
logical unit of work
.
Commonly associated with
monetary transactions
(give and take money, withdrawing, debiting, or crediting).
Transactions can also involve any change or reading of a database.
Example of a Transaction: ATM Withdrawal
Task:
Withdraw money
Operations:
Insert card
Read information (balance, authenticity)
Choose language
Select account type (savings/current)
Enter amount
Enter PIN
Dispense money
Transaction completion message
These steps form a
transaction
.
Example of a Transaction: Online Fund Transfer
Operations:
Authenticate (username and password)
Select/Add beneficiary
Enter amount
Receive and enter OTP
Enter transaction password
Transaction completion message
Transactions in Databases
Transactions usually represent
changes in a database
.
Banking systems
use databases to store account holder details, money, etc.
When transactions occur, data is fetched from the database and changes are made.
Major operations in a database transaction:
Read:
Access the database to fetch data.
Write:
Make changes to the data.
Detailed Walkthrough of a Database Transaction
Scenario:
Transferring money from Account A to Account B
Steps:
Read
account A balance from hard disk to RAM (e.g., A = $1000)
Perform operation:
A = A - 500 (new A balance = $500 in RAM)
Read
account B balance from hard disk to RAM (e.g., B = $2000)
Perform operation:
B = B + 500 (new B balance = $2500 in RAM)
Commit:
Save changes from RAM to hard disk (permanent changes).
Other operations: Commit and Rollback
Commit:
Save all changes permanently.
Rollback:
Revert changes (not covered in detail).
Key Points
**CPU and Memory: **
CPU performs operations in RAM, not directly on the hard disk.
This ensures speed as CPU is fast, and hard disk is slow.
Data must be in RAM or cache for the CPU to work on it.
Summary
Read:
Fetch data from the database.
Write:
Make changes to the data.
Commit:
Save changes permanently to the database.
Transactions:
A set of operations to complete tasks and change or access a database.
Transaction states and properties will be discussed further.
📄
Full transcript