Idempotency is another important topic after the ACID properties.
Idempotency means:
Performing the same operation multiple times should give the same result, not duplicate effects.
Scenario: Duplicate Transfer
I ran the same transfer twice:
~ First transfer
UPDATE accounts SET balance = balance - 200 WHERE name = 'Christina';
UPDATE accounts SET balance = balance + 200 WHERE name = 'Sharon';
~ Same transfer again (duplicate)
UPDATE accounts SET balance = balance - 200 WHERE name = 'Christina';
UPDATE accounts SET balance = balance + 200 WHERE name = 'Sharon';
What Happened?
- Christina lost ₹400
- Sharon gained ₹400
The system allowed duplicate processing
What I learned
- Database does NOT automatically prevent duplicates
- Same request executed twice = double transaction
- This can lead to wrong balances
Top comments (0)