Database for Rating System?
So I'm currently trying to implement a rating system, more specifically i 'vote up' or 'vote down' type rating system for my website.
What I want to know is, Do I need to create a database in mysql for this? And if so, could you give me some specifics on what the table would include?
Personally, I would not want to do it without some sort of database, though it would not necessarily have to be MySQL.
At a minimum, you would probably need at least 3 tables: one for the things that get rated, one for the users who do ratings, and one to track the ratings (foreign keys to both the "users" and "things" tables, probably with a unique index on those two keys so that that cannot rate the same thing more than once.
Firstly, I'd definitely recommend that you use a database for something like this as you'll likely be storing a great deal of information over time and you'll want this to be organized and easily accessible (to save and load results).
Now, I'm really not any sort of data guru so there may be a better way of going about this but my initial thought is to have a table that would include fields such as: id, rate_id, user_id, vote
And to explain, id would be a pretty standard field, auto-incrementing primary key that is just used to identify each individual vote. The rate_id would be used if you are implementing this system for a number of different pages or individual items (videos, images, songs, etc.). Each rate_id would be different per item, and this allows you to load the results for each specific page. The user_id would be to prevent duplicate votes. Assuming you have some sort of user system, or at least a way to identify unique users, this field would be populated with that identifier so new votes for the same item/page could not be duplicated by the same user. And lastly the vote field would be a simple value to show what the actual vote is. It could be a 0 or a 1, it could be a Y or N, it could be a U or D or you could actually use whole words such as "up" or "down". As long as you know what each value stands for.
I sure am getting crushed in response time today... My reply is really a supplement to NogDog's, as those other tables would be necessary to properly manage/organize the whole system.
"Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"
As an aside, I work on a physician rating system which uses 18 DB tables, but that's probably overkill for what you need.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)