Critical Thinking

Transaction: statements which are used to perform certain

Transaction: Transaction is a
group of sql (DML) statements which are used to perform certain combination of
operations like write, update etc. into one unit to make the consistency of
data. They are used to perform multiple actions if and only if all the
operations can be performed else none of the action or operation should not be done
and the database should not affect i.e; the transaction is ROLLBACK. If all the
operations are performed successfully than it will be save to database by
issuing the COMMIT command. There is a Transaction log which are used to make
the database to original state in case of failure occurs. With transactions
supports ACID properties. The real scenarios where Transactions are used are
Bank data base for money transactions, railway reservation etc.  Transaction is an automatic work with respect
to recovery and consistency.

Transactions are useful when you’re modifying two tables that you don’t
want out of sync. The classic example is a debit/credit system for a bank,
where money is moved from one account to another: Here transaction is performed
using TRY catch block.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

 

BEGIN TRANSACTION;

BEGIN TRY

UPDATE account SET total=total+5000.0 WHERE account_id=1337;

UPDATE account SET total=total-5000.0 WHERE account_id=45887;

COMMIT TRANSACTION

END TRY

BEGIN CATCH

ROLLBACK TRANSACTION

END CATCH

 

GO

If something happened between the two updates, this bank would lose $5000.00.
But, when wrapped in a transaction block, the initial update is rolled back,
even if the server crashes.

 

Transaction Processing:

Transaction processing gives a
scheme which is used to check the progress and controls the execution of
transaction programs. Transaction processing mainly used in mission-critical
applications which requires large amount of parallel users with minimum downtime.  Proper use of Transaction Processing results
the controlling the execution of several applications which are executing
parallel. Transaction processing ensures the ACID properties over different
databases this can be done by using two-phase COMMIT. Transaction processing
system is best used if an application requires online access and also if there
is a modification on different databases.

                                             

Local Transaction: When the
transaction is limited to only single database or resource is called Local
Transaction and all the operations will commit at the end of the transaction.

Distributed Transaction:

Unlike to local transaction which
are limited to specific resource distributed transactions extend across
multiple databases or resources. It is similar to local transaction where at
the end of the transaction should be either committed or roll backed. If we
have a situation where network failure occurs then but unfortunately in place
of rollback all the transactions the data in one of the database or resource is
committing this can happen due to many reasons to minimize these type of risk
distributed transaction uses TWO –PHASE COMMIT process.

Implicit transaction contains
only one statement of either INSERT, UPDATE, DELETE etc. After connecting to
the database then if we perform or execute any DML statements then changes are
made and saved to database automatically. This happens since the connection is
in auto commit transaction mode. If you don’t want to save any changes until
unless you specifies the COMMIT or ROLLBACK then we can use Implicit
Transaction. Using Implicit Transaction the transactions remains in effect
until the user issues the COMMIT or ROLLBACK commands.

Explicit transaction contains
multiple statements with BEGIN indicates start the transaction and END indicates
end the transaction. Using explicit transaction user is controlling when the
transaction is going to start and when it should ends. These are also called
user-defined transactions

x

Hi!
I'm Simon!

Would you like to get a custom essay? How about receiving a customized one?

Check it out