Yes, this is yet another voting design discussion. As far as I can see there are two approaches:
1. A separate table that records the User-Content relationship including the vote -1/0/+1 and, optionally: 2. A voting field in with the content that gets atomically updated with each vote. Just going with table 1 there are some pro's/con's: + you can catch duplicate votes easily + no worries about transaction integrity since each vote is unique - expensive to determine the vote total for a piece of content Adding the field in option 2 flips this around (I think you always need table #1 to prevent duplicate votes) + fast to compute voting total - hard to do transactions via django (I think) Using a postgres backend some of the problems are: * If we do the voting math in the server (v.s. the db) we need to support either "read committed" transactions or "serialized" transactions ... I'm not sure which one django uses by default. The server/django code would look something like this: content = Content.objects.get(id = ...) content.voteTotal += voteDelta content.save() But we could get dirty reads when there are concurrent transactions if the get() occurred while another transaction was being processed. The transaction problems are outlined here: http://www.postgresql.org/docs/7.4/interactive/transaction-iso.html * If we do the voting math in the database, postgres "read committed" is best since there is no effect on the source code ... conflicts are handled by the database. Serialized will work too, but requires special code in the server code to handle the retry and exceptions (will django report this correctly?) UPDATE Content SET voteTotal = voteTotal + 1 WHERE id = ... But, this is going to require bypassing the ORM and writing database specific sql. So, my questions are: 1. What type of database transactions does django support with postgres out of the box? 2. How do we change it? 3. What exceptions will it throw, if any, on a conflict? Any examples anywhere? Anyone have any thoughts on the problem? What am I missing? Any insights would be appreciated. Cheers, Sandy --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---