Adding new columns to a table from an application is not recommended, since as your application grows (Scalability Theme), it will be very difficult to maintain that table.
However, there are techniques to mitigate this error, which I will offer you one of them.
The solution consists in making two tables, which in one stores the general information of the form and later the table of "metadata" stores the fields (Inputs) with the following characteristics:
- Form_ID: Indicates which form is
- Correlative: Incremental auto key increases
- Key: Unique identifier that recognizes the entry of a respective form
- Type: The type of the key (Integer, Boolean, Chains, among other more ...)
- Value: The value that corresponds to the key.
In case you want to delete or add a new field, you should follow the following steps:
-
Add : Just add a new row in the metadata table
-
Delete : You only have to delete the rows, starting with the brackets and Form_ID (Where Form_ID = {FORM_ID} AND key = {Key})
I'll attach an example:
Relationship entity diagram
Example
I hope I have helped you greetings.