Database model for user ratings / reviews

时间:2016-08-31 18:03:05

标签: mysql database database-design

What is the best way of modeling user reviews and scores in a database?

So the problem description would be the following:

Imagine we had users who can rate items (give a score to an item), but can also write reviews (with title, content, and also a score), and maybe even submit more types of reviews, such as video reviews (with a video and also a score for instance).

Also, users can rate other user's reviews.

I've came up with the following EER diagram for this problem (does not include attributes nor the relationship between REVIEW and USER that would allow users to rate reviews):

EER User Reviews

In the design above, the different types of reviews (written review or video review) could be modeled by using inheritance, either in the same table using an attribute to differentiate between types or with a table per subclass.

An alternative to this design would be to consider the RATING table another type of review (one with no content or title, just a score), and use inheritance to model all the review types (scores, written reviews and video reviews). The problem I see with approach though is that I would need 2 relationships to allow users to rate reviews (one with written reviews and another one with video reviews), and would make it more difficult as well to retrieve all users reviews (written and video reviews).

Do you think one approach is better than the other (I'm leaning towards the first), or is there a better way of modeling this scenario?

0 个答案:

没有答案