Keeping track of votes

I’m adding my own rating system on my site, and am wondering what the best way is to keep track of people that have voted.

The obvious solution seems to make a new row for each vote that records the id of the item voted and the user’s IP (or some unique id I assign the user in a cookie).

I’ve never done this before and am a bit wary because this database would get really big, really quickly. Is there some drawback to doing this and querying the DB every time someone votes to check if they’ve already done so?

Would it be less intensive for the server to keep all the voted ids on a single row and have PHP parse through a string of concatenated ids? As weird as that sounds, it’s worked for me in the past. (put them together with a delimiter, then explode() them, and parse through the array)

Excellent. I guess that’s all I really needed to know. Thanks everyone.

@c2uk: I haven’t used serialize, and I’m not entirely sure it would have fit the purpose

@r937: I would be getting about 100 votes a day. I’m asking because I’ve never tested the limits of MySql. At what point would I need to do something special to keep it from being slow? 100,000 rows? More?

way more

:slight_smile:

Not answering your original question, but referring to this particular technique, isn’t that what the PHP function serialize/unserialize is good for?

With regards to your original question, I doubt this would be better than your suggested database solution, though I admit my knowledge is fairly limited.

depends on how you measure “really big” and “really quickly”

unless you’re amazon or ebay, my guess is you will not have to look for anything other than the normalized table design (one row per vote), which is best practice

no, it would be worse