Transaction Processing Concepts
Transaction Processing Concepts
Transaction Processing Concepts
One criterion for classifying a database system is according to the number of users
who can use the system concurrently—that is, at the same time. A DBMS is single-user if at
most one user at a time can use the system, and it is multiuser if many users can use the
system—and hence access the database—concurrently. Single-user DBMSs are mostly
restricted to some microcomputer systems; most other DBMSs are multiuser. For example, an
airline reservations system is used by hundreds of travel agents and reservation clerks
concurrently. Systems in banks, insurance agencies, stock exchanges, supermarkets, and the
like are also operated on by many users who submit transactions concurrently to the system.
Multiple users can access databases—and use computer
systems—simultaneously because of the concept of multiprogramming, which allows the
computer to execute multiple programs—or processes—at the same time.
A transaction is a logical unit of database processing that includes one or more
database access operations—these can include insertion, deletion, modification, or retrieval
operations. The database operations that form a transaction can either be embedded within an
application program or they can be specified interactively via a high-level query language
such as SQL. One way of specifying the transaction boundaries is by specifying explicit
begin transaction and end transaction statements in an application program; in this case, all
database access operations between the two are considered as forming one transaction. A
single application program may contain more than one transaction if it contains several
transaction boundaries. If the database operations in a transaction do not update the database
but only retrieve data, the transaction is called a read-only transaction.
A database is basically represented as a collection of named data items. The size
of a data item is called its granularity
The basic database access operations that a transaction can include are as follows:
• read_ item(X): Reads a database item named X into a program variable. To simplify
our notation, we assume that the program variable is also named X.
1. • write_item(X): Writes the value of program variable X into the database item named
X.
Transaction includes read_item and write_item operations to access and update the database.
The read-set of a transaction is the set of all items that the transaction reads, and the
write-set is the set of all items that the transaction writes.
T1 T2
read_item(X);
X=X-N; Read_item(X);
X=X+M;
write_item(X);
read_item(Y);
Write_item(X);
Y=Y+N;
write_item(Y);
T1 T2
read_item(X);
X=X-N;
write_item(X);
read_item(X);
X=X+M;
Write_item(X);
read_item(Y);
Transaction T1 fails and must change the value of X back to its old value meanwhile T2 has
read the temporary incorrect value of x
Another problem that may occur is called unrepeatable read, where a transaction T reads an
item twice and the item is changed by another transaction T between the two reads. Hence, T
receives different values for its two reads of the same item. This may occur, for example, if
during an airline reservation transaction, a customer is inquiring about seat availability on
several flights. When the customer decides on a particular flight, the transaction then reads
the number of seats on that flight a second time before completing the reservation
Types of Failures
Whenever a transaction is submitted to a DBMS for execution, the system is
responsible for making sure that either all the operations in the transaction are completed
successfully and their effect is recorded permanently in the database, or the transaction has
no effect the database or on any other transactions. The DBMS must not permit some
operations of a transaction T to be applied to the database while other operations of T are not.
This may happen if a transaction fails after executing some of its operations but before
executing all of them.
Types of Failures
Failures are generally classified as transaction, system, and media failures. There are several
possible reasons for a transaction to fail in the middle of execution:
1. A computer failure (system crash): A hardware, software, or network error occurs in
the computer system during transaction execution. Hardware crashes are usually
media failures—for example, main memory failure.
2. A transaction or system error: Some operation in the transaction may cause it to fail,
such as integer overflow or division by zero. Transaction failure may also occur
because of erroneous parameter values or because of a logical programming error . In
addition, the user may interrupt the transaction during its execution.
3. Local errors or exception conditions detected by the transaction: During transaction
execution, certain conditions may occur that necessitate cancellation of the
transaction. For example, data for the transaction may not be found. Notice that an
exception condition ,such as insufficient account balance in a banking database, may
cause a transaction, such as a fund withdrawal, to be cancelled. This exception should
be programmed in the transaction itself, and hence would not be considered a failure.
4. Concurrency control enforcement: The concurrency control method may decide to
abort the transaction, to be restarted later, because it violates serializability or because
several transactions are in a state of deadlock.
5. Disk failure: Some disk blocks may lose their data because of a read or write
malfunction or because of a disk read/write head crash. This may happen during a
read or a write operation of the transaction.
6. Physical problems and catastrophes: This refers to an endless list of problems that
includes power or air-conditioning failure, fire, theft, sabotage, overwriting disks or
tapes by mistake, and mounting of a wrong tape by the operator.
Transaction and System Concepts
Transactions should possess several properties. These are often called the ACID
properties, and they should be enforced by the concurrency control and recovery methods of
the DBMS. The following are the ACID properties:
1.Types of Security
Database security is a very broad area that addresses many issues, including the following:
1. • Legal and ethical issues regarding the right to access certain information. Some
information may be deemed to be private and cannot be accessed legally by
unauthorized persons. In the United States, there are numerous laws governing
privacy of information.
2. • Policy issues at the governmental, institutional, or corporate level as to what
kinds of information should not be made publicly available—for example, credit
ratings and personal medical records.
3. • System-related issues such as the system levels at which various security functions
should be enforced—for example, whether a security function should be handled at
the physical hardware level, the operating system level, or the DBMS level.
4. • The need in some organizations to identify multiple security levels and to categorize
the data and users based on these classifications—for example, top secret, secret,
confidential, and unclassified. The security policy of the organization with respect to
permitting access to various classifications of data must be enforced.
Threats to databases
● Loss of integrity :-
Database integrity refers to the requirement that information be protected from
improper modification. Modification of data includes creation, insertion, modification,
deletion etc. Integrity is lost if unauthorized changes are made to the data
● Loss of availability:-
Database availability refers to making objects available to a human user or a program
to which they have a legitimate right.
● Loss of confidentiality:-
Database confidentiality refers to the protection of data from unauthorized disclosure.
It result in public confidence and legal action against the organization.
In a multiuser database system, the DBMS must provide techniques to
enable certain users or user groups to access selected portions of a database without gaining
access to the rest of the database. A DBMS typically includes a database security and
authorization subsystem that is responsible for ensuring the security of portions of a
database against unauthorized access. It is now customary to refer to two types of database
security mechanisms:
1. • Discretionary security mechanisms: These are used to grant privileges to users,
including the capability to access specific data files, records, or fields in a specified
mode (such as read, insert, delete, or update).
2. • Mandatory security mechanisms: These are used to enforce multilevel security by
classifying the data and users into various security classes (or level)
2.Control Measures
There are 4 control measures that are used to provide security of data in databases.
2.1 Access control
2.2 Inference control
2.3 Flow control
2.4 Data Encryption
1. Account creation: This action creates a new account and password for a user or
a group of users to enable them to access the DBMS.
2. Privilege granting: This action permits the DBA to grant certain privileges to
certain accounts.
3. Privilege revocation: This action permits the DBA to revoke (cancel) certain
privileges that were previously given to certain accounts.
4. Security level assignment: This action consists of assigning user accounts to the
appropriate security classification level.
The DBA is responsible for the overall security of the database system.
Suppose that the DBA creates four accounts—A1, A2, A3, and
A4—and wants only A1 to be able to create base relations; then the DBA must issue the
following GRANT command in SQL:
The CREATETAB (create table) privilege gives account A1 the capability to create new
database tables (base relations) and is hence an account privilege.
Next, suppose that account A1 wants to grant to account A2 the privilege to insert and delete
tuples in both of these relations. Then DBA can issue the following command:
The clause WITH GRANT OPTION means that A3 can now propagate the privilege to other
accounts by using GRANT.
Revoking Privileges
In some cases it is desirable to grant some privilege to a user temporarily. For
example, the owner of a relation may want to grant the SELECT privilege to a user for a
specific task and then revoke that privilege once the task is completed. Hence, a mechanism
for revoking privileges is needed. In SQL a REVOKE command is included for the purpose
of cancelling privileges.
The DBMS must now automatically revoke the SELECT privilege on EMPLOYEE from A3