‫All right, consistency, guys, all right, so I really needed to talk about it and isolation, forced
‫to talk about consistency, right.
‫Although consistency is the second property or an asset.
‫Right.
‫And the reason is.
‫Ethnicity and isolation leads to consistency, in my opinion, and the way I see it.
‫There are two types of consistency, the way I see it here.
‫And the first one is consistency in your data.
‫And the second one is consistency in reading the data.
‫And let's talk about each one of the men and let's talk about what which one of those the sequel guys
‫came and try to improve upon, OK, and try to it can be relaxed here.
‫Consistency in data, because this is data is essentially is defined by the user.
‫It's something that the user defines in their table schema.
‫It says, hey, that this view and this view should be consistent, like, say, the sum of the money
‫and the stable should equal the sum of all the balances or the number of likes.
‫And this picture should no should equal the number of the users will actually like that picture.
‫So this is a consistent view that the user defines.
‫OK, usually it's enforced by referential integrity, like four keys and primary keys.
‫So you ensure consistency in your data and it's also ensured by a tomasetti and isolation.
‫We saw that we were number one.
‫We got the blue screen of death and the middle right.
‫We just lost my data.
‫Right.
‫Just went away and I got an inconsistent balance sheet.
‫As a result, we got nine hundred and five hundred where a hundred just went away and the thin air.
‫So a total lack of atomistic leads to inconsistency in your data.
‫OK.
‫Isolation.
‫Do I need to say anything?
‫We saw all that stuff, either isolation, rent, giving all this false reports as a result of lack
‫of isolation.
‫Right at the moment, people are changing my product sales while I'm reading this data.
‫I'm going to get a bad result.
‫I'm going to get an inconsistent result, although my product says the sum is one 30.
‫I can see it.
‫I can sum it up.
‫But the actual total is saying one fifty five, that's bad.
‫So a lack of isolation leads to inconsistency.
‫It's up to you as a user if you can handle if you're okay with that inconsistency or not.
‫Sometimes it leads to corruption, inconsistency.
‫If you're not happy with that like bank transaction, you cannot probably be happy with that product
‫sales.
‫Probably not.
‫That's that.
‫Pictures and like we're going to show that example seem like this is an example, right, where because
‫this is in my data is really not a big deal.
‫Like we have two pictures here.
‫There's a blob of the picture.
‫I say this is an Instagram implementation.
‫We have a blob of the picture and we have the number of likes hosting.
‫We might say, hey, why are you adding a field called Likes?
‫What what is that game?
‫Why don't you just query this table and just get the number of flights?
‫Performance is the best short answer for this.
‫Right.
‫So you would add like field here, which will contain the total number of likes in this picture that
‫this picture got.
‫And that is another table called picture like which includes like, hey, John liked picture number
‫one edman like picture number one, John, like picture number two.
‫So if you sum this right.
‫Picture number got two likes from John and Edman, that's correct, and then picture two got one like
‫this one from John.
‫So that's a consistent view.
‫But if you saw that, for example, this is four and this view doesn't represent that, that's an inconsistent
‫view.
‫It's up to you if you're happy with that inconsistency or not.
‫And that's a very critical question, because based on that, you can adjust the performance, you can
‫adjust the consistency, you can adjust scalability, you can adjust isolation based on what can you
‫give up as an engineer, as a software engineer, you really guys need to think about every single aspect
‫of that.
‫What can you give up?
‫That's why you have to understand the requirements and then ask yourself, what can you give up?
‫You're telling me that Instagram, if Kylie Jenner gets like five million likes and a picture five million
‫and thirty two lives, if I clicked on that and view the five million, are you telling me that you're
‫going to match I betting everything you want.
‫I know matching this this is impossible to get a consistent view on this and they don't care because
‫nobody is going to fiddle through five million users anyway so they can give you an approximate number
‫and they can be off.
‫There's those two views can be off by even a hundred thousand.
‫YouTube has the same subscribers.
‫Right.
‫Do you think why do you think YouTube is showing you like my subscribers 6k or six point 2k?
‫Because they cannot guarantee you that I have exactly six thousand thirty two subscribers, OK, or
‫twenty three or even Peurifoy.
‫Right.
‫He has like one now, almost ninety five million subscribers.
‫That number is not exactly accurate to the actual number of subscribers that he actually got.
‫It's an approximation because they cannot.
‫They decided that it's not important to maintain the consistency of this thing because why?
‫First, because nobody's going through ninety nine million subscribers.
‫So they are preferring performance over this consistency.
‫Sorry about guys.
‫So by going to a tangent, but as I said, it's as critical to this.
‫Let's talk about the other costs concept of this consistent data.
‫Sometimes it matters, sometimes it doesn't.
‫Consistent consistency in rates, same thing.
‫Sometimes it doesn't.
‫It doesn't matter.
‫So we'll think about that.
‫No consistency and reads is very interesting.
‫And.
‫What it means is like if I update something for a transaction, update something to the database, I
‫say I've added a value X and that X get persistent and then another transactions start reading that
‫it better get the value X.
‫Hussein, what are you saying?
‫That's obviously tough, reckon, right ride obviously has to give the same value, but not necessarily.
‫We're going to talk about the concept of eventual consistency here.
‫So that's inconsistent.
‫Read if I committed something, can you transactions see it immediately.
‫OK, and here's the thing.
‫This type of consistency is now available on both relational and equal databases.
‫Is a big statement to you both that a business suffers from this consistency, including Oracle, including
‫postscripts including my school.
‫Those databases are not consistent and reads.
‫And let me explain here.
‫When you have a one server and you're committed something to it and you read from that one server,
‫life is good, right?
‫Life is perfect.
‫Because you have one frickin server, but the moment you start adding other server, let's look at what
‫this is all my school.
‫What are you going to do essentially is you're going to have one server and you created a replica of
‫that server.
‫And that is like even one way replica to where replica is going to start pumping data to the replica.
‫Right.
‫And now, obviously, you need to add multiple replicas for horizontal scalability and you cannot serve
‫seven million people off one database.
‫Right.
‫That YouTube started doing that with one database and they scaled it up to multiple and they implemented
‫now for test, which is this new fancy stuff on top of my school that gives you like sharding on the
‫fly sharding stuff.
‫We're going to talk about another video by essentially.
‫The moment you break things up into these replicas, into this essentially the other databases, the
‫secondary databases.
‫Follower leader of follower nodes right now, what would you start doing that you are inconsistent,
‫sir, you will become inconsistent because you arrive to the primary node and someone else reads from
‫the secondary node.
‫The second takes time to get the value propagated.
‫There is networking going on.
‫There is delays latency until the secondary node gets the new value.
‫So you're going to get an old value, my friend.
‫You're going to get an old value.
‫Right.
‫And that is inconsistency.
‫So.
‫This problem and a lot of people get this wrong, inconsistency.
‫So the relational database is inconsistent and reads right the moment you start breaking them into horizontal
‫scalability, the multiple servers, you are going to get inconsistency, right?
‫So they are consistent when there is one big nice server.
‫Right.
‫The moment you break up, they are inconsistent and reads, you're going to read it, but someone will
‫get to read an old value.
‫And it's up to you.
‫Now, as an engineer, are you happy with this old value if you get a slightly older subscriber count?
‫OK.
‫That's completely fine if your video, the latest view, and that's what YouTube does, right, there
‫are many servers and all these rights going to multiple databases and then they eventually sink back
‫into one big server, one big database.
‫Right.
‫And then if you read if I'm reading that view versus someone from Germany versus someone from Japan
‫reading that same video, we're going to get a different result because we're reading different replicas.
‫We're reading from different follower nodes.
‫And that's OK.
‫Right.
‫Sometimes that's OK.
‫Sometimes it's not.
‫So now.
‫There are a bunch of people who say, you know what, we don't want to enforce that thing is this all
‫this stuff you guys are doing silly, this asset thing is silly.
‫And the fact that scaling relational databases has been always hard.
‫Right, because it was designed in the 70s to be a one big beefy machine, one big beefy server.
‫The database is there and that's it.
‫Right.
‫In this era, those guys said, OK, you know what, I'm going to give up consistency because you guys
‫already don't have consistency.
‫Right?
‫I'm going to relax a little bit of these four properties and I'm going to give you.
‫A better scalability and performance.
‫So I'm going to scale horizontally, I'm going to add a bunch of other servers on the sides and then
‫just that we're going we can start sharding doing all these things, undistributed manner.
‫So that's essentially what they did.
‫And there was thus the no SQL databases came into picture.
‫So they give up consistency or in favor of scalability, which the relational database is a really,
‫really hard to do ratio databases, whether you have to implement the follow or node and leader node
‫and they start replicating bumpe changes.
‫And the second one gives you a scalability.
‫You can add just nodes and then we'll scale nicely.
‫But if you're looking for isolation and all that fancy stuff, you're not going to get it.
‫Obviously right now.
‫You're not going to get all these properties off of this.
‫You you you will get this new concept called eventual consistency, which is to me is just a marketing
‫term game until everything is eventually consistent.
‫So it's like if you if you read the value going an old value, if you wait a little bit, you're going
‫to get the latest value essentially.
‫Right.
‫So to me, a visual consistency.
‫Both the relational databases and non-resident databases suffer from this eventual consistency.