ER Model of User Ratings

大兔子大兔子 提交于 2019-12-11 01:51:06

问题


I have many "Users" and each of them will have maximum of 5 "Services". The User should be able to Rate (0-5) on each Service. I would also like to persist the Avg Rating of the Users.

This is what I am thinking, but there could be a better way?

User

id | user_name | dob | ...

Service (Fixed number of Services)

id |service_description | service_code | avg_rating

Rating:

id | service_id | user_id | rating (0-5)

回答1:


I have created an E/R diagram to depict the way a multiple ratings system can be implemented. Note that I have used generic names for a lot of things.




回答2:


If you allow users to change their rating and want to track their changes, you could simply do so by adding a created_at attribute to the Rating entity. In that way you allways know the current rating (last/highest timestamp) and you can also look up which changes the user did to his rating. A lot of database systems add this attribute by default, as well as the last_changed attribute.



来源:https://stackoverflow.com/questions/24494063/er-model-of-user-ratings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!