dongyingtang3803 2012-11-19 00:35
浏览 8
已采纳

返回用户最佳分数的结果页面

I currently have a MySQL table setup that saves only the User's best score. If they get a better score the previous score is updated. I also want to have a 24 Hour leaderboard that only shows scores posted within the last... 24 hours.

Two options come to mind:

1) Have 2 separate tables for each leaderboard. A "Best Score" leaderboard that only saves 1 score per user and a "24 Hour" leaderboard that saves 1 score per user and is time stamped. This means every time a score is submitted it needs to be sent to 2 tables instead of 1 but the data footprint will be minimal compared to the next option.

2) Have 1 table that allows duplicate scores to be posted per-user, time stamps the scores and then simply queries the huge table of scores with the data I need (best score overall, scores within 24 hours, etc).

Any ideas/suggestions? This is the first time I've dealt with PHP/MySQL so I'm not sure what the best approach would be design/efficiency-wise.

  • 写回答

2条回答 默认 最新

  • doufu8588 2012-11-19 00:42
    关注

    For a normalized database, you should only have the 1 table for all scores. You should only insert, not update or delete.

    Then, if you want to find the maximum score for instance, you could apply a MAX on the query.

    If you want to find scores within the last 24 hours, you could add this into your WHERE clause.

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

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示