1

I am trying to create a database table for my project but I stuck in this type of data.

The purpose is the admin can add, modify or insert types of questions and choices

example:

Do you like pokemon?

  • Yes
  • No

Pick the pokemons you like

[] charmander

[] pikachu

[] squirtle

[] bulbasaur

Pick your starting pokemon:

  • charmander
  • pikachu
  • squirtle
  • bulbasaur

Why pikachu is so cute?


Explanation here


Here is my table

Questions table

id | question | type

Choices table

id | choice | question_id

UserAnswers table

id | choice_id | question_id | answer | userid

my problem is where to put the explanation of the user since it would be a large set of text? I am still very new in database designing and don't know what to do with this type of scenario. Please any recommendation for a good way to design my table.

asked May 19, 2015 at 9:32

1 Answer 1

0

I think you're on the right track.

I presume questions.type (NB type might be a reserved word and cause problems) will have the check constraint check type in ('multiple_choice','free_text') or something similar.

Then all you would need to do is rename your proposed UserAnswers to UserMultipleChoiceAnswers and drop the column answer, and create another table, UserFreeTextAnswers with columns id, question_id, answer, user_id.

answered May 19, 2015 at 11:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.