This is a fairly easy table design. You'll want a table that stores
the type of questions that can be asked, and the basic HTML code that
will do with them. This is for the admins. A table with the
questions and the actual HTML for each questions, ie the drop down
code, the radio button code, etc. and the actual question, and a table
which will store the answers. If you want to have more than one
survey you'll need a table to account for that.
create table QuestionTypes
(QuestionType_ID int,
QuestionType_Desc varchar(25),
BasicHTML varchar(100))
create table Surveys
(Survey_ID int,
Survey_Desc varchar(100))
create table Survey_Questions
(Survey_ID int, /*This is only needed if you use a Survey's table*/
Question_ID int, /*This is unique per survey, this will also be the
order of the questions*/
Question_HTML varchar(500), /*This is the actual HTML that will be
displayed for the question*/
)
create table Survey_Answers
(Survey_ID int, /*This is only needed if you use a Survey's table*/
AnswerGroup_ID int /*This will tie all the answers together so that
you can group them by person. This is important even if you don't
identify the person, so that you can do some advanced grouping such as
if they answered X for questions 2 and Y for question 3. Without this
table that can't be done.*/
)
create table Survey_Answers_BreakDown
(AnswerGroup_ID int,
Question_ID int,
Answer varchar(1000) /*This needs to be a large field to account for
large text answers.
)
This code is Microsoft SQL Code, it should run on MySQL without to much trouble. |