
ASSIGNMENT 34
* Design a transaction using the given accounts table to transfer money from one user to another by debiting the sender and crediting the receiver within a single transaction block. Then introduce errors at different stages of the transaction (such as after the debit operation) and observe whether the database allows partial updates or rolls back the entire transaction. Analyze the results to verify that atomicity is maintained, ensuring that either both operations succeed or none are applied. * Introduction In a digital wallet system (like PhonePe/GPay/Paytm), Atomicity ensures: A transaction is completed fully or not executed at all. This is critical because: Partial updates → money loss Failed transfers → inconsistent balances Atomicity guarantees: Either both debit and credit happen Or nothing happens Given Table Code CREATE TABLE accounts ( id SERIAL PRIMARY KEY, name TEXT NOT NULL, balance INT NOT NULL CHECK (balance >= 0), last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); Init
Continue reading on Dev.to Tutorial
Opens in a new tab



