dbsql 7-1 copyright © genetic computer school 2009 chapter 7 transaction management, database...
TRANSCRIPT
Copyright © Genetic Computer School 2009 DBSQL 7-1
Chapter 7
Transaction Management, Database Security and
Recovery
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-2
Chapter 7 Overview
Transaction Management Concurrency Control Database Security Database Recovery
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-4
Transaction Management Transaction is the execution of a program that access and changes the database. Once a transaction is committed it is said to be that the database is in its consistent state.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-5
Transaction Concept
ACID Properties Transaction Operation Transaction State Concurrent access to data
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-6
ACID Properties
Atomicity Consistency Isolation Durability
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-7
Cont’
Atomicity
Consistency
Isolation
Durability
All the transaction task is performed or not performed at all
The system is consistent at the end of a transaction
A transaction should not make its updates visible to other transactions until it is committed When a transaction has made a change to the database state and the change is committed, this change is permanent and should be available to all other transactions
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-8
Transaction Operation
BEGIN_TRANSACTION READ or WRITE END_TRANSACTION COMMIT_TRANSACTION ROLLBACK UNDO REDO
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-9
Transaction State
A transaction goes into an active state immediately after it stars execution, where it can issue READ and WRITE operations. When the transaction ends, it moves to the partially committed state. At this point, some concurrency control techniques require that certain checks are made to ensure that the transaction did not interfere with other executing transactions.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-10
Concurrent Access of data Many computer systems can be used simultaneously by more than one user. This is made possible by multiprogramming, a technique that allows the computer to run multiple program (or transactions) at the same time.
Due to speed at which these commands are executed, the impression of concurrent use is given to the users. This process is known as interleaving
An important issue is that more than one application may attempt to access the same data item. As a result, data stored in a multi-user DBMS can be damaged or destroyed.
To overcome this problem, concurrency control techniques have been developed to protect data from incorrect changes caused by transactions running simultaneously
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-11
Problems when concurrent access is executed
The lost update problem The uncommitted dependency problem The inconsistency analysis problem
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-13
Concurrency Control
Locks Types of Locking Locking Protocol Deadlock Oracle concurrency control
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-14
Concurrency Control
Concurrency Control is the control on the Database and Transaction which are executed concurrently to ensure that each Transaction completed healthy. Concurrently control is concerned with preventing loss of data integrity due to interference between users in a multi-user environment.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-15
Lock-Based Method
The best method to control the concurrent access to the Database Objects by providing suitable permissions to the Transactions. Also it is the only method which takes less cost of Time and less program complexity in terms of code development.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-16
Cont’
Database Object
Lock
Database Object is the small data element, the value of which one is altered during the execution of transactions.
Lock is a small object associated with Database Object which gives the information about the type of operations allowed on a particular Database Object. It can be termed as type of permission provided by the transaction manager to the transactions to do a particular operation on a Database Object.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-17
Types of Lock
Shared Locks (S locks) Exclusive Locks (X locks)
Uses of Locking Lost update Uncommitted dependency Inconsistent analysis
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-18
Locking Protocols
Basic 2PL Conservative 2PL Strict 2PL
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-19
Deadlock
Deadlock occurs mainly due to the Lock-Based Concurrency Control. The exclusive lock type will isolate one particular Database Object from the access other transactions. This will isolate one particular Database Object from the access of other transaction. This will suspend all the transactions who request Shared lock on that particular Database Object until the transaction which hold Exclusive lock on that object is completed. This will create a loop in Database which leads to Deadlock within transactions. This will leave the Database in inconsistent state.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-20
Oracle Concurrency Control
SET TRANSACTION READ COMMITTED SET TRANSACTION SERIALIZABLE SET TRANSACTION READ ONLY
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-21
Example
TRANSACTION 1
TRANSACTION 2
Time
Startcheck seatavailability
Start check seatavailability
Make reservation seat x
Make reservation seat x
commit
commit
TRANSACTION 1
TRANSACTION 2
Time
Startread price
item x
Start read/change price item x
create order
commit
commit
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-23
Database Security
Database security issues are often lumped together with data integrity issues, but the two concepts are really quite distinct. Security refers to the protection of data against unauthorized disclosure, alteration, or destruction; integrity refers to the accuracy or validity of that data.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-24
The need for security
Multiple users tried to access the data at the same time so in order to maintain consistency security is needed Because of the advancement of internet and to protect data from hackers and crackers. The plastic card (credit card) is popular so data must be safe.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-25
Database Security System
The person responsible for data security is usually the database administrator (DBA). The database security system stores authorization rules and enforces them for each database access. When a group of users, access data in the database then a privilege can be given to the said group rather than individual users.Database security involves allowing and disallowing users from performing actions on the database and the objects within it
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-26
Classification of Security
Physical refers to the security of the hardware
associated with the system and the protection of the site where the computer resides
Logical refers to the security measures residing in
the operating system or the DBMS designed to handle threats to the data.
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-27
Cont’
Design Level Should be simple Has to be normalized Decide privilege for each group Create unique view for each users or group
Maintenance Level Operating system issues and availability Confidentiality and accountability Encryption Authentication schemes
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-29
Database Recovery
Failure Classification Recovery Facilities Recovery Techniques Advance Recovery Techniques
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-30
Database Recovery
Brings the database from the temporary inconsistent state to a consistent state. Database recovery can also be defined as mechanisms for restoring a database quickly and accurately after loss or damage. Database are damaged due to:
Human error Hardware error Incorrect or invalid data Program errors Viruses Natural catastrophe
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-31
Recovery Facilities
Back-up mechanism Logging Facilities Checkpoint Facilities Recovery Manager
Copyright © Genetic Computer School, Singapore 2009
DBSQL 7-32
Recovery Techniques
Deferred update Immediate update Shadow paging