item_id was a int(10)
member_id was a int(10)
date was a timestamp(14)
rating was a int(1)

then each record would take up 35bytes + a little overhead
Neglecting the overhead 20,000 records would take up only 700kb of space.

So size of the db shouldn't be a issue. But if it is then you could changed
item_id and member_id to slightly smaller int types.

If you are worried about speed of searchs etc, I'm pretty sure MySQL can
handle it, but if you want to place some less work on MySQL make a table
which stores the current Averages/Totals/Etc and update that whenever a new
vote is made/changed/deleted. That way MySQL isn't adding up 20,000 records
each time you want to display the current results, and this also leaves you
the flexibility to do other statitisics on your data later.

Hope this helps

----- Original Message -----
From: "Monty" <[EMAIL PROTECTED]>
Sent: Sunday, October 27, 2002 8:21 PM
Subject: [PHP] Best way to store Votes for Survey app

> I'm writing a survey app in PHP (4.2.2) that will allow people to view a
> of photos and then rate each photo from 1-5 using a little dropdown under
> each photo. When they are done choosing their ratings, they click on
> to register all their votes at once.
> I thought the best way to record votes was to create a record for each
> member and each photo they voted on in MySQL. So, for example, if someone
> rates 9 photos, there will be 9 records created in the voting DB
> something like this:
>     item_id     // ID number of the photo being rated.
>     member_id   // ID of the member making the vote.
>     date        // Date vote made.
>     rating      // 1-5
> While this system offers a lot of flexibility in calculating votes, I'm
> worried that the DB will become full fast with records because of the
> of records created for each member when they vote. If there are 10 photos
> and 2,000 people rate those photos, that will create 20,000 new records in
> the DB for that one poll alone.
> So, I'm wondering if anyone has any suggestions for better ways to store
> votes like this without created so many DB records. I want to be able to
> calculate total votes for each photo as well as prevent members that have
> already voted from voting again.
> Any suggestions would be appreciated!
> Monty
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to