You are on page 1of 4

TPS CAT TWO Y4S1

DUE DATE; 10/04/08

a) Compare and contrast the 2PL and Strict 2PL locking techniques, and suggest where each is most appropriate.

2PL(two phase locking) vs. S2PL (strict two phase locking)

Phases:

Growing phase: similar for both 2pl and s2pl; acquire all locks, no release of locks

Shrinking phase: different; 2pl: all locks are released , no acquiring of locks.

;s2pl: release all shared locks regularly(at the end of process ), release the exclusive locks only
after the transactions have committed.

Knowledge about the transaction:

For both transactions to determine the start of the phase 2(end of phase 1) requires explicit knowledge about the
transactions (e.g. the ordering of the data access). However for s2pl where exclusive locks are involved this might
not be necessary since the locks are released at the transaction end.

End of phase 1:

2pl: to end phase 1 requires explicit knowledge about the transaction. Where 2 or more processes are involved a
synchronization point is needed among them in order to determine the end of phase 1(growing phase). Such a point
is expensive to maintain.

S2pl; end of phase 1 must also be known in order to release the shared locks, however for exclusive locks the phase
2 is usually merged with the end of the transaction ie. Some of the locks are released at the end of the transaction.
At such a point the phase 2 is not needed.

Practicality:

2pl and s2pl have great theoretical importance, in fact all s2pl locking protocols must satisfy 2pl protocols. However
both 2pl and s2pl are not known to be used in practice and thus have no much practical importance. An improved
version of both; the strong strict two phase locking(ss2pl) is popularly used .

Usage:

2pl;

properties:

 Cascading rollbacks are possible.


 Conflict serializable schedules cannot be obtained.
 Requires explicit information about the transaction

Though rarely used, 2pl can be suitably applied where Conflict serializable schedules and rollback issues are not of
paramount importance, also where explicit information about the transaction is provided.

S2pl:
The protocol is used where cascading rollbacks are not allowed since this is usually eliminated by the release of
the exclusive locks only at after the transaction commits.

b) Compare and contrast the use of OLAP and OLTP, using any DBMS of your choice in a particular business use,
while suggesting where each can be used in your business example

Online transaction processing (OLTP) refers to a class of business systems that facilitate and manage
transaction-oriented applications, typically for data entry and retrieval transaction processing (Wikipedia,2012).

Online analysis processing (OLAP) on the other hand is part of the broader category of business intelligence,
which also encompasses relational reporting and data mining. Typical applications of OLAP include business
reporting for sales, marketing, management reporting, business process management budgeting and
forecasting, financial reporting and similar areas. The term OLAP was created as a slight modification of the
traditional database term OLTP (Online Transaction Processing)(Wikipedia,2012) . the following are feature to
feature comparisons between the two systems.

OLAP OLTP

Queries: are normally complex and involve aggregations Queries: are normally short and simple (return only a
(putting together a group of records). few records).

Data: uses consolidated data from other databases, usually Data: they are basically the source of data. The data
relational databases. result from processing of fundamental business
transaction (business processing).
Purpose: these systems analyse data, are designed to help
the business management in planning and decision making. Purpose: control and run fundamental business
transactions. E.g. purchasing, sales, accounting etc.
Nature of transactions: They are characterized by low
number of queries; involve aggregating records and complex Nature of transactions: normally there are a large
analysis. number of queries; comprise of updates, deletes and
inserts.
Updates: are periodic and come in batches, can take a very
long time to complete. Updates: are frequent, usually take a short time.

Databases: uses multidimensional databases which provide Databases: relational databases are suitably used.
various views of the business activities e.g. Time, product. Usually normalized with many tables.
Usually de-normalized and with few tables.
Recovery: most of these systems maintain back-ups
Recovery: when the database data is corrupted the system of the databases for use in recoveries in case of
designers prefer re-loading the from the source other than failures. These back-ups are frequently updated to
maintaining back -ups incorporated latest changes.

Usage:
OLTP: retail stores e.g. supermarkets; to automate inventory, sales and revenues accounting, e.g. Record the
cashiers’ sales.
OLAP: can be used on the same but now to analyze the generated data , to even may be forecasts sales and
revenues in various dimensions such as time, per retail branch, per region etc.

c) Explain how transactions are implemented in distributed database systems.

Two methods are commonly used:

1. Private Workspace
2. Two-phase Commit Protocol

Private Workspace

Conceptually when a process starts a transaction it is given a private workspace containing all objects to which it has
access. Until the transaction either commits or aborts, all its read and writes go to the private workspace, rather
than the real object (file system). Cost of copying everything to a private workspace is prohibitive

Several optimizations possible:

 when a process reads a file but does not modify it, there is no need for a private copy
 when a file is opened for writing, instead of copying the entire file, only the file’s index is copied into the
private workspace

Two-phase Commit Protocol

One of the processes involved functions as the coordinator and executes the transaction. Coordinator writes a log
entry saying that it is starting the commit protocol, followed by sending each of other processes involved a message
telling them to prepare to commit. The subordinate checks itself and decides whether to commit or not. It then
sends the decision to the coordinator. After receiving all responses, the coordinator can then commit or abort. If
one process refuses to commit, the coordinator must abort.

Concurrency control

Concurrency control algorithm is needed to keep all the processes that are executing simultaneously out of each
other’s way. The methods used are; Locking, Optimistic concurrency control algorithm, Timestamps.

Locking: when a process needs to read or write a file as a part of a transaction, it first locks the file.

Optimistic concurrency control algorithm: let the processes go ahead and do whatever they want to do without
paying attention to what everybody else is doing and if there is a problem worry about it later.

Timestamps: assign each transaction a timestamp at the moment it does begin a transaction. Ensure timestamps are
unique. If transactions are short and widely spaced in time, it will normally occur that when a process tries to access
a file, the file’s read and write timestamps will be lower than the current transaction’s timestamp. This ordering
means that the transactions are being processed in the right order, so everything is all right.

You might also like