mysql - Data Synchronisation among clients -


i have database server (mysql).

this holds table of products. 1 of field of products table remaining quantity.

i have few clients (around 10) querying remaining quantity while placing order. once order placed remaining quantity decreased based on order.

i face problem when quantity low: example if remaining quantity "10" , client1 creating order 8quantity(order not yet placed, in process ) , client2 places order 5 quantity, client places order latter fail.

i want improve system such when 1 client in process of ordering, other clients should shown (remaining quantity - client1 order quantity). thought of altering remaining quantity entered in order table, creates problem when order cancelled or computer placing order powered off / crashed.

please suggest me suitable algorithm handle case effectively.. whenever order in progress, other clients should see (remaining quantity - order in progress quantity).

one answer might in question:

other clients should see (remaining quantity - order in progress quantity). 

so problem store data on "orders in progress"

some people add "confirmed" attribute orders, can set true/false maintain correct information. or have separate structure record orders in progress, , move them permanent order table after confirmation. either way, available stock is, said, (stock - orders in progress quantity), query give that.

then, need know cancellations. if cancellation explicit - user changes basket - it's easy: remove order. awkward case when order not completed through: when "order in progress" not "in progress" more? set given time order remains in progress, , let user know, e.g. "your order remain in basket 24hrs, after priority given other customers on stock" - or this.

your system use cleanup process compare current date/time time "order in progress" made, , if order old it's cancelled - or @ least put on hold client renew.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -