[thelist] Database Schema Suggestions

Kae Verens kverens at contactjuggling.org
Fri Nov 14 05:55:19 CST 2003


Burhan Khalid wrote:
>   However, I am also going to have a facility where the admin can choose 
> fields that are mandatory and some basic checks (email, name, zipcode, 
> etc.) but I don't know how I would store that information per field .. 
> or where I would store it.  I thought about creating another table with 
> possible validation types, and then doing the same comma-list in the 
> form table for validation (which would be in the same order as the 
> fields) but I have a feeling that there is a better way to do this.

what you need is three tables. one to describe the form generally (name, 
id), one to describe each field, and the last to hold the actual data.

For example:

t_form(
  id int auto_increment primary key,
  name text
)

t_form_fields(
  id int auto_increment primary key,
  formId int,
  name text,
  type int,
  mandatory tinyint default 0
)

t_form_data(
  formId int,
  formFieldsId int,
  contents text
)

that should take care of most forms.

Kae



More information about the thelist mailing list