开发者

Data Structure

开发者 https://www.devze.com 2022-12-28 08:24 出处:网络
I am building a online form, with about 20 multiple choice checkboxes. I can get the nested data with this command.

I am building a online form, with about 20 multiple choice checkboxes.

I can get the nested data with this command.

raise params.to_yaml

I need to store these data and call them again later. I want to sort out which use开发者_如何学JAVAr chose which specific checkbox, i.e. who chose checkbox no.2?

What's the best way to store these data in database?


The easiest way to run reports on your collected data is going to be storing it in a structured fashion.

Something along the lines of:

Question has_many Answers 
Answer belongs to User

Creating Question, Answer and User models with corresponding tables.

The alternative would be to just brute force through the YAML data. It might work for smaller data sets, but it won't be pretty. You could fetch all of the responses, iterate through the responses to find and collate the results for specific questions. I think the structured approach, although a little more legwork initially, is going to be easier in the long run.


you may take a look at smerf for questionnaire building, if not too over-killed

0

精彩评论

暂无评论...
验证码 换一张
取 消