954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Database/table structure for points system

I'm trying to make a membership system where users can 'approve' or 'disapprove' another member only once. If they have approved the member previously or disproved the member previously, I want to be able to detect it.

I also want to display the average user approval for each member on their profile. (# of approvals/ # of approval+disapproval received)

I'm thinking of having 2 tables:
1. The `members` table - basic user info
2. The `ratings` table - each row is an entry for when user#1 votes (+ or -) for user#2.

My concern is this:
1. Is this the most efficient way to implement such a system? If not, can you please suggest a better way to do it?
2. Will it take up too much resources if I have to query the ratings table everytime I have to fetch the average rating?

Thanks for helping me. *in advance haha*

kanaku
Posting Whiz
378 posts since Jan 2007
Reputation Points: 70
Solved Threads: 15
 
users can 'approve' or 'disapprove' another member


User is Member?! or each another entity!!

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Eep. Sorry for switching terms... Users are the same as members.

kanaku
Posting Whiz
378 posts since Jan 2007
Reputation Points: 70
Solved Threads: 15
 

[User] table still the same
[Rating] table has (Voter_Member int #, Voted_Member int #, Rating int)
- Composed primary keys (to maintain user can't de\vote user two times)
- Rating int (if you need some higher rating 1 2 3 4 or -1 -2 -3 -4)

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

*googles primary key... 0.0*

So I have to set voted_memberID and voter_memberID as primary keys?

Yey! Thank you so much for the advice. ;-)

kanaku
Posting Whiz
378 posts since Jan 2007
Reputation Points: 70
Solved Threads: 15
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You