On 10 nov, 05:36, Continuation <selforgani...@gmail.com> wrote:
> I'm working on an auction app.
>
> In an Auction object I store the current_high_bid for that auction.
>
> When a new_bid comes in, I:
> 1) retrieve the current_high_bid field of the Auction object
> 2) compare it with the new_bid
> 3) if the new bid is higher than current_high_bid, I update
> current_high_bid to the value of the new_bid.
>
> but there's a (slight) chance that between steps (1) and (3) a
> different user could've submitted an even higher bid which then become
> the current_high_bid. In that case step 3 should not proceed. What can
> I do to make sure such a situation does not arise?

Well, the SimplestSolution would be to NOT denormalize your DB. From a
relational / SQL POV, you shouldn't store the "current_high_bid" in
the 'auction' table, but query the 'bid' table for the currently max
bid for this auction.

But I guess you have some good reasons to dismiss this solution...



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to