Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In a site like StackOverflow should the Question and its Votes be separate tables?

I'm making a site like StackOverflow in Rails but I'm not sure if it's necessary for the Votes on a question to be stored in a separate table in the database.

Is there any good reason to separate the data?

Or could I store the Votes as a single sum in a field of the Questions table?

like image 737
Charlie K Avatar asked Jun 12 '09 04:06

Charlie K


People also ask

What Does votes mean on Stack Overflow?

Voting up a question or answer signals to the rest of the community that a post is interesting, well-researched, and useful, while voting down a post signals the opposite: that the post contains wrong information, is poorly researched, or fails to communicate information.

What happened to Stack Overflow?

Stack Overflow plans on discontinuing Stack Overflow Jobs and Developer Stories by March 2022. The popular question-and-answer site will sunset its Developer Stories in late January, followed by the Salary Calculator in February.

Why was my question closed Stack Overflow?

Questions posted on Stack Overflow which are not related to programming topics, are marked as 'closed' by experienced users and community moderators. A question can be 'closed' for five reasons - duplicate, off-topic, subjective, not a real question and too localized.


1 Answers

How would you know if a user voted on a question without keeping a votes table? Or like this website that holds you to X votes a day, how would you know how many votes a user made in the day? How would you keep track of how many up and down votes a user has done? I think good design practices pretty much scream for you to normalize the data and keep a votes table, with perhaps keeping a current +/- denormalized field in the question row for easy fetching.

like image 107
Paolo Bergantino Avatar answered Oct 13 '22 00:10

Paolo Bergantino