Given a table of votes (users vote for a choice, and must supply an email address):
votes
--
id: int
choice: int
timestamp: timestamp
ip: varchar
email: varchar
What's the best way to count "unique" votes (a user being a unique combination of email + ip) given the constraint they may only vote twice per hour?
It's possible to count the number of hours between first and last vote and determine the maximum number of allowed votes for that timeframe, but that allows users to compress all their votes into say, a single hour-long window, and still have them counted.
I realize anonymous online voting is inherently flawed, but I'm not sure how to do this with SQL. Should I be using an external script or whatever instead? (For each choice, for each email+ip pair, get a vote, calculate the next +1h timestamp, count/discard/tally votes, move on to the next hour, etc...)