Data storage method, system and device supporting double-layer loop data and medium

By obtaining the double-layer loop data and its configuration tables, creating corresponding database tables and storing data, the problem of low efficiency in double-layer loop data storage and analysis is solved, and efficient data storage and analysis is achieved.

CN119988383APending Publication Date: 2025-05-13CRSC RESEARCH & DESIGN INSTITUTE GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510094951.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-21
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The prior art is difficult to effectively analyze and store double-layer cyclic data, resulting in unfixed fields for data search, interference, and low data import and analysis efficiency.

Method used

By obtaining the double-layer looping data to be stored and its configuration tables, creating corresponding database tables based on the configuration information, and storing the data into these tables, realizing reasonable storage and analysis of the data.

Benefits of technology

This enables the double-layer cyclic data to be reasonably stored in relational databases, improves the efficiency of data analysis, and reduces the time for data storage and query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988383A_ABST
    Figure CN119988383A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of data processing, and discloses a data storage method, system and device supporting double-layer loop data and a medium, and the method comprises the steps: obtaining to-be-stored double-layer loop data and a configuration table corresponding to the to-be-stored double-layer loop data, configuration information of fields in the to-be-stored double-layer loop data is described in the configuration table; creating a database table corresponding to the to-be-stored double-layer loop data according to the configuration information of the fields in the to-be-stored double-layer loop data; and storing the double-layer loop data to be stored into the database table. According to the technical scheme, the double-layer cyclic data can be reasonably stored in the relational database, so that related personnel can conveniently analyze the data, and the working efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data storage method, system, device and medium supporting double-layer circulation data. Background Art

[0002] With the development and growth of high-speed railway and highway networks, the user scale of related products has expanded rapidly, the data generated has exploded, and big data processing has risen to a national strategic task. In order to save data storage space and meet the characteristics of different products, when collecting data, the data is defined as cyclic data (some fields in the cyclic data are stored in a cyclic manner) and stored as text files by line.

[0003] When performing correlation analysis on cyclic data, the mainstream analysis method is to manually determine the problem location, which has the risk of subjective assumptions, is not comprehensive, and takes a relatively long time. It is difficult to determine the problem directly by maintaining data, which is not convenient for developers to analyze data. For example, import the stored double-layer cyclic data into Nodepad++, enter the search conditions, such as 00 0000ae for search, but the search cannot fix the field, so the searched data will have a lot of interference, and Nodepad++ will crash after importing multiple files for a long time, affecting work efficiency. Summary of the invention

[0004] To solve the above problems, the present invention provides a data storage method, system, device and medium that supports double-layer circulation data, so that the double-layer circulation data can be reasonably stored in a relational database, so that relevant personnel can analyze the data and improve work efficiency.

[0005] To achieve the above object, the present invention adopts the following technical solution:

[0006] In a first aspect, the present invention provides a data storage method supporting double-layer circulating data, comprising:

[0007] Obtaining the double-layer circulation data to be stored and a configuration table corresponding to the double-layer circulation data to be stored, wherein the configuration table describes configuration information of fields in the double-layer circulation data to be stored;

[0008] According to the configuration information of the fields in the double-layer circulation data to be stored, a database table corresponding to the double-layer circulation data to be stored is created;

[0009] The double-layer cycle data to be stored is stored in the database table.

[0010] Furthermore, the configuration table corresponding to the double-layer loop data to be stored includes a configuration main table and a configuration sub-table; the configuration main table describes the configuration information of the first-level fields in the double-layer loop data to be stored; the configuration sub-table describes the configuration information of the sub-content corresponding to the first-level fields in the double-layer loop data to be stored.

[0011] Furthermore, according to the configuration information of the fields in the double-layer circulation data to be stored, a database table corresponding to the double-layer circulation data to be stored is created, including:

[0012] According to the configuration information of the first-level field in the double-layer loop data to be stored described in the configuration master table, determine the table name and field of the database master table corresponding to the double-layer loop data to be stored;

[0013] According to the configuration information of the primary field corresponding to the secondary field in the double-layer loop data to be stored described in the configuration sub-table, determine the table name and field of the database sub-table corresponding to the double-layer loop data to be stored;

[0014] According to the determined table names and fields of the database main table and database sub-table corresponding to the double-layer circulation data to be stored, the database table corresponding to the double-layer circulation data to be stored is automatically created.

[0015] Further, according to the configuration information of the primary field in the double-layer loop data to be stored described in the configuration master table, the table name and field of the database master table corresponding to the double-layer loop data to be stored are determined, including:

[0016] Determine the table name of the database master table corresponding to the double-layer loop data to be stored according to the user name that executes the current database table creation operation;

[0017] According to the serial number attribute value corresponding to the primary field in the double-layer loop data to be stored described in the configuration master table, determine the name attribute value of the primary field corresponding to the field name of the database master table;

[0018] According to the type attribute value, length attribute value, and display form attribute value corresponding to the primary field in the double-layer loop data to be stored described in the configuration main table, determine the data type of the database main table field corresponding to the name attribute value of the primary field.

[0019] Further, according to the configuration information of the primary field corresponding to the secondary field in the double-layer loop data to be stored described in the configuration sub-table, the table name and field of the database sub-table corresponding to the double-layer loop data to be stored are determined, including:

[0020] Determine the table name of the database sub-table corresponding to the double-layer loop data to be stored according to the user name who performs the current database table creation operation and the serial number attribute value of the primary field;

[0021] According to the serial number attribute value corresponding to the primary field in the to-be-stored double-layer loop data described in the configuration main table and the serial number attribute value corresponding to the secondary field in the to-be-stored double-layer loop data described in the configuration sub-table, determine the field name of the database sub-table corresponding to the name attribute value of the secondary field;

[0022] According to the type attribute value, length attribute value, and display form attribute value corresponding to the secondary field in the double-layer loop data to be stored described in the configuration subtable, determine the data type of the database sub-table field corresponding to the name attribute value of the secondary field.

[0023] Furthermore, in the process of determining the fields of the database sub-table corresponding to the double-layer loop data to be stored, if the loop attribute value corresponding to the secondary field is 1, the table name and fields of the first-layer loop database sub-table corresponding to the secondary field are determined; if the loop attribute value corresponding to the secondary field is 1, and the sub-loop attribute is 1, the table name and fields of the second-layer loop database sub-table corresponding to the third-level field of the secondary field are determined.

[0024] Furthermore, according to the determined table names and fields of the database main table and database sub-table corresponding to the double-layer circulation data to be stored, a database table corresponding to the double-layer circulation data to be stored is automatically created, including:

[0025] According to the table names and fields of the database main table and the database sub-table corresponding to the determined double-layer loop data to be stored, construct and create nested dictionary data of the database main table and the database sub-table;

[0026] Traverse the nested field data and construct database instructions for creating the database main table and database sub-tables;

[0027] Execute database instructions to complete the automatic creation of database master tables and database sub-tables.

[0028] Furthermore, the double-layer cycle data to be stored is stored in a database table, including:

[0029] The double-layer loop data to be stored is read row by row, and the double-layer loop data to be stored is parsed, and the parsed first-level fields in the double-layer loop data to be stored are stored in the corresponding database main table; if the sub-content of the first-level field is 1, the parsed second-level fields are stored in a sub-table; if the loop attribute value of the second-level field is 0, the second-level field is stored in a common database sub-table; if the loop attribute value of the second-level field is 1, the second-level field is stored in a first-layer loop database sub-table; if the loop attribute value of the second-level field is 1, and the sub-loop attribute value is also 1, the third-level field corresponding to the second-level field is stored in a second-layer loop database sub-table.

[0030] Furthermore, the method further comprises:

[0031] According to the association relationship between the primary and foreign keys in the database table, a database instruction for querying the double-layer cycle data to be queried is constructed, and the query instruction is executed to obtain the double-layer cycle data to be queried.

[0032] In a second aspect, the present invention further provides a data storage system supporting double-layer circulating data, comprising:

[0033] An acquisition module, used to acquire the double-layer circulation data to be stored and a configuration table corresponding to the double-layer circulation data to be stored, wherein the configuration table describes configuration information of fields in the double-layer circulation data to be stored;

[0034] A creation module, used to create a database table corresponding to the double-layer circulation data to be stored according to the configuration information of the fields in the double-layer circulation data to be stored;

[0035] The storage module is used to store the double-layer cycle data to be stored in the database table.

[0036] Furthermore, the system also includes: a query module, which is used to construct a database instruction for querying the double-layer circular data to be queried according to the association relationship between the primary and foreign keys in the database table, and execute the query instruction to obtain the double-layer circular data to be queried.

[0037] In a third aspect, the present invention further provides an electronic device, comprising: a processor and a memory;

[0038] The processor is coupled to the memory;

[0039] The processor is used to read and execute the program or instructions stored in the memory, so that the device executes the method of the first aspect.

[0040] In a fourth aspect, the present invention further provides a computer-readable storage medium storing a computer program, which implements the method of the first aspect when executed by a processor.

[0041] The technical solution provided by the present invention has at least the following technical effects or advantages:

[0042] Based on the configuration information of the fields in the double-layer circulation data to be stored described in the configuration table corresponding to the double-layer circulation data to be stored, the data main table and the database sub-table of the relational database corresponding to the double-layer circulation data to be stored are determined, and the circulation data in the double-layer circulation data to be stored is processed by sub-table, and according to the table names and fields of the determined database main table and database sub-table corresponding to the double-layer circulation data to be stored, the database table corresponding to the double-layer circulation data to be stored is automatically created through code; the double-layer circulation data to be stored is parsed, and the parsed data sub-table is stored in the database main table and the sub-table. The present invention enables the double-layer circulation data to be reasonably stored in the relational database, so that relevant personnel can perform data analysis on the data and improve work efficiency.

[0043] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0045] Figure 1 A schematic flow chart of a data storage method supporting double-layer circulation data provided in an embodiment of the present invention;

[0046] Figure 2 A schematic diagram of a process for data storage and query supporting double-layer cyclic data provided in an embodiment of the present invention;

[0047] Figure 3 Schematic diagram of data types of double-layer cyclic data to be stored in an embodiment of the present invention;

[0048] Figure 4 It is a schematic diagram of the double-layer cycle data to be stored after parsing in an embodiment of the present invention;

[0049] Figure 5 A schematic diagram of a main table corresponding to the configuration of double-layer cyclic data to be stored in an embodiment of the present invention;

[0050] Figure 6 A schematic diagram of a database master table corresponding to a master table configured in an embodiment of the present invention;

[0051] Figure 7 It is a schematic diagram of the configuration sub-expression corresponding to the header (20B) of the double-layer cyclic data to be stored in the embodiment of the present invention;

[0052] Figure 8 It is a schematic diagram of a database sub-table corresponding to the configuration sub-table of the packet header (20B) in the double-layer cyclic data to be stored in an embodiment of the present invention;

[0053] Fig. 9 Schematic diagram of the corresponding configuration sub-area of ​​the system status area in the double-layer cyclic data to be stored in the embodiment of the present invention;

[0054] Fig.10 Schematic diagram of a database sub-table corresponding to a configuration sub-table in a system status area in double-layer circulation data to be stored in an embodiment of the present invention;

[0055] Fig.11 Schematic diagram of the corresponding configuration sub-expression of the system fault bit alarm in the double-layer circulation data to be stored in the embodiment of the present invention;

[0056] Fig.12 Schematic diagram of a database sub-table of a system fault position alarm corresponding configuration sub-table to be stored in double-layer circulation data in an embodiment of the present invention;

[0057] Fig.13 Schematic diagram of the corresponding configuration sub-area of ​​the internal channel state area in the double-layer circulation data to be stored in the embodiment of the present invention;

[0058] Fig.14 Schematic diagram of a database sub-table corresponding to the configuration sub-table of the internal channel state area in the double-layer circulation data to be stored in an embodiment of the present invention;

[0059] Fig.15 Schematic diagram of the corresponding configuration sub-area of ​​the external channel state area in the double-layer circulation data to be stored in the embodiment of the present invention;

[0060] Fig.16 Schematic diagram of a database sub-table of the number of channels configured in the configuration sub-table corresponding to the external channel status area in the double-layer circulation data to be stored in an embodiment of the present invention;

[0061] Fig.17 Schematic diagram of the database sub-table of the channel overall status-network port status in the configuration sub-table corresponding to the external channel status area in the double-layer circulation data to be stored in the embodiment of the present invention;

[0062] Fig.18 Schematic diagram of the database sub-table of the channel overall state-channel mode in the configuration sub-table corresponding to the external channel state area in the double-layer circulation data to be stored in the embodiment of the present invention;

[0063] Fig.19 It is a schematic diagram of a database sub-table of the number of connections in the configuration sub-table corresponding to the external channel status area in the double-layer circulation data to be stored in an embodiment of the present invention;

[0064] Fig. 20 Schematic diagram of a database sub-table of the connection status in the configuration sub-table corresponding to the external channel status area in the double-layer circulation data to be stored in an embodiment of the present invention;

[0065] Fig.21 It is a schematic diagram of a database sub-table of protocol registration in a configuration sub-table corresponding to an external channel state area in double-layer circulation data to be stored in an embodiment of the present invention;

[0066] Fig. 22 Schematic diagram of the database sub-table of the source IP in the configuration sub-table corresponding to the external channel status area in the double-layer circulation data to be stored in the embodiment of the present invention;

[0067] Fig.23 Schematic diagram of a database sub-table of a destination IP in a configuration sub-table corresponding to an external channel status area in double-layer cyclic data to be stored in an embodiment of the present invention;

[0068] Fig.24 Schematic diagram of a database sub-table of a source port in a configuration sub-table corresponding to an external channel state area in double-layer circulation data to be stored in an embodiment of the present invention;

[0069] Fig.25 Schematic diagram of a database sub-table of a destination port in a configuration sub-table corresponding to an external channel status area in double-layer cyclic data to be stored in an embodiment of the present invention;

[0070] Fig.26 Schematic diagram of the configuration sub-area corresponding to the alarm message area in the double-layer circulation data to be stored in the embodiment of the present invention;

[0071] Fig. 27 Schematic diagram of a database sub-table showing the number of alarm data packets in the configuration sub-table corresponding to the alarm message area in the double-layer cycle data to be stored in an embodiment of the present invention;

[0072] Fig.28 Schematic diagram of a database sub-table of a fault ID in a configuration sub-table corresponding to an alarm message area in double-layer cycle data to be stored in an embodiment of the present invention;

[0073] Fig.29 Schematic diagram of a database sub-table of fault sub-content 1 in a configuration sub-table corresponding to the alarm message area in the double-layer cycle data to be stored in an embodiment of the present invention;

[0074] Fig.30 Schematic diagram of a database sub-table of fault sub-content 2 in a configuration sub-table corresponding to the alarm message area in the double-layer cycle data to be stored in an embodiment of the present invention;

[0075] Fig.31 It is a schematic diagram of all databases corresponding to the configuration main table and configuration sub-tables in the embodiment of the present invention;

[0076] Fig.32 A schematic diagram of a code for generating a nested dictionary format according to a configuration table corresponding to double-layer loop data to be stored in an embodiment of the present invention;

[0077] Fig.33 A schematic diagram of a code for splitting a field and specifying a field length in an embodiment of the present invention;

[0078] Fig.34 A schematic diagram of a code for creating a database table through code in an embodiment of the present invention;

[0079] Fig.35It is a schematic diagram of a flow chart of storing the double-layer cycle data to be stored into a database table in an embodiment of the present invention;

[0080] Fig.36 This is a schematic diagram of the structure of a data storage system supporting double-layer circulating data in an embodiment of the present invention;

[0081] Fig.37 The present invention is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0082] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0083] Figure 1 Schematic diagram of a data storage method supporting double-layer circulation data provided in an embodiment of the present invention. Figure 2 A schematic diagram of a data storage and query process supporting double-layer loop data provided in an embodiment of the present invention is shown below. Figure 1 , 2 Describe the technical solution of the present invention:

[0084] S101, obtaining double-layer circulation data to be stored and a configuration table corresponding to the double-layer circulation data to be stored, wherein the configuration table describes configuration information of fields in the double-layer circulation data to be stored;

[0085] The characteristics of cyclic data include: some fields in the cyclic data are stored in a cyclic manner, the number of times the fields are cyclic is different, the fields in the cycle are different, the length is different, and the cycle can have two or more layers.

[0086] The double-layer loop data stored in rows collected during the operation of the product is obtained and determined as the double-layer loop data to be stored. The structure of each row of data in the data has the characteristics of a double-layer loop. Each row of data in the double-layer loop data includes multiple first-level field data. If there is at least one second-level field data in the first-level field data, the second-level field data is the first-layer loop data. If there is at least one third-level field data in the second-level field data, the third-level field data is the second-layer loop data. In order to facilitate the description of the technical solution, the first-level field data, the second-level field data, and the third-level field data can also be referred to as the first-level field, the second-level field, and the third-level field.

[0087] The configuration table corresponding to the double-layer circulation data to be stored is obtained, wherein the configuration table describes the configuration information of the fields in the double-layer circulation data to be stored. The configuration table includes a configuration main table and a configuration sub-table.

[0088] The configuration main table describes the configuration information of the first-level field in the double-layer loop data to be stored, including the main table header information and the main table entity information; the main table header information describes the configuration attributes of the first-level field, including the serial number, name, type, length, display form, sub-content, etc.; the serial number indicates the position of the first-level field in the configuration main table, arranged in order from small to large; the name indicates the name of the first-level field; the type indicates the original data type of the first-level field. When the value is 1, it indicates that the first-level field is a string type, and the value is 0, which indicates that the first-level field is a binary type; the length indicates the byte length of the first-level field data. When the value is -1, it indicates that the length of the first-level field data is uncertain, that is, it needs to be determined according to the specific actual data; the display form indicates the target data type of the first-level field data. When the value is 2, it indicates a decimal value type, when the value is 3 or 4, it indicates a binary value type, when the value is 0, it indicates a string type, and when the value is 1, it indicates an ASCII code type; the sub-content indicates whether there is a sub-content in the first-level field data, that is, whether there is a second-level field data in the first-level field data. When the value is 1, it indicates that there is a second-level field data. The main table entity information describes the attribute values ​​of the configuration attributes in the main table header information corresponding to all the first-level fields in the double-layer loop data to be stored, and each row of data describes the attribute value of the configuration attribute in the header information corresponding to a first-level field.

[0089] The configuration subtable describes the configuration information of the sub-content corresponding to the first-level field in the double-layer loop data to be stored, that is, the configuration information of the second-level field, including the sub-table header information and the sub-table entity information; the sub-table header information describes the configuration attributes of the second-level field, including the sequence number, name, type, length, display form, whether to loop, sub-loop, etc.; the sequence number, name, length, and display form have the same meaning as those in the configuration main table, that is, the sequence number indicates the position of the second-level field in the configuration subtable, arranged in order from small to large; the name indicates the name of the second-level field; the type indicates the original data type of the second-level field. When the value is 1, it indicates that the second-level field is a string type, and when the value is 0, it indicates that the second-level field is a binary type; the length indicates the data type of the second-level field. Byte length, when the value is -1, it means the length of the secondary field data is uncertain, that is, it needs to be determined according to the specific actual data; Display format indicates the data type of the secondary field data, when the value is 2, it means decimal value type, when the value is 3 or 4, it means binary value type, and when the value is 0, it means string type; Whether to loop indicates whether the secondary field data is the first-level loop data, when the value is 1, it means the secondary field data is loop data, that is, the secondary field corresponds to multiple data, when the value is 0, it means the secondary field data is non-loop data, that is, the secondary field corresponds to 1 data; Sub-loop indicates whether the secondary field has sub-content, when the value is 1, it means there is sub-content, and the sub-content is the third-level field data, also called the second-level loop data. The sub-table entity information describes the attribute values ​​of the configuration attributes in the header information corresponding to all the secondary fields corresponding to the first-level fields in the double-layer loop data to be stored, and each row of data describes the attribute value of the configuration attribute in the header information of the sub-table corresponding to a second-level field.

[0090] S102, creating a database table corresponding to the double-layer circulation data to be stored according to the configuration information of the fields in the double-layer circulation data to be stored;

[0091] The amount of double-layer loop data to be stored is uncertain, and the size of a row of data may be several KB to dozens of KB. If the data is stored in one table, it cannot be stored in one row when the amount of data is too large, and the storage speed is very slow. Only when the double-layer loop data to be stored is parsed, can we know how many times a certain loop data is looped, that is, only when the data is parsed can we know how many rows the loop data occupies, and the number of loops of each row of data and the same loop field of each row of data is uncertain, which is determined according to the currently parsed data. Therefore, the horizontal storage method is not suitable for loop data. Therefore, when creating a database table, it is necessary to create the corresponding data main table and data sub-table according to the configuration main table and configuration sub-table.

[0092] S1021. Determine the table name and field of the database master table corresponding to the double-layer loop data to be stored according to the configuration information of the first-level field in the double-layer loop data to be stored described in the configuration master table;

[0093] Read the configuration information of the first-level field in the double-layer loop data to be stored described in the configuration main table, and determine the table name of the database main table corresponding to the double-layer loop data to be stored according to the user name who performs the current database table creation operation. For example, use the user name as the prefix of the table name, user name_main.

[0094] According to the attribute values ​​corresponding to all primary fields in the to-be-stored double-layer loop data described in the main table entity information in the configuration main table, the fields of the database main table corresponding to the to-be-stored double-layer loop data are determined.

[0095] Since the name attribute value in the main table entity information indicates the name of a specific primary field in the loop data to be stored, the field of the database main table corresponding to the double-layer loop data to be stored corresponds to the name attribute value of the primary field.

[0096] According to the serial number attribute value corresponding to the name attribute value of the first-level field, determine the field name of the database master table corresponding to the name attribute value of the first-level field. The serial number attribute value is a numerical value arranged in ascending order. The corresponding field name in the database master table is determined as 0_serial number attribute value, such as 0_1, 0_2...0_N, where N is the maximum value of the serial number attribute value. If the name attribute value is "time", the field name in the database master table corresponding to the name attribute value of the first-level field is determined to be "time".

[0097] According to the type attribute value, length attribute value, and display form attribute value corresponding to the name attribute value of the first-level field, determine the data type of the database main table field corresponding to the name attribute value of the first-level field. If the display form attribute value is 2 (numeric data), the name attribute value of the first-level field corresponds to the data type of the database main table field, which is determined to be a numeric type, such as INT type; if the display form attribute value is 3 or 4 (binary data), the type attribute value is 0 (binary data), and the length attribute value is a specific byte length value, then the name attribute value of the first-level field corresponds to the data type of the database main table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value * 3 * 8; if the display form attribute value is 3 or 4 (binary data), the type attribute value is 1 (string data), and the length attribute value is a specific byte length value, then the name attribute value of the first-level field corresponds to the data type of the database main table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value * 3 * 8. The value of the attribute corresponds to the data type of the database main table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value * 8; if the display form attribute value is 0 or 1 (string data or ASCII code data), the type attribute value is 0 (binary data), and the length attribute value is a specific byte length value, then the name attribute value of the first-level field corresponds to the data type of the database main table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value * 3; if the display form attribute value is 0 or 1 (string data or ASCII code data), the type attribute value is 1 (string data), and the length attribute value is a specific byte length value, then the name attribute value of the first-level field corresponds to the data type of the database main table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value. If the length attribute value is -1, then the name attribute value of the first-level field corresponds to the data type of the database main table field, which is determined to be a variable-length text type, such as TEXT type.

[0098] After determining the fields of the database main table corresponding to the double-loop data to be stored based on the name attribute values ​​of all the first-level fields in the main table entity information, in order to facilitate retrieval and construction of the table relationship between the first-level fields and the second-level fields, determine the "id" field of the database main table as the primary key auto-increment INT type.

[0099] S1022. Determine the table name and field of the database sub-table corresponding to the double-layer loop data to be stored according to the configuration information of the primary field corresponding to the secondary field in the double-layer loop data to be stored described in the configuration sub-table.

[0100] In the process of determining the field of the database main table corresponding to the double-layer loop data to be stored according to the name attribute values ​​of all the first-level fields in the main table entity information, if the sub-content attribute value corresponding to the name attribute value of the first-level field is 1, it means that there is second-level field data in the first-level field data.

[0101] Read the configuration information of the first-level field corresponding to the second-level field in the two-layer loop data to be stored described in the configuration subtable, and determine the table name of the database sub-table corresponding to the two-layer loop data to be stored according to the user name who performs the current database table creation operation and the serial number attribute value of the first-level field in the main table entity information. For example: use the user name as the prefix of the table name, user name_0_serial number attribute value of the first-level field.

[0102] According to the attribute values ​​corresponding to all the secondary fields corresponding to the primary fields in the double-layer loop data to be stored described by the sub-table entity information in the configuration sub-table, the fields of the database sub-table corresponding to the double-layer loop data to be stored are determined.

[0103] Since the name attribute value in the sub-table entity information indicates the name of the specific secondary field corresponding to the primary field in the loop data to be stored, the field of the database sub-table corresponding to the double-layer loop data to be stored corresponds to the name attribute value of the secondary field.

[0104] According to the serial number attribute value of the primary field and the serial number attribute value corresponding to the name attribute value of the secondary field, determine the field name of the database sub-table corresponding to the name attribute value of the secondary field. The serial number attribute value corresponding to the name attribute value of the secondary field is a numerical value arranged in ascending order. The field name in the corresponding database sub-table is determined as 0_serial number attribute value of the primary field_serial number attribute value of the secondary field, such as 0_1_0, 0_1_2...0_1_M, where M is the maximum value of the serial number attribute value of the secondary field, and 1 is the serial number attribute value of the primary field.

[0105] According to the type attribute value, length attribute value, and display form attribute value corresponding to the name attribute value of the secondary field, determine the data type of the database sub-table field corresponding to the name attribute value of the secondary field. If the display form attribute value is 2 (numeric data), the name attribute value of the secondary field corresponds to the data type of the database sub-table field, which is determined to be a numeric type, such as the INT type; if the display form attribute value is 3 or 4 (binary data), the type attribute value is 0 (binary data), and the length attribute value is a specific byte length value, then the name attribute value of the secondary field corresponds to the data type of the database sub-table field, which is determined to be a character type, such as the VARCHAR type, and the length of the field is determined to be the length attribute value * 3 * 8; if the display form attribute value is 3 or 4 (binary data), the type attribute value is 1 (string data), and the length attribute value is a specific byte length value, then the name attribute value of the secondary field corresponds to the data type of the database sub-table field, which is determined to be a character type, such as the VARCHAR type, and the length of the field is determined to be the length attribute value * 3 * 8. The value of the attribute corresponds to the data type of the database sub-table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value * 8; if the display form attribute value is 0 or 1 (string data or ASCII code data), the type attribute value is 0 (binary data), and the length attribute value is a specific byte length value, then the name attribute value of the secondary field corresponds to the data type of the database sub-table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value * 3; if the display form attribute value is 0 or 1 (string data or ASCII code data), the type attribute value is 1 (string data), and the length attribute value is a specific byte length value, then the name attribute value of the secondary field corresponds to the data type of the database sub-table field, which is determined to be a character type, such as VARCHAR type, and the length of the field is determined to be the length attribute value. If the length attribute value is -1, then the name attribute value of the secondary field corresponds to the data type of the database sub-table field, which is determined to be a variable-length text type, such as TEXT type.

[0106] After determining the fields of the database sub-table corresponding to the double-layer loop data to be stored based on the name attribute values ​​of all secondary fields in the sub-table entity information, in order to facilitate retrieval and construction of the table relationship between the primary and secondary fields, determine that the "id" field of the database sub-table is the foreign key of the "id" field of the database main table.

[0107] In the process of determining the fields of the database sub-table corresponding to the double-layer circular data to be stored according to the name attribute values ​​of all secondary fields in the sub-table entity information, if the circular attribute value corresponding to the name attribute value of the secondary field is 1, it means that the secondary field can be circular, and the table name and field of the independent database sub-table corresponding to the secondary field are determined. At this time, the independent database sub-table can also be called a one-layer circular database sub-table. The table name is determined as user name_0_serial attribute value of the first-level field_serial attribute value of the second-level field. The table fields in the table include 3 fields. The "id" field in the one-layer circular database sub-table is determined as the primary key auto-increment INT type; the "main_id" field is determined as the foreign key of the "id" field of the database main table; the table field corresponding to the secondary field in the one-layer circular database sub-table is determined as 0_serial attribute value of the first-level field_serial attribute value of the second-level field_circulate. If the loop attribute value corresponding to the name attribute value of the secondary field is 1, and the child loop attribute value is 1, it means that the secondary field is loopable, and there is third-level field data in the secondary field data, and the third-level field is loopable. After determining the first-level loop database sub-table, determine the table name and field of the second-level loop database sub-table corresponding to the third-level field. The table name naming rule of the second-level loop database sub-table is the same as the table name naming rule of the first-level database sub-table. The table fields in the table include 4 fields. Determine the "id" field in the second-level loop database sub-table as the primary key auto-increment INT type; determine the "main_id" field as the foreign key of the "id" field of the database main table; determine "child_id" as the foreign key of the "id" field of the first-level loop database sub-table; the table field corresponding to the third-level field in the second-level loop database sub-table is 0_the serial number attribute value of the first-level field_the serial number attribute value of the second-level field_childCirculate. The "id" fields in multiple first-layer loop database sub-tables corresponding to the primary fields are one-to-one corresponding, that is, they are automatically incremented when data is stored; the "id" fields in multiple second-layer loop database sub-tables corresponding to the secondary fields are one-to-one corresponding, that is, they are automatically incremented when data is stored.

[0108] The above-mentioned database sub-tables include ordinary database sub-tables, first-level circular database sub-tables, and second-level circular database sub-tables, that is, when the circular value of the secondary field is 0, the corresponding database sub-table is an ordinary database sub-table; when the circular attribute value is 1, the corresponding database sub-table is a first-level circular database sub-table; when the circular attribute value is 1 and the sub-circular value is 1, the database sub-table corresponding to the third-level field is a second-level circular database sub-table.

[0109] S1023. Automatically create a database table corresponding to the double-layer circulation data to be stored according to the determined table names and fields of the database main table and database sub-table corresponding to the double-layer circulation data to be stored.

[0110] According to the table names and fields of the database main table and the database sub-table corresponding to the determined double-layer loop data to be stored, nested dictionary data for creating the database main table and the database sub-table are constructed; the nested dictionary data describes the specific data of the table names and fields of the database main table and the database sub-table corresponding to the determined double-layer loop data to be stored, traverses the nested field data, constructs a database instruction for creating the database main table and the database sub-table, executes the database instruction, and completes the automatic creation of the database main table and the database sub-table.

[0111] S103, storing the double-layer cycle data to be stored in the database table.

[0112] The double-layer loop data to be stored and the database table both satisfy the configuration information in the above-mentioned configuration table. According to the configuration information in the configuration main table, the double-layer loop data to be stored is read row by row, and the double-layer loop data to be stored is parsed. The parsed first-level field in the double-layer loop data to be stored is stored in the corresponding database main table. If the sub-content of the first-level field is 1, the second-level field corresponding to the first-level field is parsed according to the configuration information in the configuration sub-table, and the parsed second-level field is stored in a sub-table. If the loop attribute value of the second-level field is 0, the second-level field is stored in the ordinary database sub-table. If the loop attribute value of the second-level field is 1, the second-level field is stored in the first-layer loop database sub-table; if the loop attribute value of the second-level field is 1, and the sub-loop attribute value is also 1, the third-level field corresponding to the second-level field is stored in the second-layer loop database sub-table.

[0113] The double-layer cycle data to be stored can be the double data collected in real time that meets the configuration information in the above-mentioned configuration table, or it can be the double-layer cycle data collected in advance and stored in a text file by row. When the double-layer cycle data to be stored is stored in the database table, multiple pieces of real-time collected data can be stored continuously, or the double-layer cycle data in multiple text files can be stored continuously.

[0114] S104. Based on the association relationships among the primary key in the database main table, the primary key and foreign key of the common database sub-table, the primary key and foreign key of the first-layer loop database sub-table, and the foreign key of the second-layer loop database sub-table, a database instruction for querying the double-layer loop data to be queried is constructed, and the query instruction is executed to obtain the double-layer loop data to be queried.

[0115] The technical solution in the embodiments of the present invention has at least the following technical effects or advantages:

[0116] Based on the configuration information of the fields in the double-layer circulation data to be stored described in the configuration table corresponding to the double-layer circulation data to be stored, the data main table and the database sub-table of the relational database corresponding to the double-layer circulation data to be stored are determined, and the circulation data in the double-layer circulation data to be stored is processed by sub-table, and according to the table names and fields of the determined database main table and database sub-table corresponding to the double-layer circulation data to be stored, the database table corresponding to the double-layer circulation data to be stored is automatically created through code; the double-layer circulation data to be stored is parsed, and the parsed data sub-table is stored in the database main table and the sub-table. The present invention enables the double-layer circulation data to be reasonably stored in the relational database, so that relevant personnel can perform data analysis on the data and improve work efficiency.

[0117] The following takes the double-layer cycle data to be stored and stored by row collected during the operation of the product as an example to further illustrate the technical solution of the present invention:

[0118] Step 1: Obtain the double-layer circulation data to be stored and the configuration table corresponding to the double-layer circulation data to be stored, and design the database table according to the configuration information in the configuration table, that is, determine the table name and fields of the database table;

[0119] Get the double-layer cycle data to be stored, such as Figure 3 (a) Figure 3 (b) Figure 3 (c) Figure 4 It is a schematic diagram of the double-layer cycle data to be stored after parsing in an embodiment of the present invention.

[0120] The configuration table corresponding to the double-layer circulation data to be stored is obtained, and the configuration table describes the configuration information of the fields in the double-layer circulation data to be stored. The configuration table includes a configuration main table and a configuration sub-table.

[0121] According to the configuration information of the configuration master table, determine the table name and fields of the database master table. For example, Figure 5 A schematic diagram of a main table corresponding to the configuration of double-layer cyclic data to be stored in an embodiment of the present invention; Figure 6 A schematic diagram of a database master table corresponding to a master table configured in an embodiment of the present invention;

[0122] The name of the database main table is determined based on the user name that performs the current database table creation operation. That is, the user name is used as the prefix of the table name, and the table name is crscd_main.

[0123] According to the configuration information of the configuration master table, the fields of the database master table are determined. For example, Figure 6 The "id" field is the primary key auto-increment column of type INT; Figure 6 The "time" field corresponds to Figure 5 The row corresponding to sequence number 0 is named time, and the type is VARCHAR; Figure 6"0_1" corresponds to Figure 5 The row with the serial number 1 corresponding to the name of the packet header (20B) is Figure 5 When the length column value is -1, it means that the specific length is known only when it is dynamically parsed, and the length of each row of data parsed may be the same or different. However, the database table has been determined before the data is stored, which means that the type of data stored in each field and the maximum length of the data stored have been determined. Therefore, if the data stored in the database table from "0_1" to the last field are all strings, the field type is set to TEXT (if the data is of fixed length, it can be changed to VARCHAR type without calculation) type and variable length text type. If the data stored is all numbers, the display mode column value is 2, then the field type is set to INT. The database table name column is replaced with "0_" plus Figure 5 The numerical value corresponding to the ordinal column.

[0124] When the sub-content value in the configuration information of the configuration main table is 1, the table name and field of the database sub-table are determined according to the configuration information of the configuration sub-table. For example, for example:

[0125] Figure 7 It is a schematic diagram of the configuration sub-expression corresponding to the header (20B) of the double-layer cyclic data to be stored in the embodiment of the present invention; Figure 8 This is a schematic diagram of a database sub-table corresponding to the configuration sub-table of the packet header (20B) in the double-layer cyclic data to be stored in an embodiment of the present invention; Figure 8 The "id" field is the database main table Figure 6 The id foreign key of the database sub-table field name is "0_" plus the configuration main table Figure 5 The value 1 corresponding to the serial number column plus "_" plus the configuration subtable Figure 7 The numerical value corresponding to the ordinal column.

[0126] Fig. 9 Schematic diagram of the corresponding configuration sub-area of ​​the system status area in the double-layer cyclic data to be stored in the embodiment of the present invention; Fig.10 Schematic diagram of a database sub-table corresponding to the configuration sub-table of the system status area in the double-layer circulation data to be stored in an embodiment of the present invention; Fig.10 The "id" field is the database main table Figure 6 The id foreign key of the database sub-table field name is "0_" plus the configuration main table Figure 5 The value 2 corresponding to the serial number column plus "_" plus the configuration subtable Fig. 9 The numerical value corresponding to the ordinal column.

[0127] Fig.11 Schematic diagram of the corresponding configuration sub-expression of the system fault bit alarm in the double-layer circulation data to be stored in the embodiment of the present invention; Fig.12Schematic diagram of a database sub-table for configuring a corresponding sub-table of a system fault position alarm in double-layer circulation data to be stored in an embodiment of the present invention; Fig.12 The "id" field is the database main table Figure 6 The id foreign key of the database sub-table field name is "0_" plus the configuration main table Figure 5 The value 3 corresponding to the serial number column plus "_" plus the configuration subtable Fig.11 The numerical value corresponding to the ordinal column.

[0128] Fig.13 Schematic diagram of the corresponding configuration sub-area of ​​the internal channel state area in the double-layer circulation data to be stored in the embodiment of the present invention; Fig.14 Schematic diagram of a database sub-table corresponding to the configuration sub-table of the internal channel state area in the double-layer circulation data to be stored in an embodiment of the present invention; Fig.10 The "id" field is the database main table Figure 6 The id foreign key of the database sub-table field name is "0_" plus the configuration main table Figure 5 The value 4 corresponding to the serial number column plus "_" plus the configuration subtable Fig.13 The numerical value corresponding to the ordinal column.

[0129] Fig.15 Schematic diagram of the corresponding configuration sub-area of ​​the external channel state area in the double-layer circulation data to be stored in the embodiment of the present invention; Fig.16 Schematic diagram of a database sub-table of the number of channels configured in the configuration sub-table corresponding to the external channel status area in the double-layer circulation data to be stored in an embodiment of the present invention; Figure 17-Figure 19 A schematic diagram of a one-layer loop database sub-table showing whether the loop value is 1 and the sub-loop value is 0 in the configuration sub-table corresponding to the external channel status area in the double-layer loop data to be stored in an embodiment of the present invention; Figure 20-Figure 25 Schematic diagram of a two-layer loop database showing whether the loop value is 1 and the sub-loop value is 1 in the configuration sub-table corresponding to the external channel status area in the double-layer loop data to be stored in the embodiment of the present invention; wherein Fig.16 The "id" field is the database main table Figure 6 The id foreign key of the database sub-table field name is "0_" plus the configuration main table Figure 5 The value 6 corresponding to the serial number column plus "_" plus the configuration subtable Fig.15 The value corresponding to the serial number column. The table name of this database sub-table is crscd_0_6. Figure 20-Figure 25 The "main_id" field of each database table is the database main table Figure 6 The id foreign key; the "id" field is the primary key auto-increment column of INT type; Fig.15 If the value of the loop column is 0, it means that the row field does not loop. The non-looping fields are stored in the database sub-table. Fig.16 in the table; Fig.15The loop column value is 1, which means that the row field is looped. The looped field will generate a separate database table. If the loop column value is 1 and the value of the sub-loop column corresponding to the row is 0, then the database sub-table corresponding to the row data is determined to be a one-layer loop database sub-table. Fig.17 , Fig.18 , Fig.19 (When the value of the sub-loop column in the configuration sub-table is 1 and the value of the number of packages column is 1, the first-layer loop processing is equivalent to the value of the loop column being 1 and the value of the sub-loop column being 0). There are three fields in the first-layer loop database, namely "id", "main_id", and "0_", plus the configuration main table Figure 5 The value 6 corresponding to the serial number column plus "_" plus the configuration subtable Fig.15 Add "_circulate" to the value corresponding to the sequence number column; if the value of the whether-circulate column is 1, and the value of the sub-circulation column corresponding to the row is 1, then it is determined that the database sub-table corresponding to the row data is a two-layer circulation database sub-table, that is, Figure 20-Figure 25 The second-layer loop database table has four fields, namely "id", "main_id", "child_id", "0_" plus the configuration Figure 5 The value 6 corresponding to the serial number column plus "_" plus the configuration subtable Fig.15 The value corresponding to the serial number column is added with "_childCirculate", where "child_id" is a layer of circular database sub-table, i.e. Fig.17 , Fig.18 , Fig.19 The "id" value (one-level circular database table Fig.17 , Fig.18 , Fig.19 The "id" value is one-to-one, and the two-layer circular database is divided into tables Fig. 20 , Fig.21 , Fig. 22 , Fig.23 , Fig.24 , Fig.25 The "id" values ​​of are one-to-one).

[0130] Fig.26 Schematic diagram of the configuration sub-area corresponding to the alarm message area in the double-layer circulation data to be stored in the embodiment of the present invention; Fig. 27 Schematic diagram of a database sub-table indicating whether the cycle value is 0 in the configuration sub-table corresponding to the alarm message area in the double-layer cycle data to be stored in an embodiment of the present invention; Figure 28-Figure 30 This is a schematic diagram of a one-layer loop database sub-table showing whether the loop value is 1 and the sub-loop value is 0 in the configuration sub-table corresponding to the alarm message area in the double-layer loop data to be stored in the embodiment of the present invention; Fig. 27 The "id" field is the database main table Figure 6 The id foreign key of the database sub-table field name is "0_" plus the configuration main table Figure 5The value 8 corresponding to the serial number column plus "_" plus the configuration subtable Fig.26 The value corresponding to the serial number column. The table name of this database sub-table is crscd_0_8. Figure 28 to Figure 30 The "main_id" field of each database table is the database main table Figure 6 id foreign key; "id" field is primary key auto-increment column INT type; configure subtable Fig.26 If the value of the loop column is 0, it means that the row field does not loop. The non-looping fields exist in the database subtable. Fig. 27 in the table; Fig.26 If the loop column value is 1 and the value of the sub-loop loop column corresponding to the row is 0, then it is determined that the database sub-table corresponding to the row data is a one-layer loop database sub-table. Fig.28 , Fig.29 , Fig.30 The database table has three fields, namely "id", "main_id", "0_" plus the configuration main table Figure 5 The value 8 corresponding to the serial number column plus "_" plus Fig.26 Add "_circulate" to the value corresponding to the serial number column;

[0131] Fig.31 This is a schematic diagram of all databases corresponding to the configuration main table and configuration sub-table in the embodiment of the present invention; in summary, crscd is the user name, crscd_main is the configuration main table Figure 5 The corresponding database master table. Configure the master table Figure 5 If there is a sub-table (sub-content is 1), a separate database sub-table will be generated, such as configuring the main table Figure 5 If the name column corresponding to the sequence number column of 1 is the "Baotou" field, and the sub-content column value is 1, it means that "Baotou" has a sub-table, and the corresponding database sub-table is named as the user name plus "_0_" plus the value of the sequence number column corresponding to the "Baotou" field is 1, that is, "crscd_0_1", and the corresponding database sub-tables corresponding to the fields with the sub-content column value of 1 are named "crscd_0_2", "crscd_0_3", "crscd_0_4", "crscd_0_6", and "crscd_0_8". The database sub-table "crscd_0_6_1" is because there is cyclic data, that is, the main table is configured Figure 5 The value of the sequence number column is 6, the corresponding name column is the "external channel status area (indefinite length)" field, and the corresponding sub-content column value is 1. The sub-table is configured in the "external channel status area (indefinite length)" field. Fig.15 The value of the sequence number column is 1, and the value of the name column is "Channel Overall Status - Network Port Status". The value of the loop column is 1, thus generating a database sub-table named user name plus "_0_" plus the configuration main table corresponding to the "External Channel Status Area (Variable Length)" field. Figure 5 The value of the sequence number column is 6 plus "_" to configure the subtable Fig.15 The value of the sequence number column is 1, which is "crscd_0_6_1", and the corresponding configuration subtable Fig.15 The first-layer loop database sub-tables corresponding to the fields whose values ​​of other loop columns are 1 are named "crscd_0_6_2", "crscd_0_6_3", "crscd_0_6_4", "crscd_0_6_5", "crscd_0_6_6", "crscd_0_6_7", "crscd_0_6_8", "crscd_0_6_9", and "crscd_0_6_10"; similarly, because "crscd_0_8_1" has loop data, the value of the sequence number column of the configuration main table 5 is 1, and the corresponding sub-content column value of the field named "alarm message area" is 1 in the configuration sub-table corresponding to the "alarm message area" field. Fig.26 The value of the sequence number column is 1, and the name column is defined as "Fault ID". The value of the loop column is 1. Generate a layer of loop database sub-table, named "user name plus _0_" plus the configuration main table corresponding to the "alarm message area" field Figure 5 The serial number column value 8 plus "_" configures the subtable Fig.15 The value of the sequence number column is 1, which is "crscd_0_8_1", and the corresponding configuration subtable Fig.26 The first-layer cyclic database sub-tables corresponding to the fields whose values ​​of other non-cyclic columns are 1 are named "crscd_0_8_2" and "crscd_0_8_3".

[0132] Step 2: Automatically create a database table corresponding to the double-layer cycle data to be stored;

[0133] (1) The configuration table corresponding to the double-layer loop data to be stored is read into the system to generate data in a nested dictionary format (similar to the nested folder format), where the configuration sub-table is stored in the "children" field (similar to the fact that if the children folder is empty, there is no child data, and if the children folder is not empty, there are still file levels under the children folder). The key in the field corresponds to the configuration attribute of the configuration table header information, and the value in the dictionary corresponds to the attribute value of each row of the field in the configuration table entity information, such as Fig.32. Specific description of nested dictionary key values: the name value is the specific name of the given configuration table name column, the size length value is the specific data of the given configuration table length column, the id field unique number is the backend configuration string, the big_little_endian size end value is the specific data of the given configuration table size end column, the file_type file type value is the specific data of the given configuration table file type column, the circulate loop value is the specific data of the given configuration table whether to circulate the column, the child_circulate sub-circulation value is the specific data of the given configuration table sub-circulation column, the is_packets packet value is the specific data of the given configuration table whether to package the column, the bit value is the specific data of the given configuration table bit-by-bit column, the show whether to display the value is the specific data of the given configuration table whether to display the column, the offset offset value is the specific data of the given configuration table offset column, the param parameter value is the specific data of the given configuration table parameter column, the conn whether there is an association value is the specific data of the given configuration table whether there is an association column, and the children sub-content value is the specific data of the given configuration table sub-content column. ID number description: traverse from the non-header row of the main table, the main table is the first layer, numbered 0_main table traverses the row number from the non-header row, and numbering starts from 0. If a field in the main table has sub-content, the sub-content is numbered as the field number of the main table_sub-table traverses the row number from the non-header row, and numbering starts from 0. This can quickly locate the position of a field in the main table or sub-table, and quickly locate the position of a field in the database table. The fields stored in the database are also stored according to this number.

[0134] (2) Traverse the nested dictionary layer by layer according to the field. For the main table field, if the field is displayed in the form of 2, it means that the data is numeric, and the corresponding database table type is int; if the display form is 3 or 4 (binary data), if the file type is 0 binary data, the database table type is varchar type, and the length is the length given by the field * 3 * 8; if the display form is 3 or 4 (binary data), if the file type is 1 string type data, the database table type is varchar type, and the length is the length given by the field * 8; if the display form is 0 or 1 (string type is 0, ASCII code type is 1), if the file type is 0 binary data, the database table type is varchar type, and the length is the length given by the field * 3; if the display form is 0 or 1 (string type is 0, ASCII code type is 1), if the file type is 1 string data, the database table type is varchar type, and the length is the length given by the field * 3;

[0135] (3) Traverse the nested dictionary layer by layer according to the field. For example, if the sub-content of the main table field is 1 and there is a sub-table field, traverse the sub-table field. If the sub-table field is a normal field, that is, non-circular and sub-circular data, then the type and length of the database table of the field are determined according to the above (2) method. Then the table name of the database where the field exists is user name_the upper-level main table field id of the field (that is, the sub-table field id minus the last _ and the following data), and the fields of the database table are the auto-increment column id, main_id, and the field id. If the sub-table field is cyclic data, that is, whether it is cyclic is 1, then the table where the field exists in the database is user name_the field id, and the fields of the database table are the auto-increment column id, main_id, and the field id. circulate, where main_id is the foreign key of the auto-increment column in the username_main table, and the length of this field is determined according to the above method (2); if the sub-table field is sub-circular data, that is, the sub-circularity is 1, then the database table name of this field is username_the field id, and the fields of this database table are the auto-increment column id, main_id, child_id, the field id__childCirculate, where main_id is the foreign key of the auto-increment column in the main table, and child_id is the foreign key of the auto-increment column of the upper-level circular data table of this field. The length of this field is determined according to the above method 2; the auto-increment columns id, main_id, and child_id are all int types.

[0136] (4) Each user is assigned a user name. The system obtains the user name as the prefix of the user stored in the database table. If the database has a table name with the user name as the prefix before the data is stored, all data and database tables with the prefix are deleted. Before parsing the data each time, a new database table needs to be generated according to the input configuration table, that is, according to the above nested dictionary data, a database instruction for creating the database main table and the database sub-table is constructed, and the instruction is executed to automatically complete the creation of the database main table and the database sub-table.

[0137] Fig.33 (a) Fig.33 (b) Fig.33 (c) is a schematic diagram of a code for splitting fields and specifying field lengths in an embodiment of the present invention; Fig.34 This is a schematic diagram of code for creating a database table through code in an embodiment of the present invention.

[0138] Step 3: storing the double-layer cycle data to be stored in the database table;

[0139] The double-layer loop data to be stored and the database table both satisfy the configuration information in the above-mentioned configuration table. The double-layer loop data to be stored is read row by row. According to the configuration information in the configuration main table, the double-layer loop data to be stored is parsed, and the parsed first-level field in the double-layer loop data to be stored is stored in the corresponding database main table. If the sub-content of the first-level field is 1, the second-level field corresponding to the first-level field is parsed according to the configuration information in the configuration sub-table, and the parsed second-level field is stored in a sub-table. If the loop attribute value of the second-level field is 0, the second-level field is stored in the ordinary database sub-table. If the loop attribute value of the second-level field is 1, the second-level field is stored in the first-layer loop database sub-table; if the loop attribute value of the second-level field is 1, and the sub-loop attribute value is also 1, the third-level field corresponding to the second-level field is stored in the second-layer loop database sub-table. Fig.35 The figure is a flow chart of storing the double-layer cycle data to be stored into the database table in an embodiment of the present invention.

[0140] The double-layer cycle data to be stored can be the double data collected in real time that meets the configuration information in the above-mentioned configuration table, or it can be the double-layer cycle data collected in advance and stored in a text file by row. When the double-layer cycle data to be stored is stored in the database table, multiple pieces of real-time collected data can be stored continuously, or the double-layer cycle data in multiple text files can be stored continuously.

[0141] Step 4: Query the double-layer loop data from the database table.

[0142] The double-layer loop data stored in the database table is searched according to the "id" field given in the database main table "crscd_main" as the unique key, and the main table and sub-table joint query is performed according to the multi-table joint query method given by the database. For queries involving loop data, if the data to be searched is in a first-layer loop database sub-table, the query condition is that the "mian_id" field value of the first-layer loop database sub-table is equal to the "id" field value of the database main table, and the "id" values ​​between adjacent first-layer loop database sub-tables are equal. If the sub-table loop field contains a sub-loop field (that is, part of the data is in the second-layer loop database sub-table), the query condition is that the "child_id" field value in the second-layer loop database sub-table is equal to the "id" value of the field in the first-layer loop data sub-table, and the "id" values ​​between adjacent second-layer loop database sub-tables are equal.

[0143] Example 1: select crscd_main.time,crscd_0_6_1.0_6_1_circulate as

[0144] 0_6_1_circulate, crscd_0_6_2.0_6_2_circulate as 0_6_2_circulate from crscd_main join crscd_0_6_1 on crscd_main.id = crscd_0_6_1.main_id join crscd_0_6_2 on crscd_main.id = crscd_0_6_2.main_id and (crscd_0_6_2.id = crscd_0_6_1.id) order by crscd_main.id limit 20 offset 0。

[0145] Example 2: select crscd_main.time, crscd_0_6.0_6_0 as 0_6_0, crscd_0_6_4.0_6_4_childCirculate as 0_6_4_childCirculate, crscd_0_6_5.0_6_5_childCirculate as 0_6_5_childCirculate, crscd_0_6_6.0_6_6_childCirculate as 0_6_6_childCirculate from crscd_main join crscd_0_6 on crscd_main.id = crscd_0_6.id join crscd_0_6_4 on crscd_main.id =

[0146] crscd_0_6_5.main_id and (crscd_0_6_5.id = crscd_0_6_4.id) join crscd_0_6_6 on crscd_main.id = crscd_0_6_6.main_id and (crscd_0_6_6.id = crscd_0_6_5.id) order by crscd_main.id limit 20 offset 0。

[0147] Example 3: select count(*)as count from crscd_main join crscd_0_6_2on crscd_main.id=crscd_0_6_2.main_id join crscd_0_6_3on crscd_main.id=crscd_0_6_3.main_id and(crscd_0_6_3.id=crscd_0_6_2.id)join crscd_0_6_4on crscd_main.id=

[0148] crscd_0_6_4.main_id and (crscd_0_6_4.child_id=crscd_0_6_3.id) joincrscd_0_6_5 on crscd_main.id=crscd_0_6_5.main_id and (crscd_0_6_5.id=crscd_0_6_4.id).

[0149] Fig.36 This is a schematic diagram of the structure of a data storage system supporting double-layer circulating data provided in an embodiment of the present invention. As shown in the figure, the system includes:

[0150] An acquisition module, used to acquire the double-layer circulation data to be stored and a configuration table corresponding to the double-layer circulation data to be stored, wherein the configuration table describes configuration information of fields in the double-layer circulation data to be stored;

[0151] A creation module, used to create a database table corresponding to the double-layer circulation data to be stored according to the configuration information of the fields in the double-layer circulation data to be stored;

[0152] The storage module is used to store the double-layer cycle data to be stored in the database table.

[0153] Furthermore, the system also includes: a query module, which is used to construct a database instruction for querying the double-layer circular data to be queried according to the association relationship between the primary and foreign keys in the database table, and execute the query instruction to obtain the double-layer circular data to be queried.

[0154] It should be noted that, for the sake of convenience, Fig.36 For example, only the main modules of the data storage system structure supporting double-layer circulating data are shown. In practical applications, the system may also include modules or components not shown in the figure; the system is not limited to the above module structure, and may also be other module structures that implement the above method embodiments.

[0155] Fig.37This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. As shown in the figure, the electronic device includes: a processor and a memory;

[0156] The processor is used to read and execute programs and instructions stored in the memory, so that the electronic device executes the above method embodiment.

[0157] It should be noted that, for the sake of convenience, Fig.37 For example, only the main components of the electronic device are shown. In actual applications, the electronic device may also include components or assemblies not shown in the figure.

[0158] The present invention also provides a computer-readable storage medium storing a program or instruction. When a computer reads and executes the program or instruction, the computer executes the above method embodiment.

[0159] Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent substitutions for some of the technical features therein; and these modifications or substitutions do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data storage method supporting double-layer circulation data, characterized in that: include: Acquire the double-layer circulation data to be stored and a configuration table corresponding to the double-layer circulation data to be stored, wherein the configuration table describes configuration information of fields in the double-layer circulation data to be stored; Creating a database table corresponding to the double-layer circulation data to be stored according to the configuration information of the fields in the double-layer circulation data to be stored; The double-layer cycle data to be stored is stored in the database table.

2. The data storage method supporting double-layer circulation data according to claim 1, characterized in that: The configuration table corresponding to the double-layer circulation data to be stored includes a configuration main table and a configuration sub-table; the configuration main table in the configuration main table describes the configuration information of the primary field in the double-layer circulation data to be stored; the configuration sub-table describes the configuration information of the sub-content corresponding to the primary field in the double-layer circulation data to be stored.

3. The data storage method supporting double-layer circulation data according to claim 2, characterized in that: The step of creating a database table corresponding to the double-layer circulation data to be stored according to the configuration information of the fields in the double-layer circulation data to be stored comprises: According to the configuration information of the first-level field in the double-layer loop data to be stored described in the configuration master table, determine the table name and field of the database master table corresponding to the double-layer loop data to be stored; According to the configuration information of the primary field corresponding to the secondary field in the double-layer loop data to be stored described in the configuration sub-table, determine the table name and field of the database sub-table corresponding to the double-layer loop data to be stored; According to the determined table names and fields of the database main table and database sub-table corresponding to the double-layer circulation data to be stored, the database table corresponding to the double-layer circulation data to be stored is automatically created.

4. The data storage method supporting double-layer circulation data according to claim 3, characterized in that: The method of determining the table name and field of the database master table corresponding to the double-layer circulation data to be stored according to the configuration information of the primary field in the double-layer circulation data to be stored described in the configuration master table includes: Determine the table name of the database master table corresponding to the double-layer loop data to be stored according to the user name that executes the current database table creation operation; According to the serial number attribute value corresponding to the primary field in the double-layer loop data to be stored described in the configuration master table, determine the name attribute value of the primary field corresponding to the field name of the database master table; According to the type attribute value, length attribute value, and display form attribute value corresponding to the primary field in the double-layer loop data to be stored described in the configuration main table, determine the data type of the database main table field corresponding to the name attribute value of the primary field.

5. The data storage method supporting double-layer circulation data according to claim 3, characterized in that: The method of determining the table name and field of the database sub-table corresponding to the double-layer loop data to be stored according to the configuration information of the primary field corresponding to the secondary field in the double-layer loop data to be stored described in the configuration sub-table includes: Determine the table name of the database sub-table corresponding to the double-layer loop data to be stored according to the user name who performs the current database table creation operation and the serial number attribute value of the primary field; According to the serial number attribute value corresponding to the primary field in the to-be-stored double-layer loop data described in the configuration main table and the serial number attribute value corresponding to the secondary field in the to-be-stored double-layer loop data described in the configuration sub-table, determine the field name of the database sub-table corresponding to the name attribute value of the secondary field; According to the type attribute value, length attribute value, and display form attribute value corresponding to the secondary field in the double-layer loop data to be stored described in the configuration subtable, determine the data type of the database sub-table field corresponding to the name attribute value of the secondary field.

6. The data storage method supporting double-layer circulation data according to claim 5, characterized in that: In the process of determining the fields of the database sub-table corresponding to the double-layer loop data to be stored, if the loop attribute value corresponding to the secondary field is 1, then the table name and field of the first-layer loop database sub-table corresponding to the secondary field are determined; If the corresponding loop attribute value of the secondary field is 1, and the sub-loop attribute is 1, then the table name and field of the second-level loop database sub-table corresponding to the third-level field of the secondary field are determined.

7. The data storage method supporting double-layer circulation data according to claim 3, characterized in that: The method of automatically creating a database table corresponding to the double-layer circulation data to be stored according to the determined table names and fields of the database main table and the database sub-table corresponding to the double-layer circulation data to be stored comprises: According to the table names and fields of the database main table and the database sub-table corresponding to the determined double-layer loop data to be stored, construct and create nested dictionary data of the database main table and the database sub-table; Traverse the nested field data and construct database instructions for creating the database main table and database sub-tables; Execute database instructions to complete the automatic creation of database master tables and database sub-tables.

8. The data storage method supporting double-layer circulation data according to any one of claims 1 to 7, characterized in that: The storing the to-be-stored double-layer cycle data into the database table comprises: The double-layer loop data to be stored is read row by row, and the double-layer loop data to be stored is parsed, and the parsed first-level fields in the double-layer loop data to be stored are stored in the corresponding database main table; if the sub-content of the first-level field is 1, the parsed second-level fields are stored in a sub-table; if the loop attribute value of the second-level field is 0, the second-level field is stored in a common database sub-table; if the loop attribute value of the second-level field is 1, the second-level field is stored in a first-layer loop database sub-table; if the loop attribute value of the second-level field is 1, and the sub-loop attribute value is also 1, the third-level field corresponding to the second-level field is stored in a second-layer loop database sub-table.

9. The data storage method supporting double-layer circulation data according to any one of claims 1 to 7, characterized in that: The method further comprises: According to the association relationship between the primary and foreign keys in the database table, a database instruction for querying the double-layer cycle data to be queried is constructed, and the query instruction is executed to obtain the double-layer cycle data to be queried.

10. A data storage system supporting double-layer circulating data, characterized in that: include: An acquisition module, used for acquiring the double-layer circulation data to be stored and a configuration table corresponding to the double-layer circulation data to be stored, wherein the configuration table describes configuration information of fields in the double-layer circulation data to be stored; A creation module, used for creating a database table corresponding to the double-layer circulation data to be stored according to the configuration information of the fields in the double-layer circulation data to be stored; The storage module is used to store the double-layer cycle data to be stored in the database table.

11. The data storage system supporting double-layer circulating data according to claim 10, characterized in that: The system further comprises: a query module, which is used to construct a database instruction for querying the double-layer cycle data to be queried according to the association relationship between the primary and foreign keys in the database table, and execute the query instruction to obtain the double-layer cycle data to be queried.

12. An electronic device, characterized in that: include: Processor and memory; The processor is coupled to the memory; The processor is used to read and execute the program or instruction stored in the memory, so that the device executes the method according to any one of claims 1 to 9.

13. A computer-readable storage medium, characterized in that: A computer program is stored, and when the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.