I have a question on the data storing on MySql, what would be a better way of storing something like this:
I am trying to create an application where users can store different customizable form fields, e.g. if i need a contact form, i can create a form with From textfield, Subject dropdown field, Message textarea field, and likewise to have a different form with different form elements. And to addon to that, user can set name, and values or other form attributes to the fields.
However, what will be a better way to store this piece of information, such that it will be easy for retrieve to create a dynamic form for user to change the contents easily, as well as using them?
I could only think about 2 ways of storing them:
-
Within a table with schema like such id, form, element, name, value
element_id | form_id | element | name | value |
1 | 1 | textfield | to | null |
2 | 1 | selectbox | subject | general, support | -
As a field within a table, with datatype as BLOB, could be stored as serialize data
Kindly advise. Thanks.
Well, I myself prefer not to use serialized data in my designs. But it really depends on the things you will do with it.
I found this blog article describing the ups and downs, which may be helpful to your decision.