Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Dynamic Database Content Design

$
0
0
Hi,

'm currently working on a survey system(PHP/MySQL) where the content is dynamically generated. Users can create their own questions and other users can answer these forms.


How do I go about designing the database? What is the best approach? Do I save each question in an individual row? Do I create a text field and populate it with long string with delimiters then explode it? Same goes for the response. It is estimated that there is going to be several thousand surveys and I can only imagine that amount multiplied for responses.

I'll give you an example to illustrate my point a little clearer :)/>



Survey Table
id
name
date

survey_question table
id
survey_id
question
type
date

survey_user_answer
id
user_id
question_id
answer
date




Should I store it in this manner, where every response gets a field? Eg:

Survey Table
1    user survey    21/12/2012
2    marketing survey    22/12/2012

survey_question table
1    1    how did you feel about the user?    subjective    21/12/2012
2    1    how do you think the user did?    subjective    21/12/2012
3    1    where should the user got today?    subjective    21/12/2012
4    2    what did you think of the marketing?    mcq    21/12/2012

survey_user_answer
1      1    1    the user was not reponsive    21/12/2012
2      1    2    the user didn't do well    21/12/2012
3      1    3    the user should go to  DIC  21/12/2012
4      1    4    the marketing was too obvious   21/12/2012
5      2    1    the user was not reponsive    21/12/2012
6      2    2    the user didn't do well    21/12/2012
7      2    3    the user should go to  DIC  21/12/2012
8      2    4    the marketing was too obvious   21/12/2012
9      3    1    the user was not reponsive    21/12/2012
10     3    2    the user didn't do well    21/12/2012
11     3    3    the user should go to  DIC  21/12/2012
12     3    4    the marketing was too obvious   21/12/2012




OR:


Survey Table
id
name
questions
date

survey_user_answer
id
user_id
survey_id
answer
date




Should I store it in this manner, where every response or survey is stored in a single row and put in a dilimiter? Eg:

Survey Table
1    user survey    1%subjective%how did you feel about the user?@2%subjective%how do you think the user did?@3%subjective%where should the user got today? 21/12/2012
2    marketing survey    1%mcq%what did you think of the marketing 22/12/2012


survey_user_answer
1    1    1    1%the user was not responsive@2%the user didn't do well@3%the user should go to DIC    21/12/2012
2    2    1    1%the user was not responsive@2%the user didn't do well@3%the user should go to DIC    21/12/2012
3    1    2    1%the marketing was too obvious    21/12/2012




What about storing it as XML? Does that work? Could anyone please provide an opinion or point me in the right direction.

Pros? Cons? I just need advice :D

Thanks in advanced!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>