
Durability in Wallet Transfer System
In this task, I understood the Durability property of ACID using a wallet system. Durability means that once a transaction is committed, the data will be permanently stored in the database and will not be lost even if the system crashes or restarts. First, I created the accounts table. CREATE TABLE accounts ( id SERIAL PRIMARY KEY, name TEXT NOT NULL, balance INT NOT NULL CHECK (balance >= 0), last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); Then I inserted sample data. INSERT INTO accounts (name, balance) VALUES ('Alice', 1000), ('Bob', 500); To check the initial data: SELECT * FROM accounts; Alice had 1000 and Bob had 500. Next, I performed a successful transaction to transfer 300 from Alice to Bob. BEGIN; UPDATE accounts SET balance = balance - 300 WHERE id = 1; UPDATE accounts SET balance = balance + 300 WHERE id = 2; COMMIT; After committing, I checked the data again. SELECT * FROM accounts; Now Alice had 700 and Bob had 800. Then I simulated a system restart by reconnecting to
Continue reading on Dev.to
Opens in a new tab




