Question 1 Flashcards

1
Q

What is a transaction?

A

A sequence of one or more SQL statements that are executed as a single, logical unit of work. It ensures the consistency and integrity of a database.

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

Name the 5 transaction properties.

A
  • Atomicity
  • Consistency
  • Isolation
  • Durability
  • Serializability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is transaction Atomicity?

A

Ensures a transaction is treated as a single, logical unit of work. Either all of its operations are completed, or none are. If any part of the transaction fails, the entire transaction is rolled back.

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

What is transaction Consistency?

A

A transaction should bring the database from one consistent state to another. It means that the integrity constraints and business rules must be satisfied before and after the transaction.

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

What is transaction Isolation?

A

A database transaction property in which a data item used by one transaction is unavailable to other transactions until the first one ends.

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

What is transaction Durability?

A

The transaction property that ensures that once transaction changes are done and committed, they cannot be undone or lost, even in the event of a system failure.

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

What is transaction Serializability?

A

A property in which the selected order of concurrent transaction operations creates the same final database state that would have been produced if the transactions had been executed serially.

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

What is the Transaction log?

A

The transaction log records all operations that modify the database.

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

What is the function of the Transaction Log?

A

This log is essential for recovery, allowing the system to undo uncommitted changes (via ROLLBACK) in case of system failures, program crashes, or network issues.

Some systems, like Oracle, also use the log to recover and bring the database to a consistent state by rolling back uncommitted transactions and applying committed ones that haven’t been saved to disk.

This ensures data integrity and consistency in transactional databases.

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

Define Locking Methods.

A

Involves placing locks on database objects (e.g., rows, tables) to prevent concurrent transactions from accessing or modifying the same data simultaneously.
Locking is controlled by a lock manager.

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

Name the 5 Lock Granularity levels.

A
  1. Database-level: Restricts access to the owner of the lock and allows only one user at a time to access the database.
  2. Table-level: Allows only one transaction at a time to access a table.
  3. Page-level: An entire disk page or section of a disk is locked.
  4. Row-level: Allows concurrent transactions to access different rows of the same table, even if the rows are on the same page.
  5. Field-level: Allows concurrent transactions to access the same rows as long as they require the use of different attributes within that row.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Name 3 lock types.

A
  1. Binary lock: Has only two states, locked (1) and unlocked (0). If a data item is locked, no other transaction can use that data item.
  2. Exclusive lock: Issued when one or more transactions must update (WRITE) a data item. Therefore, an exclusive lock is issued only when a transaction must WRITE (update) a data item and no locks (not shared or exclusive) are currently held on that data item by any other transaction.
  3. Shared lock: Issued when a transaction must read data from the database and no exclusive locks are held on the data to be read.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Deadlock?

A

Occurs when two transactions wait indefinitely for each other to unlock data.

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

Name 3 Deadlock control techniques.

A
  • Avoidance: The transaction must obtain all the locks needed before it can be executed.
  • Prevention: Transaction requesting a new lock is aborted when there is a possibility that a deadlock can occur.
  • Detection: DBMS tests the database periodically for deadlocks, if found, the victim transaction is aborted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Two-phase Locking?

A

A set of rules that manage how transactions acquire and release locks to ensure serializability, though it doesn’t prevent deadlocks.

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

What is Concurrency Control?

A

Coordination of the simultaneous execution of transactions in a multiuser database system.

17
Q

What are the two phases in Two-phase Locking?

A
  1. Growing phase: The transaction acquires all the locks it needs without releasing any.
  2. Shrinking phase: After reaching its locked point (where all necessary locks are obtained), the transaction releases its locks and cannot acquire new ones.
18
Q

What is the Objective of Concurrency Control?

A

Ensure serializability of transactions to guarantee data integrity and consistency in a database management system.

19
Q

What are 3 Data integrity and consistency problems?

A
  • Lost updates: Occurs in two concurrent transactions when: Same data element is updated and one of the updates is lost.
  • Uncommitted data: Occurs when 2 transactions are executed concurrently, first transaction is rolled-back after the second transaction has already accessed uncommitted data.
  • Inconsistent retrievals: Occurs when a transaction accesses data before and after one or more other transactions finish working with such data.
20
Q

What is Time Stamping and name 2TS Methods?

A

Time stamping assigns a global unique time stamp to each transaction

  • Uniqueness: Ensures no equal time stamp values exist
  • Monotonicity: Ensures time stamp values always increased
21
Q

Name 2 Time-Stamping-based strategies.

A
  1. Wait/Die: The older transaction waits, while the younger transaction rolls back and is rescheduled with the same time stamp.
  2. Wound/Wait: The older transaction rolls back the younger one, which is then rescheduled with the same time stamp.
22
Q

What are Optimistic methods and name 3 phases?

A

Optimistic approach assumes that most database operations do not conflict.

  1. Read Phase: The transaction reads data and makes updates to a private copy, storing changes in a temporary file.
  2. Validation Phase: The transaction is checked to ensure its changes won’t compromise database integrity. If validation fails, the transaction is restarted.
  3. Write Phase: Successful changes are permanently applied to the database.
23
Q

What is database recovery?

A

Restores an inconsistent database to a previously consistent state after critical events like hardware/software failures, human errors, or natural disasters.

24
Q

Name 2 recovery techniques.

A
  • Deferred-Writes: Only logs are updated, actual updates made once transaction commits.
  • Write-Through: Updates made instantly; rollback needed on failure.
25
Q

Name 4 Key Concepts of Database Recovery.

A
  1. Write-Ahead Log Protocol (WAL): Logs before updating the database
  2. Redundant Transaction Logs: Multiple log copies to prevent data loss.
  3. Buffering: Temporary storage for efficient operation.
  4. Checkpoints: Sync database and transaction logs by writing buffers to disk.