I need a fresh look at storing variables in MySQL

[email protected] (tedd)
Newsgroups php.general
Message-ID <p06240801c7c178726ad0@[192.168.1.102]>
Hi gang:

I just completed writing a survey that has approximately 180 
questions in it and I need a fresh look at how to store the results 
so I can use them later.

The survey requires the responder to identify themselves via an 
authorization script. After which, the responder is permitted to take 
the survey. Everything works as the client wants so there are no 
problems there.

My question is how to store the results?

I have the answers stored in a session variable, like:

$_SESSION['answer']['e1']
$_SESSION['answer']['e2']
$_SESSION['answer']['e2a']
$_SESSION['answer']['e2ai']
$_SESSION['answer']['p1']
$_SESSION['answer']['p1a']
$_SESSION['answer']['p1ai']

and so on. As I said, there are around 180 questions/answers.

Most of the answers are integers (less than 100), some are text, and 
some will be null.

Each "vote" will have a unique number (i.e., time) assigned to it as 
well as a common survey id.

My first thought was to simply record the "vote" as a single record 
with the answers as a long string (maybe MEDIUMTEXT), such as:

1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,

Then I thought I might make the data xml, such as:

<survey_id>1</survey_id><vote_id>1268501271</vote_id><e1>1</e1><e2>16</e2><e2a>Four 
score and ...</e2a><e2ai></e2ai>

That way I can strip text entries for <> and have absolute control 
over question separation.

Then I thought I could make each question/answer combination have 
it's own record while using the vote_id to tie the "vote" together. 
That way I can use MySQL to do the heavy lifting during the analysis. 
While each "vote" creates 180 records, I like this way best.

Then I thought, what would you guys do? So, what would you guys do?

Keep in mind that this survey must evaluated in terms of answers, 
such as "Of the ones who answered e1 as 1 how did they answer e2?"

If there is something wrong with my preference, please let me know.

Thanks,

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.