Reputation: 21672
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.
id
- story IDname
- authorstory
- storyupvotes
- number of upvotesupvoter_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.voter_id
- Unique ID stored in cookiestory_id
- ID of story that was upvotedUpvotes: 0
Views: 63
Reputation: 25214
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.
Upvotes: 1