Relational Database Atomicity Explained By Example
Key Takeaways
The video explains the ACID properties of relational databases, specifically atomicity, using an Instagram example with database design and transactions. Tools like Sketch and Nexium are mentioned, and concepts such as consistency, isolation, and durability are introduced.
Full Transcript
what's up y'all this is russain nozzle from I geometry where we discuss software engineering by example and today topic today's topic is acid not the kind that you take nexium for but the other kind which is database acid which stands for atomicity consistency isolation and durability so this is a applied this is relevant for the relational databases so so let that's good let's discuss this so let's break this and what is acid and why these properties why do we have these four properties and how they are useful for us right so we're gonna start the database is Ward the first property is atomicity alright so in order to discuss these properties we're gonna take like we always do in this channel an example an actual real life example and a hello world example right so just take Instagram for it for for an example right let's assume this is all made up obviously the design and everything it's gonna be made up but let's take Instagram for it for for example and let's assume that we're gonna design the database for Instagram so you're gonna be building erm for Instagram so we'll take it very simple so you have pictures right and you have people which our users and you have people liking pictures let's take the comments out of the picture yeah so the requirements is for each picture that I post I need to know how many likes this picture makes right so that's that's one piece of information the other piece is who likes these pictures who are there give me the list of all these users so the way I'm gonna design this is yeah let's go ahead and write like two tables here and I'm using this online tool sketch that I oh it's a really cool app you just found it so yeah it's gonna make a table called pictures and then we're gonna make another table called likes which are the individual likes of these right and what do we have what oh that's big all right what do we have we have an ID a picture have an ID correct and what else picture as URL again it's all fictional right I mean they might have more and more and more stuff there but and we have like Scouts right right and for consistence make it all caps to follow the standard here so that's URL right it sounds good sounds good sounds good all right how about the likes so this will tell me like for this particular picture with this ID right this got this much we're gonna get we're gonna get two examples in a second here so just go ahead and just copy that a like will basically have the picture ID right which picture got like and literally who like did does that make sense I think it does right very simple yeah just feels like a table I guess right thank right that makes sense get on with my face here second but yeah neck sense right so yeah okay so we'll discuss atomicity so we talking all the time just to sketch up this stuff so let's say I have what I have I just posted a new picture I don't really care who posted and I mean we can add that record who is the owner of this picture but it's not relevant for this we can add a lot of stuff so it got an ID so picture number one all right and has some URL and zero likes okay delete stuff in a second but we have no likes for this picture so let's discuss Tama City here so that's we just we just have a nice design now so you like that right so these are linked all right the one picture can have many likes I think mmm zero or more not bad in this case yeah so yeah otama City the first thing first property rights or whole thing was just to discuss that after ma city and then we're gonna discuss in different videos the rest of properties of assets so we have a database here what is a Thomas City what is that so let's say I my name is Jon Jon Snow and he found picture one which is the picture of wolf I guess along he's into that right so he likes that picture double click all right double tap and he likes it so how how are we going to update what is the series of sequel that we need to update right so what do we need to do what what series of sequel statements that we need to execute in order to update that there are two things right first the first statement is hey I'm update I'm liking picture number one so two statements the first one is update table pictures maybe you'll just write that as well all right yeah why not update to update pictures set likes count equal likes count plus one right we're ID is equal one I'm liking picture number one so that's the first statement yeah let's make it like that okay let's make it a little smaller so what is the second statement the second statement is also add me I am Joan insert a record into the likes table answers into likes yeah for simplicity you just assume that John right alright so these are the two statements that needs to be executed yeah first set that count and then insert a record okay so what is a toast otama City this brings us to the topic we need to discuss which is a tomas City atomic we need to make this unit of work that like has to happen as a one unit single unit of work that means if that statement get executed all right the other statement has to be executed so both of them has to succeed otherwise we will end up in an inconsistent state right so what will happen here is okay I'm going to basically delete that puppy okay and then yeah like one right and then I am going to actually add a new record here she's that handwriting though Jonas no while you're doing John alright look at that so yeah so I I updated that record and I also inserted a new record here so if something happened like I atomicity is this property if I managed to successfully update that picture and for some reason let's say oh okay let's say I lost connection right database went down at that moment really unlikely but let's say that that's one case where the automa City can kicks in alright and let's say I just lost connectivity I lost connection to the database so I did not manage to send that our statement which is really unlikely but yeah okay so I end up with this but I did not update I did not insert a new record for John to the likes so if that happened let's assume that I don't have a I don't have any item s at the end Mr gum might actually not have that they don't really care this is it's not really I don't care for the day if it shows like you have hundred likes and if you list though we're gonna talk about that in a minute but it's there let's say we don't we have if you don't have atomicity and I did that we our picture will show one like so I'm gonna okay using my head that's supposed to be iPhone all right sir all right okay on that alright that's John snow egg hey just click done then and he liked it but for some reason he lost connection and then he come back and he said oh there is ok that that owner of the picture says ok my wolf got one like but if I click I see I want to see who actually liked it right I want to see who liked it so you click on that and you'll end up it says okay no users ah that's an example of inconsistent results that you get out out of not implementing atomicity so atomic transaction so these two pieces of sequel statement has to be executed together and and you that's why you have to wrap it in a transaction if you're doing programming you have to hey both those puppies have to go in if one of them fail that's one case of failure where we lost connection right but you're gonna end up with a lot of other failures constraint which we'll see in the next episode you're gonna see a lot of cases so so that's and I'm not sure that that is a thomas city so let's let's do another thing the same sansa right let's so that were beautiful wolf and she decided to like that picture to says what do you in Sansa let's go okay delete delete okay this is a ridiculous all right so now sounds are like that picture so two statements then used to write and then Shawn saw what are you doing sensor look at that picture alright so we have now - right now we're gonna discuss the consistency and in the next episode so that's the second property so that's basically atomicity right if you don't end up so atomicity and consistent you're kinda linked but i prefer to gusseted up in a previous episode so you might have a lot of questions about primary keys and foreign keys we're gonna discuss that in the next episode so stay tuned guys subscribe and you're gonna see you on the next one I geometry software engineering by examples see ya
Original Description
ACID stands for the four properties in relational database 4 Atomcity , Consistency, Isolation and Durability. These are key attributes in transaction managements in any RDBMS.
In this video we explain consistency, the first property of a relational database. We illustrate this using instagram as example.
Software Engineering Content on IGeometry
——————————————————————
- [x] Stateful vs Stateless Applications https://goo.gl/Fubfi6
- [x] Database ACID - Atomicity https://goo.gl/ER9PPj
- [x] Database ACID - Consistency https://goo.gl/VpLAeN
- [x] Database ACID - Dirty read https://goo.gl/88wf6y
- [x] Database ACID - Phantom read https://goo.gl/rnyzuA
- [x] Database ACID - Non repeatable read https://goo.gl/8kgEjN
- [x] Database ACID - Read uncommitted https://goo.gl/4igWUq
- [x] Database ACID - Read committed https://goo.gl/twgAKL
- [x] Database ACID - Repeatable read https://goo.gl/vDcP6M
- [x] Virtual Machines vs Containers https://goo.gl/fiECVb
Boost your GIS knowledge by grabbing my books
———————————————————————
- [x] Learning ArcGIS Geodatabase https://goo.gl/csQdCX
- [x] Administering ArcGIS for Server https://goo.gl/zvYCRg
- [x] ArcGIS By Example https://goo.gl/yJKSqB
- [x] Building Web Applications with ArcGIS https://goo.gl/brgKUJ
Watch my top GIS videos
————————————
- [x] Support IGeometry on paypal: https://goo.gl/wZ8hSh
- [x] Full ArcGIS Javascript API Series Playlist http://bit.ly/2zf7G80
- [x] Full Multi-User Geodatabase Playlist https://goo.gl/nSgYnM
- [x] Full ArcGIS Pro 2.x Playlist https://goo.gl/2j4NoZ
- [x] Full ArcGIS By Example (C#) [Phonatech] Playlist https://goo.gl/FwdrHa
- [x] Full ArcGIS Server Playlist https://goo.gl/nkfM6Q
-Hussein Nasser
www.husseinnasser.com
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Hussein Nasser · Hussein Nasser · 25 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
▶
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Extending ArcObjects (IGeometry) - 01 - Getting Started
Hussein Nasser
Extending ArcObjects (IGeometry) - 02 - The Document, The Map and The Layers
Hussein Nasser
Channel Update - New Book, New Job, New Videos
Hussein Nasser
Learn Programming with VB.NET - 01 - Getting Started
Hussein Nasser
Learn Programming with VB.NET - 02 - Classes and Objects (Part 1)
Hussein Nasser
Learn Programming with VB.NET - 03 - Classes and Objects (Part 2)
Hussein Nasser
Learn Programming with VB.NET - 04 - User Interface
Hussein Nasser
Learn Programming with VB.NET - 05 - By Value v. By Reference
Hussein Nasser
Learn Programming with VB.NET - 06 - Variable size, 32 bit vs 64 bit
Hussein Nasser
Learn Programming with VB.NET - 07 - Conditional Statements
Hussein Nasser
Learn Programming with VB.NET - 08 - Inheritance
Hussein Nasser
Learn Programming with VB.NET - 09 - Strategy Design Pattern
Hussein Nasser
Learn Programming with VB.NET - 10 - How did I learn programming
Hussein Nasser
IGeometry 2016 Retrospective - Channel Update
Hussein Nasser
Javascript by Example - The Vook
Hussein Nasser
Vlog - Keep your servers close and your database closer
Hussein Nasser
Vlog - Client/Server Programming Languages
Hussein Nasser
Javascript By Example L1E01 - Getting Started
Hussein Nasser
Persistent Connections (Pros and Cons)
Hussein Nasser
Javascript By Example L1E02 - Building the Calculator Interface
Hussein Nasser
Happy new Year from IGeometry!
Hussein Nasser
Synchronous v. Asynchronous
Hussein Nasser
Javascript By Example L1E03 - Displaying the Digits on Calculator Screen
Hussein Nasser
Show Your Work. Blog, Vlog, Write, Create and Develop!
Hussein Nasser
Relational Database Atomicity Explained By Example
Hussein Nasser
Javascript By Example L1E04 - Operators, All Clear with Arrow Functions
Hussein Nasser
What Comes First, User Experience or Software Architecture?
Hussein Nasser
Javascript By Example L1E05 - Evaluate the Calculator Expressions with eval
Hussein Nasser
Fastest Way to Learn Programming Language or Technology
Hussein Nasser
Javascript By Example L1E06 - Fix Leading Zero Bug with Conditions
Hussein Nasser
Stateful vs Stateless Applications (Explained by Example)
Hussein Nasser
Javascript By Example L1E07 - Running our Calculator on the Mobile Phone
Hussein Nasser
Advice for New Software Engineers and Developers
Hussein Nasser
Why JSON is so Popular?
Hussein Nasser
Building Scalable Software - SLA, HS, VS
Hussein Nasser
Vlog (Istanbul) - Datacenter Proximity
Hussein Nasser
Should Software Engineers Learn Bleeding-Edge Technologies?
Hussein Nasser
Do Developers Build Bad User Interfaces/Experience?
Hussein Nasser
Learn By Doing.
Hussein Nasser
I Wrote Bad Front-End Code That Broke Chrome
Hussein Nasser
My Story
Hussein Nasser
Vlog - Horizontal vs Vertical Scaling
Hussein Nasser
Can User Experience Help Build Better Rest API?
Hussein Nasser
Reverse engineering Instagram in flight mode
Hussein Nasser
The Benefits of the 3-Tier Architecture (e.g. REST API)
Hussein Nasser
Stateless v. Stateful Architecture (Podcast)
Hussein Nasser
The evolution from virtual machines to containers
Hussein Nasser
Proxy vs. Reverse Proxy (Explained by Example)
Hussein Nasser
Canary Deployment (Explained by Example)
Hussein Nasser
No Excuses
Hussein Nasser
Synchronous vs Asynchronous Applications (Explained by Example)
Hussein Nasser
What is an Asynchronous service?
Hussein Nasser
Difference between Client Polling vs Server Push in Notifications
Hussein Nasser
Software vs. Hardware AdBlockers (Explained by Example)
Hussein Nasser
HTTP Caching with E-Tags - (Explained by Example)
Hussein Nasser
Simple Object Access Protocol Pros and Cons (Explained by Example)
Hussein Nasser
Nodejs Express "Hello, World"
Hussein Nasser
Reverse Engineering Instagram feed
Hussein Nasser
Popup Modal Dialog with Javascript and HTML
Hussein Nasser
MIME and Media Type sniffing explained and the type of attacks it leads to
Hussein Nasser
More on: Research Methods
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Applying Scalability in Backend (CodeBuddy)
Medium · LLM
Why Every Backend Developer Should Learn Nginx Before Going to Production
Medium · DevOps
Connecting Frontend to Backend: A Backend Engineer’s Reality Check
Medium · Programming
Build Secure Authentication System Using Access and Refresh Tokens
Medium · Python
🎓
Tutor Explanation
DeepCamp AI