dopnpoh056622 2010-04-12 16:05
浏览 10
已采纳

我应该如何为像SO和yahoo答案的用户创建一个积分系统?(PHP)

I am creating a voting system for a Q&A site project in which if a user asks a question, he/she losses -5 points; answer a question +5, vote a question +1, etc. (kind of like SO and yahoo answers)

-->To create the basic arithmetic, I have a "users_points" table that relates the user_id and their total points.

+---+---------+
| 1 | 100     |
+---+---------+
| 2 | 54      |
+---+---------+

-->Basically if the users does certain task, it would + or - the points. How do I prevent users from say voting an answer up 100 times. ex: I want a user to be only able to vote once per question, etc.

  • 写回答

3条回答 默认 最新

  • duanjiwei1283 2010-04-12 16:07
    关注

    You should create a votes table that has the columns: user_id, question_id, delta. Delta is the value of the vote, which should be 1 or -1 (this way you can just do a SUM(delta) to find a question's point value).

    To get the uniqueness, create a unique index on (user_id, question_id).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题