0
0
MySQLquery~20 mins

ACID properties in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ACID Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Atomicity in Transactions

Which statement best describes the Atomicity property in database transactions?

AAll parts of a transaction must complete successfully, or none do.
BData must be visible to all users immediately after a transaction.
COnce a transaction is committed, changes can be undone automatically.
DTransactions must be isolated from each other to prevent interference.
Attempts:
2 left
💡 Hint

Think about whether a transaction can be partially done.

🧠 Conceptual
intermediate
2:00remaining
Isolation Levels and Their Effects

Which isolation level allows a transaction to read uncommitted changes made by other transactions?

ARepeatable Read
BSerializable
CRead Committed
DRead Uncommitted
Attempts:
2 left
💡 Hint

Consider the lowest isolation level that permits dirty reads.

query_result
advanced
2:00remaining
Effect of COMMIT on Durable Data

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?

ANULL
B1000
C0
DAn error because the transaction is not closed
Attempts:
2 left
💡 Hint

Think about what COMMIT does to the inserted data.

🔧 Debug
advanced
2:00remaining
Diagnosing a Lost Update Problem

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?

AIsolation
BConsistency
CAtomicity
DDurability
Attempts:
2 left
💡 Hint

Think about whether transactions interfere with each other.

📝 Syntax
expert
3:00remaining
Correct Use of SAVEPOINT and ROLLBACK

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
A
SAVEPOINT sp1;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
ROLLBACK;
COMMIT;
B
SAVEPOINT sp1;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
ROLLBACK TO sp2;
COMMIT;
C
SAVEPOINT sp1;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
ROLLBACK TO sp1;
COMMIT;
D
SAVEPOINT sp1;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
COMMIT;
ROLLBACK TO sp1;
Attempts:
2 left
💡 Hint

ROLLBACK TO must refer to an existing savepoint and happens before COMMIT.