Welcome to WebmasterWorld Guest from 54.205.60.49

Forum Moderators: open

Message Too Old, No Replies

multiple entries for one field type

   
3:59 pm on Mar 16, 2010 (gmt 0)

5+ Year Member



hi im doing a website for nightlife in london. a user can rate the place they go to out of 1-10. im doing the database on phpmyadmin. i want the user to be able to rate the place as many times as they like. im not sure how to do it so would i be able to get assistance?

thanks in advance
6:37 pm on Mar 16, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



table users
id|user_id|fname|.....

table ratings
id|user_id|location_id|rating|.....

Like that, joined on user_id? Users would have multiple rows in ratings. You could do a sum or display individual ratings for each location.
7:28 pm on Mar 16, 2010 (gmt 0)

5+ Year Member



would i make user_id primary key on both tables?
8:57 pm on Mar 16, 2010 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



i want the user to be able to rate the place as many times as they like.

DB structure aside, this sounds like a recipe for spamming your site.
9:40 pm on Mar 16, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



would i make user_id primary key on both tables?


No, in the example given above, id is the primary key in both tables and user_id is a foreign key in the ratings table.
However personally I would make the ID fields a bit more distinct and not have two different id fields in the user table as below.

table User
User_ID|Firstname|.....

table Rating
Rating_ID|User_ID|Location_ID|Rating|.....