If you're building these dynamically on the front end.. probably the easiest option would be to use a json field or two, and stick to just a single table for form definitions, and another (if needed) for form submissions.
Forms DB structure / relations
I would appreciate some thoughts on how best to structure a frontend forms DB (using angular so building these dynamicically with custom directives). I'm sure others more experienced have done this so would appreciate some experience applied to this problem. My current thinking is 7 tables
-
forms (form types e.g. registration form) $table->increments('id'); $table->string('name',50);
-
form fields (text, email, etc) $table->increments('id'); $table->string('name',100); $table->string('label',50); $table->string('type',20); $table->string('placeholder',100);
-
form validation types (required, autocomplete, min, max, etc.) $table->increments('id'); $table->string('key',100);
-
form validation values (validation values e.g. max = 100) $table->increments('id'); $table->string(value,100);
-
form_form_field_pivot (pivot table ) form to field relationship. Multiple forms can have multiple fields e.g. register and subscribe both would have email field
-
form fields to form validation types pivot (pivot table ) form field fields to field validation types. e.g. text field to email, required , autocomplete, maxlength, etc?
-
form validation types _to form_form_field_pivot pivot (pivot table ) form field validation to field validation values. Multiple validations could have multiple values e.g. text for one field could be maxlength 30 and another text maxlength could be 100
QUESTIONS:
- does the structure make sense? can I simplify complex?
- I end up with 3 pivot tables how and struggling with the relationships and how I would get this into a single DB query
Please or to participate in this conversation.