Reputation: 2019
I am working on a form-generator, however , I was confused when attempting to create the database for it.
The requirement is divided into backend / frontend,
For backend, the admin can manage the form
frontend: can store the form value
The problem are:
1) For the * , For example, if the user select option A , then the option C is visible , otherwise , it is hidden , how can I store the relationship?
2) How can I store the value in this form ? If I put in one table / the value are possible to be varchar / float / integer / tinyint
Thanks for helping
Upvotes: 2
Views: 3114
Reputation: 13519
Possible Suggestion for Problem #1:
You might send the mapping (i.e. selection -> input_filed) from backend. Then after receiving the mapping from back end you can make your conditional form inputs ).
Suppose, from back end you send this:
IF I select A input filed F1 will appear.
If I select B input field F2 will appear.
For implementing this of course you must have this mapping in one of your tables in your database. Then the rest will be done in front end.
Possible Suggestion for Problem # 2:
Method 1 :
You may keep a table where it will act like a super class. That means all the possible types (varchar / float / integer / tinyint) should exist in your table.
Disadvantage : waste of space because for each entry in this table only one field will be filled up others will be left blank.
Method 2 :
You should not use MYSQL for this purpose. You may use any NoSQL database. Please have a look at this post. Go through this. I am sure you will get an idea. dynamic columns and data type in mysql
Method 3 : There are so many ways. These links might help.
How to design a database for User Defined Fields?
Good Day!!
Upvotes: 2