Search code examples
sqldatabase-designrating-system

Database design for a rating system


The application handles users and objects, users rate objects with 3 features (one rate per feature).

EDIT: the last sentence is unclear : by features I mean criterias shared by all the objects

How efficiently design a database for such a system ? What are the best-practices for designing a database dealing with a rating system ?

what I was thinking of:

Tables:

  • users
  • objects
  • feat1rates
  • feat2rates
  • feat3rates

and relationships : An object has many

  • feat1rates
  • feat2rates
  • feat3rates

A user has many

  • feat1rates
  • feat2rates
  • feat3rates

Solution

  • Assuming you are not going to increase or decrease the number of rating features to rate, I would make a single table of ratings that would track the user, the product, and three columns (one for each feature)

    So you have your Users table, an Objects table, and your Ratings table which has the UserID and ObjectID as a combined primary key, that way you enforce the one rating per object per user standard.