Dynamic Design of Form fields-advantages of Data Storage Using Vertical tables (3)

Source: Internet
Author: User
In the previous section (1) (2), we analyzed the dynamic implementation of form fields. That is to say, the form field or each space displayed on the page is not an html Tag. It loops through the Retrieved Data and judges dynamically generated forms. The advantage of this design is that you can directly modify the table in the form field in the database to implement the form field displayed on the page.

In the previous section (1) (2), we analyzed the dynamic implementation of form fields. That is to say, the form field or each space displayed on the page is not an html Tag. It loops through the Retrieved Data and judges dynamically generated forms. The advantage of this design is that you can directly modify the table in the form field in the database to implement the form field displayed on the page.

In the previous section (1) (2), we analyzed the dynamic implementation of form fields. That is to say, the form field or each space displayed on the page is not an html Tag. It loops through the Retrieved Data and judges dynamically generated forms.

The advantage of this design is that you can directly modify the table in the form field in the database to modify the form field displayed on the page. How can we store data records after the dynamic form is submitted?

First, let's take a look at the source data table of the form field and the Form Format of the page form:

Data Table:

Page display:

Obviously, the form fields displayed on the page are from the previous data table. There are the following problems:

How should the data of these forms be stored when a form is submitted?

1. Design a table containing 28 fields in the form field? However, this dynamic form field is designed to enable the form to change with different requirements.

If the field in the form field is deleted, the effect is not too great. If the field in the form field is added or modified, the field will be lost when the form is submitted to the database, in severe cases, program running errors may occur.

2. Use the vertical table method:

The vertical table is used for analysis as follows: resume a table that stores the form value. For example:

The core fields of the Table value in this form are fied_id and value.

In this way, each form field and value are stored as a record in the database when the form is submitted. Each form submission actually inserts multiple records into the table, and these records constitute a piece of data submitted at a time.

That is to say, the traditional horizontal storage of data is transformed into vertical storage. This solves the problems that cannot be solved by the first solution. This makes the design completely dynamic.

When displaying data, you only need to convert the vertical table to horizontal Display Based on the Set primary key (implemented by SQL statements)

Simply put, vertical table Storage solves the problem that dynamic data is not limited by the number of fields in the horizontal table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.