Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7194851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:27:31+00:00 2026-05-28T20:27:31+00:00

Ok, I know this isn’t a unique concept. However the examples and tutorials I

  • 0

Ok, I know this isn’t a unique concept. However the examples and tutorials I find don’t really cover much they are all about this is what you do, upload it and done. Which to many extents is ok. However I want to build one from scratch.

What I have is a users who are voting on products and I am trying to figure out how to put the tables together properly to support this. So I have my users table, my product table, and from that I want to create 2 new tables. One thats actually the votes per product which will have a unique ID per product vote ranking so I can then have a second table that would have comments along with the votes. I could create on large table for the combination of the 2, yes.. but I foresee issues with that down the road as the table grows. So I would rather keep the 2 seperate. Another thing I want to do is keep tabs on the 10 different rank choices. 1/2 being the lowest 5 being the highest with total over all votes. So whats the best way to construct a table for at the least the rating storage per product.

That aside whats the best way to put the numbers in? decimals? whole numbers? how would I calculate the 5 star concept.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:27:33+00:00Added an answer on May 28, 2026 at 8:27 pm

    Three tables (two of which I assume you already have):

    users (id, etc...)
    products (id, etc...)
    
    votes (userId, productId, rating, comments)
    

    rating can be a SMALLINT type. This gives you a range of 0-255, and you could treat this as the user’s score “times ten”. eg: 4 stars = 40, 0.5 stars = 5. Unless you foresee users wanting to give something 3.1415 stars, that should be quite sufficient, plus more memory efficient than a float column.

    Then, when you want to find the average score:

    SELECT AVG(rating) FROM votes WHERE productId = xxx
    

    I don’t think that you should have any particular problems with a table structure like that. If you were being super-amazingly-paranoid, then yes, you could create a separate table for the comments, however, that would be the textbook definition of premature optimisation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this isn't a unique issue but I've not had much luck finding
I know this isn't really how <button> elements are supposed to be used, but
I know this isn't a straightforward question but I would really appreciate some feedback
I know this will seem like a really stupid question, but I just don't
I know this isn't strictly a programming question but y'all must have experienced this.
I know this isn't strictly speaking a programming question but something I always hear
I know this isn't best practice, but can I include all of the dependencies
I know this isn't so complicated but I can't remember how to do. I
I know this isn't right, but for the sake of illustration I'd like to
I know this isn't directly related to programming, but I was wondering if anyone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.