Possible Duplicate:
Rating System in PHP and MySQL
I am working on a rating system on a scale from 1 to 10. I want to be able to keep track of all users ratings and if they have already rated that particular item.
Notes:
-I have a log in so every user has a unique id in the database.
-Each particular item also has a unique id.
My question is: How should I store this information accurately in a database in the best possible manner.
This is how I am thinking of doing it:
Unique_Key | Item_ID | User_ID | User_rating
1 1 1 (1-10)
2 1 2 (1-10)
3 2 2 (1-10)
4 3 1 (1-10)
5 4 1 (1-10)
So if the Item_ID a user is rating is already in the db with their User_ID they wont be able to rate, otherwise they can.
I am looking for suggestions if this is a safe, clean way to do this before I start any coding. Thank You.
If you add a unique key to your
itemID–userIDcombination then this will be a save method to store that information.You can add a unique key like this