实施排名制度 [英] Implementing A Ranking System

查看:138
本文介绍了实施排名制度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到有关如何保护和防止滥用排名系统(如盯着电影,产品等)的几个问题,但实际上没有实现。为了简化这个问题,安全性不是我所关心的,访问这个系统的人都是信任的,如果发生排名系统的滥用是微不足道的,并且比原因更容易回归。无论如何,我很好奇如何保存投票。



一个想法是有一张投票表,记录每个投票,然后立即在预定的时间,或者在产品的每一个负载(这似乎效率不高但可能不是)的情况下,票数是相同的,0到5之间的双倍更新到产品表中的产品条目。



或者,我在产品表中存储总分和多个投票,只是在我显示时将其分开,并在有人投票时将投票添加到总计和增加数字。


还有还有更好的方式做到这一点,我还没有吗?我想在产品表中只有一个评级字段,但不能想到一种更新投票的方式,而没有一些额外的数据。



再次,数据完整性是重要的,但绝对没有必要,任何想法?

解决方案

我会保持一个得分产品,但也会保持一个投票表,看看谁投了什么。当有人投票时,插入投票,更新产品分数。



这样可以快速排序,还有一个表可以重新计算分数,并阻止人们双倍-voting。



没有必要等待写入投票并更新分数。 将会引入问题,如果它像一个传统的系统(读取比写入更多),就没有任何好处。


I've seen several question on how to secure and prevent abuse of ranking systems (like staring movies, products, etc) but nothing on actually implementing it. To simplify this question, security is not a concern to me, the people accessing this system are all trusted, and abuse of the ranking system if it were to happen is trivial and easier to revert than cause. Anyways, I'm curious how to store the votes.

One thought is to have a votes table, that logs each vote, and then either immediately, at scheduled times, or on every load of the product (this seems inefficient, but maybe not) the votes are tallied and a double between 0 and 5 is updated into the product's entry in the product table.

Alternatively, I store in the products table a total score and a number of votes, and just divide that out when I display, and add the vote to total and increment number when someone votes.

Or is there a better way to do it that I haven't though of? I'd kind of like to just have a 'rating' field in the product table, but can't think of a way to update votes without some additional data.

Again, data integrity is important, but by no means necessary, any thoughts?

解决方案

I would keep a "score" with your products but would also keep a vote table to see who voted for what. And when somebody votes, Insert vote, update product score.

This allows quick sorting and you also have a table to be able to recalculate the scores from and to stop people double-voting.

There is no need to wait to write the vote and update the scores. That will introduce problems and if it's acting like a traditional system (lots more reads than writes), gives you no benefits.

这篇关于实施排名制度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆