storing data for frequently changing forms, how?

I am unclear if you mean to say that you don't want to alter the data in the database each time, or the schema of the database each time. If it is the schema, there are certainly good ways to make such a system generic and be able to make such changes without it affecting the schema.

I have done a similar schema in the past, and here is the schema I would get started with:

forms:   id   name (friendly name for the form)

question_types:   id   question_type (suggestions: text, single-select, multiple-select, etc)

questions:   id   question_text ("please select your breed of llama")   form_id   question_type_id

answer_options:   id   answer_text ("golden llama")   question_id

answers:   id   answer_data   question_id

A note about how the answers work, if the answer type is one that offers options, the available options are stored in answer_options. in the answers table, if the answer is from a option list, it stores a reference to the answer_option. However, if the answer_type is a text one, it stores the text.

This is a bit of a hack, as you have to store the answer as a string, even if its a reference to the an answer_option. There is probably a more elegant way to handle that, but I am shooting from the hip here.

Good luck :slight_smile:

I have been working on something similar. I kindof used the general schema of phpESP.

It is a survey application, but sounds pretty much in line with what you are doing.

In essence, each answer type (int,date, boolean, etc) is stored in its own table. Creating the forms dynamically havent been that bad...I'll be curious when I get to the data retrieval for the results.

Hope that sheds a little light.