Transactions Flashcards

1
Q

What is a database transaction?

A

A unit of program execution that accesses and possibly updates various data items delimited by begin transaction and end transaction statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the ACID acronym stand for in database transactions?

A

Atomicity Consistency Isolation Durability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is atomicity in database transactions?

A

Either all operations of the transaction are reflected in the database or none are

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is consistency in database transactions?

A

The database remains in a consistent state before and after transaction execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is isolation in database transactions?

A

Each transaction appears to execute alone even when multiple transactions run concurrently

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is durability in database transactions?

A

Once a transaction completes successfully its changes persist even if system failures occur

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two basic operations transactions use to access data?

A

read(X) and write(X)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the five possible states of a transaction?

A

Active Partially committed Failed Aborted Committed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens in the partially committed state?

A

Final statement executed but transaction may still need to be aborted as data might still be in main memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is conflict serializability?

A

A schedule that can be transformed into a serial schedule by swapping non-conflicting operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When do two operations conflict in a transaction schedule?

A

When they are from different transactions operate on same data item and at least one is a write operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you determine if a schedule is conflict serializable?

A

Create a precedence graph - if it has no cycles the schedule is conflict serializable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a recoverable schedule?

A

One where transactions commit only after all transactions whose changes they read have committed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a cascadeless schedule?

A

One where transactions only read data written by committed transactions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the three main implementation techniques for transaction isolation?

A

Locking Timestamp ordering and Versioning

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is snapshot isolation?

A

A versioning technique where each transaction works with its own version of the database when it begins

17
Q

What information does a precedence graph contain?

A

Vertices represent transactions edges represent conflicts between operations

18
Q

What are the two ways to handle an aborted transaction?

A
  1. Restart it (if aborted due to hardware/software error) 2. Kill it
19
Q

What is cascading rollback?

A

When failure of one transaction forces rollback of other dependent transactions

20
Q

What is view serializability?

A

A schedule that is equivalent to a serial schedule in terms of initial reads writes and final writes

21
Q

Why is concurrent execution of transactions preferred over serial execution?

A

Two reasons: 1) Improved throughput and resource utilization 2) Reduced waiting time for transactions

22
Q

What is the fundamental problem with immediate external writes (like ATM cash dispense) in transactions?

A

They cannot be undone once executed so they should only occur after the transaction has fully committed

23
Q

What is stored in a transaction log?

A

The old values of any data on which a transaction performs a write stored on disk for recovery purposes

24
Q

What are the three conditions for two schedules to be view equivalent?

A

1) Same initial reads 2) Same reads following writes 3) Same final writes for each data item

25
Q

For conflict operations what are the four possible combinations and which ones conflict?

A

read-read: no conflict read-write: conflict write-read: conflict write-write: conflict

26
Q

What’s the main difference between view serializability and conflict serializability?

A

Every conflict serializable schedule is view serializable but not vice versa. View serializability is also NP-complete to check

27
Q

What happens when a transaction enters the failed state?

A

The system determines it can’t proceed with normal execution and must be rolled back to enter the aborted state

28
Q

What is a compensating transaction?

A

A transaction that reverses the effects of a committed transaction when external actions can’t be undone (like ATM cash dispense)

29
Q

What must be true about the read and write timestamps in timestamp-based concurrency control?

A

Read timestamp holds the largest (most recent) timestamp of transactions that read the item; write timestamp holds the timestamp of the transaction that wrote the current value

30
Q

In locking implementation what’s the difference between database-level and item-level locking?

A

Database-level locking locks the entire database for each transaction while item-level locking only locks the specific data items being accessed