简体   繁体   中英

Rails Survey App Data Structure

I'm pretty new to rails and have just begun playing around with creating a rails survey app to help better understand a nested data structure. I know I'm going to configure it so that a Survey has_many Questions. What I'm wondering is should I create another object "Answer" to just store each answer response and say a Question has_many Answers? Or should I just look into storing that information into the Question objects themselves? Really the only content that an answer will have is it's name.

I guess I'm looking for recommendations for how to handle this type of nested data structure.

Also, I haven't given too much though with how I would store responses - would having Answers as separate objects be easier to store/display the outcome of the survey?

May be this structure will be useful for you

  1. survey
  2. survey_question, have a foreign of survey
  3. survey_choice, have a foreign of survey question
  4. survey_vote, have foreign of user who is voting and choice id which he will select.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM