‫Transaction, what is a transaction?
‫We hear this a lot in databases, a transaction, it's nothing but a bunch of queries.
‫OK, it's a collection of queries.
‫So it's a one or more queries game.
‫And that property of these queries or they are you one unit of work?
‫An example would be if you want to deposit an account.
‫Right.
‫And some cash into an account that is actually a select statement followed by a statement followed by
‫another update, something like we now we're going to show in the second round.
‫But each one of those is a query.
‫The three of them can form a transaction and you define what a transaction begin and where transaction
‫end.
‫And we also there is another semantic attached to a transaction like a commit.
‫Hey, I am happy with my changes.
‫Go persist them, commit that sort of commitment, roll back.
‫You know what I think something went wrong.
‫Roll back, abort, abort, abort.
‫So that's another two piece of concept then attach by a transaction.
‫We know that.
‫Let's just jump into example.
‫A transaction.
‫I have an account here with a beautiful table just to feel because that's all where you need obviously
‫for in a bank or I have to.
‫Still feels like you don't need a name.
‫You don't need anything else.
‫No data, no.
‫Just do field.
‫So there's I got the idea there is a balance.
‫This guy has a thousand dollars, guys added to five, five hundred.
‫And the transaction is send hundred dollars from account one to account to us.
‫So what do we need to do first.
‫Does account one even have a hundred dollar.
‫I don't know.
‫So I need to check to us, we're going to begin the transaction, get a select let's check the balance.
‫Do you have one hundred dollars that.
‫Yes.
‫Your balance is a balance.
‫Go to the 100 yard sir.
‫It is greater than a hundred.
‫All right.
‫Let's debit that hundred minus hundred.
‫OK, so now it's nine hundred.
‫OK, but that's not committed is just the math, right?
‫It's just touched.
‫It's a dirty change game.
‫And then I'm going to add another hundred to the second account.
‫I'm going to commit my changes.
‫Turning green.
‫I mean, this is like it's persisted.
‫All good.
‫We're happy and that's it.
‫OK, so that's essentially what a transaction is.
‫It's a unit of work, but it consists of multiple queries, one or more as a transaction.