0% found this document useful (0 votes)
7 views3 pages

HW-21 Transaction MGMT I

The document explains the ACID properties of transactions, which stand for Atomicity, Consistency, Isolation, and Durability, emphasizing their importance in ensuring reliable database transactions. It provides real-life examples for each property and includes a SQL transaction example for adding a new IP item to a database, incorporating rollback and commit commands. Additionally, it evaluates the serializability of various transaction schedules, identifying which are conflict serializable and providing equivalent serial schedules.

Uploaded by

Li Dailin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

HW-21 Transaction MGMT I

The document explains the ACID properties of transactions, which stand for Atomicity, Consistency, Isolation, and Durability, emphasizing their importance in ensuring reliable database transactions. It provides real-life examples for each property and includes a SQL transaction example for adding a new IP item to a database, incorporating rollback and commit commands. Additionally, it evaluates the serializability of various transaction schedules, identifying which are conflict serializable and providing equivalent serial schedules.

Uploaded by

Li Dailin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CSE3241 Activity – Transaction Mgmt I

Name: Dailin Li Date: 11/18/2021

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”);

INSERT OR ROLLBACK INTO IP_ITEM (“IP_Address”, “TYPE”, PRICE);


COMMIT:
GO TO FINISH;
FINISH:
END TRANSACTION;

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.

a) r1(X); r3(X); w1(X); r2(X); w3(X)


T1 T2
x
Not serializable. There is a cycle (T1-T3).
x x Specifically, T3 reads before T1 writes and then T3 writes.

T3

b) r1(X); r3(X); w3(X); w1(X); r2(X)


Not serializable. There is a cycle (T1-T3).
Specifically, T1 reads before T3 writes and then T1 writes. T1 T2
x

x x

T3

c) r3(X); r2(X); w3(X); r1(X); w1(X)


Serializable.
Specifically, Although T2 reads before T3 writes, T2 does not write after. x
Equivalent to r3(X); w3(X); r2(X); r1(X); w1(X); T1 T2
x

T3

d) r3(X); r2(X); r1(X); w3(X); w1(X) x


T1 T2
Not serializable. There is a cycle (T1-T3). x
Specifically, T1 reads before T3 writes and then T1 writes.
x x

T3

You might also like