I'm making a site where users can post a "story" and then other members can upvote it. The question I have is regarding how to restrict people from upvoting multiple times. You do NOT need to sign-up to upvote.

These are my ideas, and if anyone could give me feedback about which would be best, or an idea of your own that would be better, it would be much appreciated.

Have a table set up like this...

id - story ID

name - author

story - story

upvotes - number of upvotes

upvoter_ids - list of all unique ID's who have upvoted separated by a space. Unique ID is stored in a cookie on first visit. Upon revisit, pull all the IDs, explode them at the space, and see if there's a match.

Create a new table just for votes, adding a row for every single vote.

1 Answer
1

The cookie-based ID system is a fairly good one. If you aren't going to authenticate your users then you cannot absolutely prevent determined folks from voting again and again. But, if you aren't requiring people to vote then I am assuming that you accept that this kind of thing may happen from time to time.

The only change that I would make is to have a one-to-many relationship table with stories and upvote IDs. You can then query this table, filtering on story IDs to get the IDs of all those who upvoted. This is cleaner than exploding a space-delimited string.