我应该如何为我的Android应用程序构建/设计评级系统?
I am building a mobile Android application where users are able to find the nearest locations around them and then when viewing these places, they are allowed to see the details and also rate it. On top of this, they are allowed to add new places onto the map. I want to be able to lower the chance of people adding fake spots the best I can and so this is why I want to implement a ratings system, which is another layer security for fake spots.
I am not sure how I should design my database tables. Right now I only have:
Location: name, address, type, terrain, difficulty, lng, lat, rating.
The ratings column is only allowed values: 1, 2, 3, 4, 5.
What else would I need to keep the sum of the ratings?
After designing the tables. I want to know the most appropriate way to calculate the average ratings and then be able to delete them based on their ratings. The problem is, if a spot has 1 vote with a rating of 1 which is 100% negative then it will be considered bad when a a spot has a vote of 100 with 90 votes with 1 and 10 votes with 5. Surely, the first one should be considered worse and then deleted. How do I counter this?
我正在构建一个移动Android应用程序,用户可以在其中找到最近的位置,然后查看这些地方 ,他们被允许看到细节,并评价它。 除此之外,他们还可以在地图上添加新地点。 我希望能够尽可能地降低人们添加假点的机会,所以这就是为什么我要实施一个评级系统,这是假点的另一层保障。 p>
我不确定如何设计数据库表。 现在我只有: p>
位置:名称,地址,类型,地形,难度,lng,纬度,等级。
code> pre>
评级栏仅允许值:1,2,3,4,5。 p>
我还需要什么来保持评级的总和? p >
设计表格后。 我想知道最合适的方法来计算平均评分,然后能够根据评分删除它们。 问题是,如果一个点有1票,评级为1,这是100%否定,那么当一个点有100票,90票,1票,10票,5票时,它将被视为不好。当然,第一个 应该被认为更糟,然后删除。 我该怎么解决这个问题? p>
div>
I would say making a separate table containing foreign keys of the id of the location and id of the user submitting the review would be useful(as well as there rating of course). This way users could edit their review at a later time.
There's lots of ways of doing this. More complex trend-monitoring systems buffer votes and look at the rate over the last day, hour, minute etc.
However, for a simple system, you could look at total number of votes and average rating. You may not care about the sum (and you can get it anyway from the other two).
To update the rating:
average = ((average*total)+new)/(sum+1);
total ++;
When you look at deleting them you'll want to set a threshold for a minimum number of votes (total) and then delete based on average rating. 1 bad vote probably isn't really enough, how many you think is, depends on your usage levels.
For other answers: PHP/MySQL - algorithm for "Top Rated"