views:

330

answers:

1

Wufoo is a:

HTML form builder that helps you create contact forms, online surveys, and invitations so you can collect the data, registrations and online payments you need without writing a single line of code.

How would you approach the database design if building a similar site?

Higher level designs (tables and relationships) or Lower level designs (tables, relationships, fields, views, rules, MySQl queries, etc)... are all welcome :-)

MySQL based solutions preferred ;-)

+4  A: 

This type of database design calls for EAV tables. For example, the form section probably contains:

1. User table (user_id, user_name, etc.)
2. Form table (user_id, form_id, form_name, etc.)
3. Form_field table (form_id, column_id, column_name, column_type, etc.)
4. column_type table (column_type_id, column_type_name)

Filled in results will be saved in a different table:

Filled_form (form_id, column_id, value)

The idea is to create a database model that is just generic enough (but no more than) needed, in order to accommodate for the needs of different users. For example, the column types are set by the programmers, and each type has a different meaning when rendering the form.

OmerGertel
Could you elaborate more on this? form_field.column_is is what? is it from another table? What is column_type table? how does it relate to form_field table? I am doing a small-ish project that will allow me to create forms.
wenbert
Simply put: The four tables on top hold the form structure, not the filled in results. Each form_field row relates to a specific field in a specific form, so it relates to a form_id, has a column_id, display name, and type. A column_type would be one of number, string, date, etc. This is used to display a different field (and for validation).Results are saved in a different table, so each value in filled_form relates to a specific form and column.
OmerGertel