Databases · Multiple choice

In a flash sale, how do you decrement stock so it never goes below zero?

medium Consistency

Options

Why

Read-then-write lets two buyers read 1 and both write 0. A conditional update is atomic in the database: one buyer's update affects a row, the other's affects none and gets "sold out".

Review this in your daily deck All cards in Databases