Module 5 Dbms
Module 5 Dbms
Module 5
Transaction Processing
Transactions
A transaction is an executing program that forms a logical unit of database processing. A
transaction includes one or more database access operations-these include insertion,
deletion, modification or retrieval operations.
One way of specifying the transaction boundaries is by using explicit begin transaction
and end transaction statements. Between these two statements constitutes the
transaction.
If the database operation in a transaction does not update the database but only retrieve
the data, then the transaction is called read-only transaction
If the database operation in a transaction updates the database, then the transaction is
called read-write transaction
Database Items
A database is basically represented as a collection of named data items. A data item can
be a database record but it can also be a larger unit such as a whole disk block or even a
small unit such as an attribute.
The size of the data item is called its granularity
read-item(X)
X=X-N
read-item(X)
X=X+M
Write –item(X)
read-item(X)
X=X-N
Write –item(X)
read-item(X)
X=X+M
Write –item(X)
2. Transaction States
A transaction enters into active state immediately after it starts execution, where it can
execute READ or WRITE operation. When the transaction ends, it moves to the partially
committed state. At this point, the system checks whether the operations are executed
successfully. If the transaction is executed successfully, it is reached to the commit
point and enters in committed state. When the transaction is committed, it concludes
its execution successfully and enters in terminated state.
However a transaction can go to the failed state, if its operations are executed
unsuccessfully or if the transaction is aborted during its active state. When the
transaction leaves the system, it enters in terminated state.
3. System Log
To be able to recover from failures, the system maintains a log to keep track of all
transaction operations that affect the values of database items. The log is a
sequential append-only file, which is kept on a disk.
Log entries are called log records. Following are the type of log entries. Here T
refers to unique transaction-id, which is automatically generated by the system to
identify each transaction
3. [read-item, T , X]- indicates that the transaction T read the value of database
item X
4. Commit Point
A transaction T reaches its commit point, when all of its operations that access the
database have been executed successfully and the effect of all the transaction
operations have been recorded in the system log and database
After the commit point, the transaction enters in committed state
Properties of Transaction
Transaction should posses certain properties. They are called ACID properties.
ACID Properties
Atomicity:
A transaction is an atomic unit of processing. It should either be performed in its
entirety or not performed at all.
It is the responsibility if the transaction recovery subsystem of DBMS to ensure
atomicity
Consistency Preservation:
A transaction should be consistency preserving. That is, it should be completely
executed from beginning to end without interference from other transactions
A transaction should take the database from one consistent state to another. It is the
responsibility of the database programmers who write programmes which should
maintain the database in consistent state
Isolation:
A transaction should be isolated from other transactions, even though many
transactions are executing concurrently. That is, the execution of a transaction should
not be interfered with any other transactions executing concurrently. This property is
enforced by the concurrency control subsystem of the DBMS
Following are the levels of isolation of a transaction:
Level 0: it does not overwrite the dirty reads
Level 1: it has no l.ost updates
Level 2: no lost updates and no dirty reads
Level 3: in addition to level 2 properties it has repeatable reads. This isolation is called
true isolation
Durability or Permanency:
It states that the changes applied to the database by a committed transaction must
persist in the database. This property is the responsibility of the transaction recovery
subsystem of DBMS
Database Security
Control Measures
There are 4 control measures used to provide the security of data in databases
Access control
Inference control
Flow control
Data encryption
Access Control:
The security mechanism of a DBMS must include provisions for restricting access to the
database system. This function is called access control. Access control is done by
creating user accounts and passwords to control the login process by the DBMS.
DBA is responsible for creating new user accounts and passwords for various users
Inference Control
It is a control measure used in statistical databases. Statistical databases are used to
provide statistical information or summaries of values based on various criteria. These
types of databases are used in market research firms or governmental firms to get
statistical information about the population
It also ensure that information about the individuals cannot be accessed
Flow control:
It prevents the information from flowing in such a way that it cannot reaches to
unauthorized users. That is, the information must flow through right channels
Data Encryption:
It is used to protect sensitive or confident data. The data is encoded using some coding
algorithms, so that only authorized user can access that coded data through decryption
Database Audits
To keep a record of all updates applied to the databases by a particular user, we keep
the system log.
We expand the log entries so that they also include account number of the user and the
device Id of the user are recorded in the log. If any tampering with the database is
suspected, a database audit is performed.
It consists of reviewing the log entries to examine all database access operations
during a certain period. When an illegal or unauthorized operation found, the
DBA can determine the account number and device ID which is used to perform
that operation.
A database log, that is mainly used for the security purpose is called an audit trail
For example, to grant table creation permission to the user ‘amen’, use the following
code
GRANT CREATETAB TO amen
To grant insert, delete and update privileges on the table employee to the user amen,
use the code
GRANT INSERT, DELETE, UPDATE ON employee TO amen
We can also use the GRANT command with ‘WITH GRANT ‘option
GRANT SELECT ON employee TO amen WITH GRANT
Now amen can assign privileges to another user on employee table
Revoking of Privileges
‘REVOKE’ command is used by the DBA to cancels the privileges from user account.