Interactive demonstration of database transaction concepts

๐Ÿ”„ Transaction States

โ„น๏ธ

๐Ÿ’ก How to use: Click the simulation buttons to watch transactions move through their lifecycle. Each state represents a different phase in transaction processing.

Active
Transaction is running
Partially Committed
Transaction completed but not yet committed
Committed
Transaction successfully completed
Failed
Transaction encountered an error
Aborted
Transaction was rolled back

โšก ACID Properties Demonstration

โ„น๏ธ

๐Ÿ’ก Learn by doing: Each property has interactive examples. Click the buttons to see ACID principles in action with real scenarios.

๐Ÿ’Ž Atomicity

All operations in a transaction succeed or all fail

Example: When transferring money, both debit and credit must happen together, or neither should happen.

โš–๏ธ Consistency

Database remains in a valid state after transaction

Example: Account balance can never go below $0. Try withdrawing more than available!
๐Ÿ’ฐ Rule: Account balance โ‰ฅ $0 (Current: $1000)

๐Ÿ๏ธ Isolation

Concurrent transactions don't interfere with each other

Example: Multiple users can work with the database simultaneously without seeing each other's uncommitted changes.

Transaction 1

Idle

Transaction 2

Idle

๐Ÿ’ช Durability

Committed transactions survive system failures

Example: Even if the system crashes, committed transactions are permanently saved and can be recovered.
System Online

โš ๏ธ Dirty Read Simulation

โ„น๏ธ

๐Ÿ’ก Watch the problem: Transaction 1 updates data but hasn't committed yet. Transaction 2 reads this "dirty" data and makes decisions based on it. When Transaction 1 rolls back, Transaction 2 has wrong information!

Transaction 1 (Writer)

1. BEGIN TRANSACTION
2. UPDATE balance = 1500 WHERE id = 1
3. (Transaction running...)
4. ROLLBACK

Transaction 2 (Reader)

1. BEGIN TRANSACTION
2. SELECT balance WHERE id = 1
3. Process with dirty data: 1500
4. COMMIT (with wrong data!)

Database State

ID Balance Status
1 1000 Committed

๐Ÿ” GRANT and REVOKE Privileges Demo

โ„น๏ธ

๐Ÿ’ก Try it yourself: Grant privileges to users, then test operations to see access control in action. Notice how users can only perform operations they have permission for!

Database Users

Alice (Admin)
ALL PRIVILEGES
Bob (Analyst)
No privileges
Charlie (Intern)
No privileges

Sample Database: employees

ID Name Salary Department
1 John Doe $75,000 Engineering
2 Jane Smith $82,000 Marketing
3 Mike Johnson $68,000 Sales

Privilege Management

Test Operations