Note that there are some explanatory texts on larger screens.

plurals
  1. POwhat's the best implemention of client creatable and modifiable web forms in a relational database?
    primarykey
    data
    text
    <p>In several web application projects I've been a part of, the client asks to be able to create their own forms. The question arises on how to store their form definitions, and then how to store user inputted values into those custom forms.</p> <p>I've seen it done two ways:</p> <ol> <li><p>Assuming that the client only defines how many fields, and what labels are associated with those fields; we can come to a solution involving four tables. <strong><code>FormDefinition</code></strong>, <strong><code>FormFieldDefinition</code></strong>, <strong><code>FormInstances</code></strong>, <strong><code>FormFieldValues</code></strong>. The client makes changes to <code>FormDefinition</code> and <code>FormFieldDefinition</code>, and the web app uses that information to render an HTML web form, on which the website visitor (end user) will submit the form, in which a new row in <code>FormInstances</code> is created and the values are saved in the <code>FormFieldValues</code> table.</p> <blockquote> <p>Rows in <strong><code>FormDefinition</code></strong> defines the form, i.e. <code>form definition ID = 2, form title = 'Car Registration Form'</code>. Rows in <strong><code>FormFieldDefinition</code></strong> defines fields of a form in <code>FormDefinition</code>, i.e. <code>field definition ID = 7, field label = 'Car Model', field type = 'varchar(50)'</code>. Rows in <strong><code>FormInstance</code></strong> is an instance of each form filled out by a user, i.e. <code>definition id = 2, date_entered = '2008-09-24'</code>. And rows in <strong><code>FormFieldValues</code></strong> are entries by the user, i.e. <code>field definition = 7, value = 'Tiburon'</code>.</p> </blockquote> <p>Unfortunately, it means the value column in <code>FormFieldValues</code> must be a char type of the largest possible size that your client might specify in a web form... and when form definitions change, managing old data becomes iffy. But user entries are queryable (i wrote a <a href="http://pastie.org/pastes/275090" rel="nofollow noreferrer">quick query</a> that lists user entries given a form id, which is similar to <a href="https://stackoverflow.com/questions/24470/sql-server-pivot-examples">another pivot question</a>).</p></li> <li><p>An alternative to using four tables would be to serialize the form definitions and user's form entries into XML (or YAML or something similar) and store that as text. The upside is that the forms are human readable in the database. The downside is that there will be more application overhead with parsing XML, and the database becomes much less queryable from an SQL standpoint.</p></li> </ol> <p>My real question is, what is this database model called? (So I can google this problem.) But I would settle on an answer to: which is the better implementation or are there better (or just as good) implementations out there?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload