Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be the best way to store the questions and responses for a survey where I need to keep the traffic on the database to a minimum?

Background
I am writing a survey that is going to a large audience. It contains 15 questions and there are five possible answers to each question along with potential comments.

The user can cycle through all 15 questions answering them in any order and is allowed to leave the survey at any point and return to answer the remaining questions.

Once an answer has been attempted on all 15 questions a submit button appears which allows them to submit the questions as final answers. Until that stage all answers are required to be retrievable whenever the user loads the survey page up.

The requirement is that the user only sees one question on a page and 'Previous' and 'Next' buttons allow the user to scroll through the questions.

Requirement
I could request the question each time the user clicks a button and save the current response and so on but that would be a large number of hits to a database that is already heavily used. I don't have the time to procure a new server etc so I have to make do with what I have. Is there any way I can cache the questions on the user machine and/or responses? Obviously I need the response data to be secure and only known to the user so I feel a little bit stuck as for the best way of doing this. Any pointers?

I am prepared to offer a bounty of 100 points on this question if it means I get some good quality discussion and feedback going.

like image 349
Ian Roke Avatar asked Apr 12 '10 19:04

Ian Roke


1 Answers

Unless there's a reason for using a database, you could always store the results in flat files on the server itself. It doesn't sound like the data you're storing is relational in any way. Worst comes to worst, you could always insert them back into a relational db as a batch job every night.

Another option would be the application cache. However, if your web server suddenly crashes on you, you risk losing information from there.

You could also store the values in the user's cookies.

like image 88
Kevin Pang Avatar answered Sep 26 '22 03:09

Kevin Pang