transactional database

7
Transaction Transaction in database is required to protect data and keep it consistent when multiple users access the database at same time.

Upload: ahsan-abbasi

Post on 10-Jun-2015

78 views

Category:

Entertainment & Humor


2 download

DESCRIPTION

DATABASE Transections overview

TRANSCRIPT

Page 1: Transactional database

Transaction

Transaction in database is required to protect data

and keep it consistent when multiple users

access the database at same time.

Page 2: Transactional database

Transactional databases

Database transaction is collection of SQL queries which forms a logical one task. For transaction to be completed successfully all SQL queries has to run successfully

Database should always remain consistent whether transaction succeeded or failed.

Transaction is implemented in database using SQL keyword transaction, commit and rollback. 

Page 3: Transactional database

Why transaction is required in database?

Database is used to store data required by real life application e.g. Banking, Healthcare, Finance etc. In order to protect data and keep it consistent any changes in this data needs to be done in transaction so that even in case of failure data remain in previous state before start of transaction.

Page 4: Transactional database

Properties of databasetransaction

There are four important properties of database transactions, represented by acronym ACID.

A stands for Atomicity, either all steps of transaction completes or none of them.

C stands for Consistency, transaction must leave database in consistent state even if it succeed or rollback.

I is for Isolation. Two database transactions happening at same time should not affect each other.

D stands for Durability, means saving the data related to transaction.

Page 5: Transactional database

Database Transaction Example

To understand database transaction better let's see a real life example of transaction in database. For this example we will assume we have an Account table which represent a Bank Account and we will transfer money from one account to another account.start transactionselect balance from Account where Account Number='9001';select balance from Account where Account Number='9002';update Account set balance=balance-900 here Account Number='9001' ;update Account set balance=balance+900 here Account Number='9002' ;commit; //if all SQL queries succeedrollback; //if any of SQL queries failed or error

Page 6: Transactional database

Thank you !!

Page 7: Transactional database

Any Question?