I need to create a database for a wordy questionnaire. At the end I want to be able to graph my information. Where can I do this?
Asked
Active
Viewed 1,784 times
1 Answers
-1
Create a table that stores the questions, answer type and answer values
+-------------------------------------------------------------------------+
| Questions |
+---------------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-----------------+------+-----+---------+----------------+
| QuestionId | int(6) unsigned | NO | PRI | NULL | auto_increment |
| QuestionText | varchar(256) | YES | | NULL | |
| AnswerOptions | varchar(512) | YES | | | |
+---------------+-----------------+------+-----+---------+----------------+
Comments
AnswerOptionsfield is optional, and its default is set to an empty string. I would set it to a JSON string vector containing the options for a question withDataTypeset to checklist, or list. (Something like[ "first option", "second option" ])
Create a table that stores the answers
+---------------------------------------------------------------------------------+
| Answers |
+------------+------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+-------------------+----------------+
| AnswerId | int(10) unsigned | NO | PRI | NULL | auto_increment |
| AnswerTime | datetime | YES | | CURRENT_TIMESTAMP | |
| Username | varchar(20) | NO | | NULL | |
| Answers | int(6) | NO | | NULL | |
+------------+------------------+------+-----+-------------------+----------------+
Comments
- I suppose you can keep track of people who answer your poll, so I added a
usernamefield. If that's not possible, you can simply not add that field to your table. - The
Answersfield should store JSON as well, because that will ensure maximum flexibility: you can add as many questions as you want, and as many answers as you want. So, JSON which can keep an object with key-pair items, representing the question index (theQuestionIdfield fromQuestionstable) and the answer index (the index of the answer in the vector fromAnswerOptionsfield).
I think I've covered everything you need. The rest of your question represents programming, so I don't think it belongs here. You can find information about graphing database information on Google
Victor
- 436
- 1
- 6
- 15