What should I do when I request the database?

Source: Internet
Author: User
What should I do when I request the database. There are only 10 items in stock on A website for purchasing products. at this time, each of the three members of A & nbsp; B & nbsp; C buys 4 items and submits them at the same time. In this case, what should the program do. Do transactions need to be performed in the database? If you have a better method, please advise to request the database at the same time. what should I do?
For more information, see.
For A website that purchases commodities, there are only 10 remaining goods in stock. at this time, each of the three persons of a B and C purchased four commodities and submitted them at the same time. In this case, what should the program do. Do transactions need to be performed in the database? If you have a better method, please advise
------ Solution --------------------
Transaction processing. Very correct.
------ Solution --------------------
This is for transaction processing. Otherwise, the inventory will become negative.
------ Solution --------------------
Use innodB for transaction processing
------ Solution --------------------
Really?
Please give the practice
------ Solution --------------------
Sort by time, first buy first ship, then the last person will fail the order, and there is 2 left in the inventory, you can directly query the line.
------ Solution --------------------
Reference:
Sort by time, first buy first ship, then the last person will fail the order, and there is 2 left in the inventory, you can directly query the line.
++

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.