let's talk a little bit about synchronous versus asynchronous events I want you to think about two different things in your life one is a phone call that you're sharing with your friend and the other is a texting session that you're sharing with another friend think a little bit about what defines this relationship versus this relationship I want you to focus a little bit on the element of time can a phone call take place if both parties are not present at the same time what about a texting session what happens if you're trying to make a phone call and the other person's not there what happens if you send a text and the other person is not there I want you to think about these the differences between these two scenarios now I'm gonna paint a third scenario and your job is to figure out is that third scenario more like this or is it more like this let's say you've ordered a package from Amazon so you've gone to your computer and sent the order in and then three days later the UPS truck driver shows up takes out the package and knocks on your door and hands it to you is that scenario more like the phone call or the texting session hopefully you agree that it's more like the texting session the idea here is that you can send a text to somebody and they don't have to be there waiting for the text or even looking at their phone they may be off eating dinner or driving a car and they may not get to your text for several minutes or perhaps even hours or days but eventually they'll return your text and the conversation can continue we say this is an asynchronous event because it doesn't really involve time in comparison a phone call is a synchronous event you have to take turns you have to both be on the call and you have to both be present for the entirety of the call when you order a package this is an asynchronous event you've used the computer to order the package and then the service combination of Amazon and UPS are delivering the package to you you don't know exactly when the package is going to arrive but it when it eventually does you have to stop doing what you're doing and receive the package we're going to talk now about asynchronous processing in general look at this main thread I want you to imagine that these are the instructions that a computer is executing and then somewhere along the way it shoots off this other instruction to the side asking for our service to be implemented the service box does what's requested by the main thread and returns an answer meanwhile main execution flow is still continuing at some point the program has to stop and handle this service response and then it can continue with its main thread of execution so we see here that the asynchronous processing basically has a non timed element here because it does not know when this service is going to respond now let's have a look at the difference between a synchronous and an asynchronous database application here we have code blocks from both a tiny database which stores information locally on the phone or tablet and works synchronously versus a cloud database that stores information on the web and returns information asynchronously let's have a look at the store values you can see that they're they're nearly identical but when we get information back from the database that's when the difference really starts to show up consider for example the get value for tiny DB look at the little puzzle like appendage on the top left this is a clue that the operation is synchronous we give it the tag here x value the information is returned nearly immediately and we can take this block and plug it into a variable such as X or any expression and so basically we don't have to wait for the database to give us an answer in comparison consider the get value on cloud dB notice that there is no puzzle-like appendage on the top left that's because the answer is not immediately provided instead it shows up sometime later in the form of one of these two gold-colored event blocks the got value is triggered eventually after a get value request from a user and the data changed event happens whenever data changes in the data the availability of the data changed event allows us to simplify our coding significantly because we do not have to sit there and repeatedly pull the database and ask it if any data has changed instead we can go about our business and anytime anything happens in the database it alerts us autonomously this chart summarizes the differences between an asynchronous cloud database and a synchronous tiny DB the cloud database takes a lot longer to retrieve data because it has to go out to the web to get at it whereas the tiny DB stores the data locally on the phone or tablet the main advantage of the cloud database is that it makes it much easier to share data among multiple users