Welcome to WebmasterWorld Guest from 54.159.48.254

Forum Moderators: open

Message Too Old, No Replies

multiple entries for one field type

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

New User

5+ Year Member

joined:Mar 8, 2010
posts: 4
votes: 0


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)

Senior Member

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

joined:Nov 28, 2004
posts:7999
votes: 0


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)

New User

5+ Year Member

joined:Mar 8, 2010
posts:4
votes: 0


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

Moderator from US 

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

joined:Dec 10, 2005
posts:5589
votes: 27


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 31, 2005
posts:1108
votes: 0


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|.....
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members