Hello, dear friends.
So in this section, we will learn about Ezekial transaction to manage transactions.
We're going to use three commands roll back command, commit command.
And lastly, the Save Point Command.
Our transaction is a unit of work that is performed against a database.
Transactions or units or sequences of work accomplished in a logical order.
Whether in a manual fashion by a user or automatically by some sort of database program.
A transaction is the propagation of one or more changes to the database, for example, if you're creating
a record or updating a record or the leading a record from the table, then you are performing a transaction
on that table.
So logically, it's important to be able to control these transactions in order to ensure the data integrity
as well as to handle database errors.
Practically, you will club many actual queries into a group and you will execute all of them together
as part of a transaction.
All right, so let's assume that you have an account with a thousand dollar balance at a bank and you
want to buy a product on the Internet with your phone, is that's what you.
If the process fails.
As soon as you accepted, the bank will not decrease your balance.
Unlike it would wait until the process has been completed, so the bank decreases your balance as soon
as you accept the sale and if something goes wrong with paying to the website or whatever, then even
though the bank decreases your balance, your product will not be sent to you.
Do you understand?
So they'll still take the money and you're not going to get nothing for it.
Because it seems like you didn't pay on the website.
That's what it looks like.
No product, but lower bank balance.
Big problem, yeah.
So the ask all transactions are here to solve this problem.
In general, a transaction is a single unit of work that consists of multiple related tasks that should
succeed or fail as one atomic unit.
All right.
So as soon as you accept the sale, the bank will wait until the process has been fully completed.
That way, if the process failed, the bank will cancel the process.
If the process end successfully, the bank will accept the payment and then decrease your balance so
you'll be able to receive your product.
Acid.
Now, to our understanding, the concept of the rescue server transaction.
I can now describe to you the transaction using the four acid properties.
Now, Acid is an acronym, not an acronym, but an acronym for Adam Midcity, Consistency.
Isolation and durability.
I'll explain it further.
Adam Midcity means that the transaction will succeed as one unit if all the separate tasks succeed with
no issue.
And on the other hand, the failure of any single task within this transaction leads to the overall
transaction failure and rolled back.
So in other words, atomistic guarantees that the transaction is all or nothing.
Consistency.
Guarantees that the transaction will not affect the database consistency and will leave it in a valid
state by complying with all database rules such as foreign keys and constraints defined on the columns
and simple words, only valid data is saved.
Isolation means that each transaction has its own boundary, it's separate from all the other currently
executing transactions and will not be affected by these transactions operations.
In other words, transactions don't affect each other.
Durability.
Durability means that the result of the committed transaction that is written permanently to the database
will not be lost even in the case of an abnormal system, failure or termination.
As there should be a mechanism of recovering this data that we're going to see later on in the next
coming articles of the series, but in other words, written data will not be lost.
Transaction state.
The state of the transaction can be summarized as.
The running transaction is referred to as the active transaction.
So the transaction does not complete its execution, it's referred to as a failed transaction that is
aborted without being committed.
So that just means that the process will be canceled.
The transaction that is not fully committed yet is referred to as a partially committed transaction.
If the partially committed transaction completes its execution successfully, it will then be committed,
otherwise it will be failed, then aborted.
The transaction that completes its execution successfully without any error is referred to as a committed
transaction.
So on this situation, the process will be saved successfully.