Tony Petley
Tony Petley

Reputation: 359

Group based questions and answers - Ruby on Rails 3

I am looking to created a voting system for my site. I am having a little trouble deciding on how to model it.

At present I have models like so:

Group has many users

On each group page it will have the same question, for example:

"What feature would you like next?"

Each group would have a the same set of answers which can be voted on. I am going to use the Thumbs Up gem to allow answers to be voted on.

The amount of groups is extremely large, somewhere in the region of 5000.

I was thinking about modelling it like so:

Answer has many Responses
Response belongs to Group, Answer and is voteable (acts_as_voteable with Thumbs Up gem)

Could anyone give suggestions on how other wise model this questions and answers? For some reason this doesn't feel correct.

Essentially mutltiple groups will have the same question and answers except different poll results. I want to try and avoid creating a poll and questions for each group as this would result in over 100,000 records in the database.

Cheers

Upvotes: 0

Views: 266

Answers (1)

bento
bento

Reputation: 2099

"Essentially mutltiple groups will have the same question and answers except different poll results. I want to try and avoid creating a poll and questions for each group as this would result in over 100,000 records in the database."

As I understood it you have Questions with a fixed set of Possible Answers, and you store the result in Response?

I would go with a 1:n relationship between Question and Answer, and probably n:m between Group and Question, this way you can "reuse" Questions in multiple Groups.

Upvotes: 0

Related Questions