HW-21 Transaction MGMT I
HW-21 Transaction MGMT I
1. Explain the ACID properties of transactions. What does the acronym stand for, and why is it important?
Atomic: The transaction needs to either be entirely performed or not performed at all, no half-done transactions
are allowed.
Consistent: Transactions that start from a database in a consistent state should end with the database in a
consistent state.
Isolated: Transactions should always function as if they were executing in isolation from other transactions.
Durable: Database changes made by a completed transaction must persist – even if the database fails
2. Provide real life examples demonstrating the applications of all 4 ACID properties.
Atomic: say a person wants to transfer his money from the checking account to saving account. In this
transaction, first deduce the amount of money in the checking account and then increase the same amount of
money in the saving account. But if the money is not deduced in the checking account, we should not increase
the amount of money in the saving account.
Consistent: say a person wants to transfer his money from the checking account to saving account. Both before
and after the transaction, the total amount of his checking and saving account should be the same. If it is not,
then the consistency is violated.
Isolated: say a person wants to check his balance on his credit card. At the same time, there is a charge to the
credit card. Then the balance he sees should not consider the simultaneous charge and the charge should not be
influenced by his view operation.
Durable: say there is a connection issue to the database. The database should be able to recover all transactions
and not lost any data result.
3. Write a transaction to add a new IP item of a certain type to your project DB. If the IP type does not exist, add it
as well.
Note: Groups will have different names for the tables and attributes. Syntax can
vary by RDBMS standard used, variations are permitted. Solution must include:
a) ROLLBACK on failure of either INSERT
b) COMMIT or END TRANSACTION
c) SELECT statement to check for existence of a record prior to inserting
BEGIN TRANSACTION NEW_ITEM
IF ((COUNT(*) AS COUNTA FROM IP_ITEM_TYPE WHERE IP_ITEM_TYPE.TYPE = TYPE) == 0)
THEN
INSERT OR ROLLBACK INTO IP_ITEM (“Store_Name”, “TYPE”);
4. For all the following questions, assume the following syntax: r1(X) means “Transaction 1 reads from
database item X”, w2(X) means “Transaction 2 writes to database item X”, a1 means “Transaction 1 aborts”
and c2 means “Transaction 2 commits”.
Which of the following schedules is (conflict) serializable? For each serializable schedule, determine the
equivalent serial schedules.
T3
x x
T3
T3
T3