What Happens When Multiple Users Hit the Same Database Record

Imagine an e-commerce website during a flash sale. Thousands of users try to purchase the last remaining iPhone at exactly the same moment.