Unit 6 Databases, Serialisability, Transactions and 2 Phase Locking Flashcards

1
Q

What is a database?

A

A database is an organised collection of data, and is said to be a form of persistent storage.

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

What are the (ACID) desirable properties of a transaction?

A

Atomicity - either all steps occur, or none at all
Consistency - The system remains in a consistent state
Isolation - the transaction cannot reveal any part of its state til the transaction is committed.
Durability - once committed the result will persist.

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

What are the methods of UserTransaction?

A

begin(), commit(), rollback()

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

What are the states of a Transaction?

A

ACTIVE - initial state and while it is executing
PARTIALLY COMMITTED - the state after the final operation has been executed. It remains here while the system writes information to disk.
COMMITTED - the state after successful completion.
FAILED - when normal exection cannot proceed
ABORTED - following rollback() ie all effects are undone and the database is restored to its original state.

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

Compare the concept of a transaction with that of a coarse grained atomic action. What are their differences and similarities?

A

Both are as series of steps that need to be implemented ‘as one’. They give the appearance of indivisibility.
The difference is that a transaction has FAILURE ATOMICITY (if it fails it is as though it never happened in the first place, if it succeeds it is made persistent).

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

What are the possible next states following PARTIALLY COMMITTED for a transaction?

A

It can progress to COMMITTED once the write completes and the data is made persistent.
Or if there is a problem it will enter FAILED and then ABORTED.

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

What does the TP system do?

A

The TP (Transaction Processing) system manages the correct and efficient execution of transactions.

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

Serialisability - What is a schedule?

A

A schedule is a preserved, chronological order of operations.

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

Serialisibility - What is a serial schedule?

A

A serial schedule is one where the transactions are executed in strict serial order.

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

Give the definition of serialisibility.

A

Serialisability is a schedule for a group of transactions that behaves as though it were executed in serial order. ie the results are the same

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

Is it a problem if serial schedules do not give the same final results for the data object involved?

A

No it is not. The main concern is whether the data objects are in a consistent state.

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

What are conflicting operations?

A

Operations conflict if the order in which they are executed affects the result (e.g read/write)

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

How is the notion of conflicting operations used to determine whether a schedule is serialisable?

A

We need to determine what the conflicting operations are. Then we need to determine the order they are executed by transactions. If the oPrrder is the same then we know the schedule is equivalent to a serial schedule..

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

Precedence graphs can be used to show conflicting operations of transactions. What would the presence of a cycle in a precedence graph mean?

A

It would mean the schedule it represents is not serialisable.

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

Why is it important to make schedules of multiple concurrent transactions serialisable?

A

To keep the transaction ISOLATION property intact (ACID).

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

What is the aim of two-phase locking?

A

To ensure the effects of the transactions on shared data is serially equivalant.

17
Q

How does two phase locking work?

A

A transaction is either in acquire phase or release phase. Once the transaction starts to release it cannot acquire any further locks.

18
Q

What is the difference between strict 2PL and 2PL?

A

In the strict form all locks are released on commit.

In the non-strict form the locks are gradually released

19
Q

What are the two classes of concurrency control mechanism?

A

Pessimistic algorithms assume there are likely to be conflicts and take measures to avoid them.
Optimistic algorithms assume conflicts will be rare, and can dealt with after the event.

20
Q

Name two types of pessimistic algorithm

A

Two-phase locking and Time Stamp Ordering.

21
Q

How does Time Stamp ordering work as an algorithm of concurrency control?

A

Each object has a time stamp associated with the transaction that accessed it most recently. If another transaction requests an operation that conflicts with one that has been carried out previously on this object the time stamp is compared. If the transaction’s time stamp is earlier than the one recorded by the object the transaction must abort and restart with a later timestamp.
Basically the time stamp cannot go backwards.

22
Q

Name some advantages of Time Stamp Ordering.

A

it is efficient and has fewer deadlock problems than locking.
It is simple - few overheads.

23
Q

Name some disadvantages of time-stamp ordering.

A

It can suffer from high levels of aborts.

May be more restrictive than 2PL.

24
Q

What is the main goal of optimistic concurrency control?

A

To avoid the overheads of locking managment, deadlock prevention or detection.

25
Q

When would you use an optimistic concurrency control algorithm?

A

When the likelihood of clients accessing the same data is low, and a fast response is important.

26
Q

In 2PL what is a shared lock and why might we want to use one?

A

A shared lock is useful for non-conflicting operations, such as two read operations. If a shared lock can be used it increases concurrency.

27
Q

What is a simple alternative to deadlock detection?

A

Timeouts.

28
Q

What are cascading aborts and what causes them?

A

Cascading aborts occur when one transaction aborts and this leads to other transactions having to abort. It means work has to be repeated.

29
Q

Distinguish between volatile memory, persistent storage and stable storage.

A

Volatile memory would be lost if the device is switched off.
Persistent storage remains after the device is switched off.
Stable storage is stored at least twice for added security.

30
Q

Which of the ACID properties of transactions are addressed through crash resilience?

A

Atomicity - transactions are all or nothing

Durability - crash resilience ensures that if the transaction has committed its results are stored in persistent memory.

31
Q

What is meant by rolling back.

A

In the even that a transaction cannot happen then the system is restored to the state is was in prior to the transaction starting.

32
Q

In Logging, what might happen if log information is written to the persistent store after the data is updated by the atomic operation is written there?

A

There would be no record of the data in the event a roll back was required. Logging should be ‘write-ahead’.

33
Q

What is shadowing? What essential feature is required to ensure that shadowing is implemented successfully?

A

Shadowing is where a copy of the original state of the data is kept and another copy is updated. Once the updated copy is committed, then the original copy can be deleted.
The essential feature is that the replacement of the relevant part of the persistent store is done atomically.

34
Q

What is the purpose of JDBC?

A

Provides a standard interface for communication with a large number of databases.

35
Q

What are the steps involved in setting up a connection between a Java application and a database using JDBC?

A
  1. The application causes the database driver to be loaded.
  2. The application requests a connection for the particular database and the driver manager requests all registered drivers to respond with a connection.
  3. The driver manager returns a connection to the application.
  4. communication through the JDBC connection to the database.