Which statement best describes the Atomicity property in database transactions?
Think about whether a transaction can be partially done.
Atomicity means a transaction is all or nothing: either every step succeeds or the database stays unchanged.
Which isolation level allows a transaction to read uncommitted changes made by other transactions?
Consider the lowest isolation level that permits dirty reads.
Read Uncommitted isolation level allows transactions to see uncommitted changes, which can cause dirty reads.
Consider this sequence of SQL commands in MySQL:
START TRANSACTION; INSERT INTO accounts (id, balance) VALUES (1, 1000); COMMIT; SELECT balance FROM accounts WHERE id = 1;
What will the SELECT query return?
Think about what COMMIT does to the inserted data.
COMMIT makes the inserted data permanent and visible, so the SELECT returns 1000.
Two transactions run concurrently on the same row in a table. Transaction A reads a value, Transaction B updates it and commits, then Transaction A updates the value based on its old read and commits.
What ACID property is violated here?
Think about whether transactions interfere with each other.
This is a classic lost update problem caused by lack of proper isolation between transactions.
Which of the following MySQL transaction sequences correctly uses SAVEPOINT and ROLLBACK to undo part of a transaction without aborting the entire transaction?
-- Assume a transaction is started
ROLLBACK TO must refer to an existing savepoint and happens before COMMIT.
Option C correctly creates a savepoint, rolls back to it (undoing the update), then commits the rest.
Option C rolls back the entire transaction, not just to the savepoint.
Option C tries to rollback to a non-existent savepoint sp2.
Option C tries to rollback after commit, which is invalid.