transactional database

Post on 10-Jun-2015

78 Views

Category:

Entertainment & Humor

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

DATABASE Transections overview

TRANSCRIPT

Transaction

Transaction in database is required to protect data

and keep it consistent when multiple users

access the database at same time.

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. 

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.

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.

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

Thank you !!

Any Question?

top related