views:

51

answers:

1

I'm currently researching a project for the place that I work in. We are trying to create a system that will allow forms to be set up dynamically from a database.

My question is what database structure would best suit something like this?

I currently have a structure of:

forms_form
forms_formfields
forms_formdata

I don't think this is the most appropriate layout for this. Basically to make is make sense I need to be able to make a form within the database that can have infinite fields all customized and have the data when submitted stored in the database.

+1  A: 

The proposed structure looks ok to me. form -> field is clearly 1:M relation, so you'll need forms(id,...) and fields(id, form_id, type, ...). field->data is kind of 1:1, so theoretically a separate table is not needed, unless you allow one form to be used with different sets of data. If this is the case, i'd suggest datasets(id,...) and data(field_id, dataset_id, value).

stereofrog
can you elaborate what you mean by different sets of data for one form? the data will still be held in the database for each form that is submitted, also the form it self is held in the database.
Neil Hickman
yes, this is what i meant - a form can be submitted many times with different data.
stereofrog