Forms data structure
The Codebots Forms extension allows for users to create forms for data collection operations without developer input. This article will go over the data structure used to store the forms in the application.
Modeling a Form
When modeling a form on the Codebots Platform it will look like this:
When you create a model like this, the bot will create the following table structure in the database:
As can be shown by the diagram, there shall be 3 tables created for a Form entity:
MyForm: This is the table used to store the individual forms created by the user.
MyFormEntityFormVersion: This is the table used to store the versions of the forms a user has created. Every time a user makes a new form it will store it in a new version. The most important column in this table is
FormData, which stores the JSON that represents the questions on the form.
MyFormSubmission: This table is where the users responses to a form a stored. The most important field on this table is
SubmissionData, which is a JSON field that stores the answers corresponding to a questions in the version.
Customising Form Submissions
The fields on the
MyForm table can be customised by adding extra attributes onto the Form entity; these will not change the submission. If we want to change the submission, we can update our model to this:
This Form Submission entity will be used for storing the form submission data instead of the default one, and can be customised to have extra entities and relations just like any other entity. This can be especially handy for doing things like linking submissions to users.
Was this article helpful?