R
Rune
Hi,
I'm developing web surveys where users logon to a web survey and answer up
to about 50 questions, one after the other, shown only one question at a
time. The answers are saved in a database.
A fellow developer and I are discussing when is the best time to save the
answers. We have two approaches in mind:
Approach 1:
After each question is answered, the answer is saved in the database.
Sessions are only used to store the User ID.
Approach 2:
After each question is answered, the answer is saved in a session variable.
When the user has finished the entire survey, all the answers are saved at
once in the database. Also, if the user logs out, or if the session times
out, the answers answered so far are all saved in the database at once.
The amount of actual data sent to the database is the same in both
approaches, but Approach 1 have much more frequent calls to the DB, thus
creating an overhead of opening and closing connections. I'm not sure how
significant that is. On the oter hand, Approach 2 store a lot of data in
sessions. I'm not sure how bad a thing that is.
Which approach is better and for what reasons? I'd be happy to supply more
information if needed.
If this question is better asked in a different newsgroup, please let me
know.
Best regards,
Rune
I'm developing web surveys where users logon to a web survey and answer up
to about 50 questions, one after the other, shown only one question at a
time. The answers are saved in a database.
A fellow developer and I are discussing when is the best time to save the
answers. We have two approaches in mind:
Approach 1:
After each question is answered, the answer is saved in the database.
Sessions are only used to store the User ID.
Approach 2:
After each question is answered, the answer is saved in a session variable.
When the user has finished the entire survey, all the answers are saved at
once in the database. Also, if the user logs out, or if the session times
out, the answers answered so far are all saved in the database at once.
The amount of actual data sent to the database is the same in both
approaches, but Approach 1 have much more frequent calls to the DB, thus
creating an overhead of opening and closing connections. I'm not sure how
significant that is. On the oter hand, Approach 2 store a lot of data in
sessions. I'm not sure how bad a thing that is.
Which approach is better and for what reasons? I'd be happy to supply more
information if needed.
If this question is better asked in a different newsgroup, please let me
know.
Best regards,
Rune