nosforit wrote:I could use some help regarding how to set up the database and how to organize the code. If you have a good idea on _how_ to do something, I would like to hear it and go straight to the doing. This way your experience on the subject comes to great use without you having to bother with the detail of the actual coding.
I've decided to add two INT columns each to _users, _posts, and _topics. In one column the total positive karma is displayed and in the other total negative karma is displayed. When the user clicks + or - on a post, the karma count is incremented by one for the user, post, and topic.
I will also add a _karma table which logs user_id of the person who clicked the button, the post_id, the user_id of the receiver, time, a boolean for good karma, a boolean for bad karma, and an a unique key based on user_id and post_id.
The reason _karma logs both good karma and bad karma is that a user will be able to issue both + and - for the same post
. This is because the user might both agree and disagree with the content of a single post. Then good karma alone would be incorrect, and bad karma alone would be incorrect, while controversy would be correct.
The very first thing that the system will do when a user clicks + or - is check if the user is allowed to rate posts based on some still obscure established rules.
Second the system checks _karma if the user has already issued that rating.
If not, the system increments the three appropriate fields and logs an entry into _karma.
When displaying this information to users the system will never have a reason transmit any data from _karma to users, except possibly if we want to tell the users that they have already issued the rating they are trying to issue. This should be impossible anyway by normal means.
This basically concludes the implementation details for Phase no. 1 and Phase no. 2.
Thank you for reading. I will begin coding now.