Jump to content


Photo

Which of these database designs is the best?


  • Please log in to reply
1 reply to this topic

#1 gnuffo1

gnuffo1
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 17 March 2006 - 08:45 PM

The website in planning will have a system for rating and writing reviews on products. Since there will be a lot users that will leave the review field blank, which of these designs is the best:

1. Have two seperate review and ratings tables and when a user does fill out both a one to one relationship between the two records is established. That way records in the review table (or even the rating table is user only write reviews and don't rate) will only be created when there is actually a review.

2. Have one table that contains a review field and the ratings fields. This version will have a lot of NULL (empty) fields, but should be quicker.

Note that the ratings and the reviews are both for the product, the ratings are not ratings of the review or vice versa.
[a href="http://www.sentinelpc.co.uk" target="_blank"]Sentinel Technology - Custom PCs and Laptops[/a]

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 17 March 2006 - 09:27 PM

I think you should go with the former -- if you ever need to store more than a single field about the rating (which you will), then it makes sense to have a separate table. Of course, the FK would be in the ratings table pointing back to the review, not vice versa, or you'd end up with the same problem.

Hope that helps.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users