‫So another theory lecture
‫about all the writes you can do on DyamoDB,
‫just so you have a really good understanding of them.
‫So the first one is concurrent writes,
‫which we have an item and say to the users,
‫"Want to update the item."
‫So the first one say,
‫"Hey, update this item to value equals one."
‫And the second one says,
‫"Hey, I want you to update the item with value equals two."
‫Now what happens? Well, they're both going to succeed.
‫So the first one will maybe update to value equals one.
‫The second updates to value equals two.
‫And so maybe the second write
‫will overwrite the first writes,
‫if it happens afterwards, okay?
‫But one of them will be overwritten.
‫And this is not a very desired behavior
‫because two of them try to update an item
‫and both get success,
‫but obviously only one of them really succeeded.
‫So that's why it's called concurrent writes.
‫So how can we solve this?
‫We can do conditional writes.
‫In conditional writes, the idea is that the user says,
‫"Hey, I want to get this item with value equals one,
‫but only if the value is currently zero."
‫And the second person says,
‫"Hey, I want you to do the value of this item
‫with value equals two, but only if the value is zero."
‫What's going to happen now is that, for example,
‫the first write is going to be accepted.
‫So the value will be equals one.
‫And the second write is going to fail
‫because at the time
‫of evaluating the condition value equals zero,
‫it turns out that then it would to be able say,
‫"Hey, you know what?
‫Actually, the value now is one."
‫So we shouldn't do your writes.
‫So this is a way to solve the concurrency problems.
‫And that's why it's called optimistic locking.
‫Now another kind of writes you can do are atomic writes.
‫So in this example, the user say,
‫"Hey, I want you to increase the value by one,"
‫and the user two say,
‫"I want to increase the value by two."
‫Now both writes are going to succeed.
‫And the value in total will be increased by three.
‫So one plus two equals three.
‫And finally, nothing to do with these kind of concurrency,
‫but just batch writes is when a user writes or updates
‫many items at a time, okay?
‫So now you know,
‫all the types of writes you have in DynamoDB,
‫and it should make sense to you at the exam.
‫I hope you liked it and I will see you in the next lecture.