Query statement generation method and device, processor and electronic equipment

By generating business rules and general statement templates, the system automatically generates joint query statements for multiple data tables in the database, solving the problem of low efficiency in existing technologies and achieving efficient joint queries and improved development efficiency.

CN118939675APending Publication Date: 2024-11-12INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410755749.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

Existing technologies suffer from low efficiency when querying multiple tables in a database. Developers are required to repeatedly write multiple query files with the same framework but different content, resulting in excessive time consumption.

Method used

By generating business rules and general statement templates, it automatically generates join query statements for multiple data tables, avoiding the need to write repetitive code.

Benefits of technology

It improves the efficiency of performing joint queries on multiple data tables, saves development time, simplifies the operation process, and enhances development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939675A_ABST
    Figure CN118939675A_ABST
Patent Text Reader

Abstract

The invention discloses a query statement generation method and device, a processor and electronic equipment. The invention relates to the technical field of computers, and the method comprises the steps that a plurality of data tables in a target database are obtained, the target database comprises a data mapping layer and a data management layer, and mapping tables in the data mapping layer and the data tables in the target database have a one-to-one correspondence relationship; based on the business demand, generating a business rule for executing query operation on the plurality of data tables, the business rule comprising a construction rule of a general statement template for executing query operation on the plurality of data tables; and based on the business rule and the general statement template, generating a target query statement, and performing joint query on the plurality of data tables by using the target query statement to obtain a group of query results. Through the method and the device, the problem of relatively low efficiency in a process of querying a plurality of data tables in a database in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of financial technology, and specifically, to a method, device, processor and electronic device for generating a query statement. Background Art

[0002] During the software development process, various software requirements emerge one after another. For example, for Java projects, when accessing the database, it is usually necessary to query the database table based on the newly added fields, for example, to write and generate corresponding SQL (Structured Query Language) statements based on the newly added fields. This statement is used for the interaction between the data mapping layer and the data persistence layer in the database.

[0003] When the above requirements involve multiple data tables in the database, developers need to write multiple query files for obtaining query results from each data table according to project requirements. However, in fact, the query codes used to generate access between the data mapping layer and the data persistence layer are often similar. Therefore, developers need to repeatedly write multiple query files with the same framework but different contents, which consumes a lot of time and causes technical problems such as low efficiency in the process of querying multiple data tables in the database.

[0004] With respect to the problem of low efficiency in the process of querying multiple data tables in a database in the above-mentioned related technologies, no effective solution has been proposed yet. Summary of the invention

[0005] The main purpose of the present application is to provide a method, device, processor and electronic device for generating a query statement to solve the problem of low efficiency in the process of querying multiple data tables in a database in the related art.

[0006] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a method for generating a query statement is provided. The method comprises: obtaining multiple data tables in a target database, wherein the target database comprises a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is used to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is realized through multiple data tables; based on business requirements, generating business rules for performing query operations on multiple data tables, wherein the business rules include construction rules for a general statement template for performing query operations on multiple data tables; based on the business rules and the general statement template, generating a target query statement, wherein a group of query results are obtained by using the target query statement to perform a joint query on multiple data tables, and the group of query results include business data that needs to be obtained from the target database according to the instructions of the business requirements.

[0007] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a query statement generation device is provided. The device includes: an acquisition unit, which is used to acquire multiple data tables in a target database, wherein the target database includes a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is used to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is realized through multiple data tables; a first processing unit, which is used to generate business rules for performing query operations on multiple data tables based on business requirements, wherein the business rules include construction rules of a general statement template for performing query operations on multiple data tables; a second processing unit, which is used to generate a target query statement based on the business rules and the general statement template, wherein a group of query results are obtained by using the target query statement to perform a joint query on multiple data tables, and the group of query results includes business data that needs to be obtained from the target database according to the instructions of the business requirements.

[0008] Optionally, in the query statement generation device provided in the embodiment of the present application, the first processing unit includes: a first processing module, which generates business rules for performing query operations on multiple data tables based on N groups of fields that need to be operated on each data table in the multiple data tables, wherein the business requirements include processing operations performed on N groups of fields, and N is a positive integer greater than or equal to 1.

[0009] Optionally, in the query statement generation device provided in the embodiment of the present application, the above-mentioned first processing module includes: a first processing sub-module, used to generate an i-th independent query statement template for performing a query operation on the i-th data table in multiple data tables by performing the following processing on the i-th group of fields in N groups of fields, where i is a positive integer greater than or equal to 1 and less than or equal to N: determining the i-th group of operations to be performed on the i-th group of fields from a group of operation options; recombining each field in the i-th group of fields according to the i-th group of operations to obtain the combined i-th group of fields; and generating the i-th business rule for performing a query operation on the i-th data table in multiple data tables based on the combined i-th group of fields.

[0010] Optionally, in the query statement generation device provided in the embodiment of the present application, the above-mentioned second processing unit includes: a second processing module, which is used to generate a target statement template that allows joint query on multiple data tables based on business rules and general statement templates; and a third processing module, which is used to obtain a target query statement by configuring parameters of the target statement template.

[0011] Optionally, in the query statement generation device provided in the embodiment of the present application, the above-mentioned third processing module includes: an acquisition sub-module, used to obtain the data type of each field in the N groups of fields contained in multiple data tables; a second processing sub-module, used to parse the multiple data tables based on the data type of each field, to obtain M groups of fields that match the target statement template, where M is a positive integer greater than or equal to 1; a third processing sub-module, used to obtain the target query statement by configuring parameters for each group of fields in the M groups of fields.

[0012] Optionally, in the query statement generation device provided in the embodiment of the present application, the above-mentioned second processing module includes: a third processing sub-module, which is used to determine, from the general statement template, a first sub-group statement template having a mapping relationship with the first part of the sub-rules when the business rules include a group of sub-rules, wherein the group of sub-rules includes the first part of the sub-rules and the second part of the sub-rules; a fourth processing sub-module, which is used to obtain a second sub-group statement template having a mapping relationship with the second part of the sub-rules by modifying at least part of the statement template of the first sub-group statement template; and a fifth processing sub-module, which is used to generate a target statement template based on the first sub-group statement template and the second sub-group statement template.

[0013] Optionally, in the query statement generation device provided in the embodiment of the present application, the above-mentioned acquisition unit includes: a fourth processing module, used to determine the target database that needs to be accessed to meet business needs based on business needs; an acquisition module, used to obtain multiple data tables from the target database by configuring parameters of the target database.

[0014] Through the present application, business rules for performing query operations on multiple data tables are generated according to business needs, and general statement templates are generated according to the rules for generating general statement templates in the business rules, so that target query statements that can be used for joint queries on multiple data tables are generated based on the general statement templates, thereby avoiding the problem of developers spending too much time writing query statements for each data table separately, and achieving the technical effect of improving the efficiency of joint queries on multiple data tables. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0016] Figure 1 is a flowchart of a method for generating a query statement according to an embodiment of the present application;

[0017] Figure 2 This is an example of a method for generating a query statement according to an embodiment of the present application;

[0018] Figure 3 It is a comparative schematic diagram of the traditional solution and the technical solution of the present application;

[0019] Figure 4 is a schematic diagram of a query statement generation device provided according to an embodiment of the present application;

[0020] Figure 5 It is a schematic diagram of an event processing electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0021] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0024] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.

[0025] The present invention is described below in conjunction with preferred implementation steps. Figure 1is a flowchart of a method for generating a query statement according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:

[0026] Step S102, obtaining multiple data tables in the target database, wherein the target database includes a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is used to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is realized through multiple data tables;

[0027] Step S104, based on business requirements, generating business rules for executing query operations on multiple data tables, wherein the business rules include construction rules for a common statement template for executing query operations on multiple data tables;

[0028] Step S106, generating a target query statement based on business rules and general statement templates, wherein a set of query results is obtained by using the target query statement to perform a joint query on multiple data tables, and the set of query results includes business data that needs to be obtained from the target database according to the instructions of business needs.

[0029] Optionally, the query statement generation method provided in the embodiment of the present application can be, but is not limited to, a query code generation scenario for performing data interaction between a data mapping layer (mainly including entity classes) and a data persistence layer (which can also be understood as a data management layer) in a database during application system development, or can be applied to a code generation scenario for performing query operations on a database during the process of creating a new database, for example, generating SQL (Structured Query Language) statements.

[0030] Among them, SQL statements can also be called structured query language, which is a database query and programming language used to store data set queries, updates and relational database systems. It is also the extension of data script files.

[0031] In the process of performing corresponding operations on the database, it usually involves querying multiple data tables in the database. In this case, the traditional solution is to write corresponding code files for each data table, and then use different code files to query the corresponding single data table in turn. However, in fact, the query statements for interactive data between the data management layer and the data mapping layer in the database are usually similar, which means that developers need to repeatedly write multiple similar codes, which takes up a lot of time and managers and reduces development efficiency.

[0032] For example, if Figure 3As shown, suppose you want to generate a query statement for obtaining the height, weight and address of user 1. According to this requirement, there are a total of 3 data tables containing the height, weight and address of user 1. Among them, data table 1 includes the height of user 1, data table 2 includes the weight of user 1, and data table 3 includes the address of user 1.

[0033] If the traditional technical solution is adopted, it is necessary to write query code file 1 for data table 1, so as to separately obtain the user height in data table 1; then write query code file 2 for data table 2, so as to separately obtain the user weight in data table 2; finally, write query code file 3 for data table 3, so that the user can separately obtain the user address in the data table.

[0034] It can be seen from the above embodiments that the multiple data tables in the embodiments of the present application can be but are not limited to data tables that form a series relationship through one or more fields. For example, three data tables in a database are connected in series through the user ID of the above-mentioned user 1, or three data tables are connected in series through the user name and user ID of the above-mentioned user 1.

[0035] Obviously, the above-mentioned multiple data tables can be, but are not limited to, data tables in the same database.

[0036] And adopt the technical scheme in the embodiment of this application, such as Figure 2 As shown, based on business needs (for example, obtaining the height, weight and address of user 1), business rules for performing query operations on multiple data tables can be generated. For example, according to the fields that need to be operated on each data table, functions such as adding, deleting, modifying, and querying can be selected respectively, and corresponding business rules can be generated.

[0037] Among them, the above business rules include a general statement template for joint query of multiple data tables. For example, the template framework includes the name and user ID of user 1, and then includes a general query statement template. The general query statement template indicates that the personal information of user 1 needs to be obtained, and the personal information includes the height, weight and address of user 1, etc.

[0038] According to the above general statement template, a corresponding target query statement can be automatically generated, and the target query statement can be used to simultaneously execute a corresponding query operation on each data table in multiple data tables and obtain a set of query results.

[0039] In other words, when it is necessary to perform a joint table query on multiple data tables with a series relationship, the target query statement corresponding to the joint table query can be automatically generated based on the general statement template and business rules, avoiding the problem of developers repeatedly writing code and wasting too much time.

[0040] Through the embodiments provided by the present application, business rules for performing query operations on multiple data tables are generated according to business needs, and general statement templates are generated according to the rules for generating general statement templates in the business rules, so that target query statements that can be used for joint queries on multiple data tables are generated based on the general statement templates, thereby avoiding the problem of developers spending too much time writing query statements for each data table separately, and achieving the technical effect of improving the efficiency of joint queries on multiple data tables.

[0041] As an optional solution, the business rules for performing query operations on multiple data tables are generated based on business needs, including:

[0042] Based on N groups of fields that need to be operated on each of the multiple data tables, business rules for performing query operations on the multiple data tables are generated, wherein the business requirements include processing operations performed on the N groups of fields, and N is a positive integer greater than or equal to 1.

[0043] In an embodiment of the present application, the business rules customized according to project requirements include but are not limited to rules for file storage paths, file naming rules, and rules for constructing code generation templates (e.g., general statement templates).

[0044] Generate corresponding business rules based on a set of fields that need to be operated on each data table, for example, Figure 2 The user ID in the data table 1 shown is 000-01. The user age is queried and the user income is modified. Then the corresponding business rule 1 is generated. For another example, query Figure 2 The user height corresponding to name 2 in the data table 2 shown is modified, and the value of the user height is modified, then the corresponding business rule 2 is generated.

[0045] The rules of the code generation template (eg, the general statement template) are used to generate corresponding query statements, which are used to implement data interaction between the entity class in the data mapping layer and the data persistence layer through the corresponding Mapper interface.

[0046] It should be noted that there are multiple entity classes in the data mapping layer, and each entity class exists in the form of a mapping table. There is a one-to-one correspondence between each mapping table and the data table in the database. For example, mapping table 1 and data table 1 have fields with the same attributes (user name, weight, height, etc.), and the attribute value of each field remains consistent.

[0047] The entity class in the data mapping layer plays a very important role in the application. It is not only the basis of the data model, but also a bridge for data interaction between different data layers. By defining the entity class corresponding to the database table (referred to as the data table) structure, the data mapping layer ensures the consistency and integrity of the data within the application.

[0048] As an optional implementation, the business rules for performing query operations on multiple data tables are generated based on the N groups of fields that need to be operated on each data table in the multiple data tables, including:

[0049] By performing the following processing on the i-th group of fields in N groups of fields, an i-th independent query statement template for performing a query operation on the i-th data table in multiple data tables is generated, where i is a positive integer greater than or equal to 1 and less than or equal to N:

[0050] Determine an i-th group of operations to be performed on the i-th group of fields from a set of operation options;

[0051] Recombining each field in the i-th group of fields according to the i-th group operation to obtain the combined i-th group of fields;

[0052] Based on the combined i-th group of fields, an i-th business rule for executing a query operation on an i-th data table among the multiple data tables is generated.

[0053] For example, it is assumed that corresponding operations such as adding, deleting, modifying or querying are performed on fields such as user ID, name and age in data table 1 among multiple data tables.

[0054] Then combine the three fields of user ID, name and age to customize the corresponding business rules, such as file save path, file naming rules and code generation template rules.

[0055] For example, Figure 2 The user ID in the data table 1 shown is 000-01. The user age is queried and the user income is modified. Then the corresponding business rule 1 is generated. For another example, query Figure 2 The user height corresponding to name 2 in the data table 2 shown is modified, and the value of the user height is modified, then the corresponding business rule 2 is generated.

[0056] Obviously, the above method of generating corresponding business rules according to the combination of a group of fields in data table 1 is only an example and is not limited thereto. For example, a query operation can also be performed on two fields in data table 2 to generate corresponding business rules.

[0057] In the above manner, according to a group of fields in the data table to be operated, a query rule for generating a query code can be generated accordingly, thereby ensuring the accuracy of the operation processing on each data table in the joint table query process.

[0058] As an optional example, the target query statement is generated based on the business rules and the general statement template, including:

[0059] Based on business rules and common statement templates, generate target statement templates that allow joint queries to be performed on multiple data tables;

[0060] The target query statement is obtained by configuring the parameters of the target statement template.

[0061] The general statement template includes but is not limited to the basic framework of the query statement used in the process of performing a joint table query on multiple data tables with a serial relationship, for example, the basic information of the query object, specifically, Figure 2 The user ID, name, and personal information are shown, and then the personal information is defined to include different types of attribute information such as height, weight, age, and address.

[0062] The parameters in the target statement template are configured according to the fields on which query operations need to be performed on each of the multiple data tables. For example, the parameter value of field 1 (user height) of data table 1 in the target statement template is set to "modify", and the parameter value of field 2 (user address) in data table 1 is set to "query". Then, the target statement template can be used to generate the corresponding query code 1, and the query code 1 is used to modify the user height in data table 1 and query the user address in data table 1.

[0063] Similarly, by configuring parameters of a newly added field (user work location) in data table 2 in the target sentence template, a new column of attribute information about the user work location in data table 2 can be generated using the target sentence template.

[0064] It can be seen that by setting parameters for the target statement template, a target query statement that performs corresponding operations on each group of fields in each data table in multiple data tables can be directly generated, thereby improving the efficiency of joint query on multiple data tables.

[0065] As an optional implementation method, the target query statement is obtained by configuring parameters of the target statement template, including:

[0066] Get the data type of each field in N groups of fields contained in multiple data tables;

[0067] Based on the data type of each field, multiple data tables are parsed to obtain M groups of fields matching the target statement template, where M is a positive integer greater than or equal to 1;

[0068] By configuring parameters for each group of fields in the M groups of fields, a target query statement is obtained.

[0069] The M groups of fields in the target statement template may, but are not limited to, have a mapping relationship with the N groups of fields contained in multiple data tables. For example, the fields in the M groups of fields correspond one-to-one to the fields in the N groups of fields.

[0070] According to the data type of each field in the N groups of fields, multiple groups of fields with the same data type are matched from the target statement template, and then according to the attribute information of each field in the N groups of fields in multiple data tables (for example, the descriptive information represented by the field, used to describe the user's height or age), M groups of fields are determined from the multiple groups of fields.

[0071] Finally, according to the parameter value of each field in the N groups of fields in multiple data tables, parameters of each group of fields in the M groups of fields are configured to obtain the target query statement.

[0072] For example, assuming that the data types of N groups of fields include type 1 and type 2, multiple data tables are parsed according to type 1 and type 2, and the N groups of fields are parsed into M groups of fields in the target statement template, and the value of each parameter in the M group of fields is configured to be the same as the value of the response parameter in the N group of fields.

[0073] It should be noted that the above-mentioned process of automatically generating the target query statement can be implemented but not limited to through a code generation tool, and the code generation tool can also be integrated into the development tool as a plug-in. Specifically, when you right-click the project with the mouse, a parameter configuration window pops up, and configures the storage path of each generated code, the database user name, password, and data table selection, etc.

[0074] Run the plug-in corresponding to the code generation tool through the above process. For example, by right-clicking the above plug-in, obtain the data table structure, mainly obtain the data type of each field in the data table, and parse the multiple data table structures into the corresponding fields in the above target statement template (which can also be understood as the code generation template) according to the data type; finally, by configuring the parameters of the corresponding fields in the parsed target statement template, generate the code that can realize the data interaction between the data mapping layer (including multiple entity classes) and the data management layer (which can also be understood as the data persistence layer) of the target database through the Mapper interface.

[0075] Through the above method, the above code generation tool can be run in the form of a plug-in on the terminal display interface according to project requirements, and the parameters of each field in the code generation template can be configured through the relationship between the data table and the mapping table corresponding to multiple entity classes in the data mapping layer, so as to automatically generate query statements that meet the current project requirements, improve the efficiency of obtaining query statements, and save development time.

[0076] As an optional example, the target statement template that allows joint query on multiple data tables to be generated based on the business rules and the general statement template includes:

[0077] In the case where the business rule includes a group of sub-rules, determining a first sub-group statement template having a mapping relationship with the first part of the sub-rules from the general statement template, wherein the group of sub-rules includes the first part of the sub-rules and the second part of the sub-rules;

[0078] By modifying at least part of the statement templates of the first subgroup statement templates, a second subgroup statement template having a mapping relationship with the second part of the sub-rules is obtained;

[0079] A target sentence template is generated based on the first subgroup sentence template and the second subgroup sentence template.

[0080] For example, if Figure 2 As shown, it is assumed that the general statement template includes the following contents: (1) obtaining user personal information, where the user personal information includes age and address; (2) querying the user's age and updating the user's address, where data table 1 includes the user's age and data table 3 includes the user's address.

[0081] Then, according to the field to be operated in data table 1 and the first business sub-rule corresponding to the above business requirement: querying the user's age, the above general statement template is modified to obtain the first sub-group statement template for querying data table 1. Through the first sub-group statement template, data table 1 can be queried to obtain the user's age.

[0082] Similarly, according to the field to be operated in data table 3 and the second business sub-rule corresponding to the above business requirement: updating the user address, the above general statement template is modified to obtain a second sub-group statement template for updating the value corresponding to the user address field in data table 3. Through the second sub-group statement template, the column where the address field in data table 3 is located can be updated to obtain the updated user address.

[0083] By integrating the first subgroup statement template and the second subgroup statement template, a target statement template that can perform a joint table query on the data table 1 and the data table 3 is generated.

[0084] As an optional example, the above-mentioned acquisition of multiple data tables in the target database includes:

[0085] Based on business needs, determine the target database that needs to be accessed to meet business needs;

[0086] By configuring parameters of the target database, multiple data tables are obtained from the target database.

[0087] According to business requirements, a target database is determined from multiple databases and the target database is configured, for example, parameter configuration in the process of connecting to the target database and parameter configuration in the process of obtaining each data table in the target database.

[0088] Specifically, when the target database is determined, a set of fields is determined based on a set of keywords in the business requirements, and then multiple data tables containing the set of fields are selected from the target database, wherein each data table in the multiple data tables includes but is not limited to at least one field in the set of fields.

[0089] exist Figure 3 In the comparison diagram between the conventional technical solution and the present solution shown, it can be intuitively seen that the technical solution in the embodiment of the present application has at least the following beneficial effects:

[0090] (1) When performing joint table queries on multiple data tables in the database, developers can automatically generate corresponding codes according to project requirements, solving the problem of long development time caused by repeated code writing;

[0091] (2) By integrating the query statement generation tool into the development application in the form of a plug-in, the user operation process is simplified and the convenience of use is improved;

[0092] (3) Improved development efficiency and increased corporate profits.

[0093] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0094] The embodiment of the present application also provides a query statement generation device. It should be noted that the query statement generation device of the embodiment of the present application can be used to execute the query statement generation method provided in the embodiment of the present application. The query statement generation device provided in the embodiment of the present application is introduced below.

[0095] Figure 4 Schematic diagram of a query statement generation device according to an embodiment of the present application. Figure 4As shown, the device comprises:

[0096] An acquisition unit 402 is used to acquire multiple data tables in a target database, wherein the target database includes a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is used to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is realized through multiple data tables;

[0097] A first processing unit 404 is used to generate a business rule for performing a query operation on multiple data tables based on business requirements, wherein the business rule includes a construction rule of a common statement template for performing a query operation on multiple data tables;

[0098] The second processing unit 406 is used to generate a target query statement based on business rules and general statement templates, wherein a set of query results is obtained by using the target query statement to perform a joint query on multiple data tables, and the set of query results includes business data that needs to be obtained from the target database according to the instructions of business needs.

[0099] Optionally, in the query statement generation device provided in the embodiment of the present application, the first processing unit 404 includes:

[0100] The first processing module generates a business rule for performing a query operation on multiple data tables based on N groups of fields that need to be operated on each data table in the multiple data tables, wherein the business requirement includes processing operations performed on the N groups of fields, and N is a positive integer greater than or equal to 1.

[0101] Optionally, in the query statement generation device provided in the embodiment of the present application, the first processing module includes:

[0102] The first processing submodule is used to generate an i-th independent query statement template for performing a query operation on an i-th data table in multiple data tables by performing the following processing on an i-th group of fields in N groups of fields, where i is a positive integer greater than or equal to 1 and less than or equal to N:

[0103] Determine an i-th group of operations to be performed on the i-th group of fields from a set of operation options;

[0104] Recombining each field in the i-th group of fields according to the i-th group operation to obtain the combined i-th group of fields;

[0105] Based on the combined i-th group of fields, an i-th business rule for executing a query operation on an i-th data table among the multiple data tables is generated.

[0106] Optionally, in the query statement generation device provided in the embodiment of the present application, the second processing unit 406 includes:

[0107] The second processing module is used to generate a target statement template that allows joint query to be performed on multiple data tables based on business rules and common statement templates;

[0108] The third processing module is used to obtain a target query statement by configuring parameters of the target statement template.

[0109] Optionally, in the query statement generation device provided in the embodiment of the present application, the third processing module includes:

[0110] The acquisition submodule is used to acquire the data type of each field in N groups of fields contained in multiple data tables;

[0111] The second processing submodule is used to parse the multiple data tables based on the data type of each field to obtain M groups of fields matching the target sentence template, where M is a positive integer greater than or equal to 1;

[0112] The third processing submodule is used to obtain a target query statement by configuring parameters for each group of fields in the M groups of fields.

[0113] Optionally, in the query statement generation device provided in the embodiment of the present application, the second processing module includes:

[0114] A third processing submodule is used to determine, from the general statement template, a first subgroup statement template having a mapping relationship with the first part of the sub-rules when the business rule includes a group of sub-rules, wherein the group of sub-rules includes the first part of the sub-rules and the second part of the sub-rules;

[0115] A fourth processing submodule, configured to obtain a second subgroup of statement templates having a mapping relationship with the second part of the sub-rules by modifying at least part of the statement templates of the first subgroup of statement templates;

[0116] The fifth processing submodule is used to generate a target sentence template based on the first subgroup sentence template and the second subgroup sentence template.

[0117] Optionally, in the query statement generation device provided in the embodiment of the present application, the acquisition unit 402 includes:

[0118] A fourth processing module is used to determine, based on business requirements, a target database that needs to be accessed to meet the business requirements;

[0119] The acquisition module is used to acquire multiple data tables from the target database by configuring parameters of the target database.

[0120] By using the query statement generation device provided in the embodiment of the present application to generate business rules for performing query operations on multiple data tables according to business needs, and generating a general statement template according to the rules for generating general statement templates in the business rules, a target query statement that can be used for joint query of multiple data tables is generated based on the general statement template, thereby avoiding the problem of developers spending too much time writing query statements for each data table separately, and achieving the technical effect of improving the efficiency of joint query of multiple data tables.

[0121] The query statement generating device includes a processor and a memory. The acquisition unit, the first processing unit and the second processing unit are all stored in the memory as program units. The processor executes the program units stored in the memory to realize corresponding functions.

[0122] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set to generate target query statements based on business rules and general statement templates, thereby improving the efficiency of generating query statements.

[0123] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0124] An embodiment of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the method for generating the query statement is implemented.

[0125] An embodiment of the present invention provides a processor, which is used to run a program, wherein the method for generating the query statement is executed when the program is running.

[0126] like Figure 5 As shown, an embodiment of the present invention provides an electronic device, the device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor implements the following steps when executing the program:

[0127] Acquire multiple data tables in a target database, wherein the target database includes a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is used to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is realized through multiple data tables;

[0128] Based on business requirements, business rules for executing query operations on multiple data tables are generated, wherein the business rules include construction rules of a common statement template for executing query operations on multiple data tables;

[0129] Based on business rules and common statement templates, a target query statement is generated, wherein a set of query results is obtained by using the target query statement to perform a joint query on multiple data tables, and the set of query results includes business data that needs to be obtained from the target database according to the instructions of business needs.

[0130] The devices in this article can be servers, PCs, PADs, mobile phones, etc.

[0131] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing the following method steps:

[0132] Acquire multiple data tables in a target database, wherein the target database includes a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is used to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is realized through multiple data tables;

[0133] Based on business requirements, business rules for executing query operations on multiple data tables are generated, wherein the business rules include construction rules of a common statement template for executing query operations on multiple data tables;

[0134] Based on business rules and common statement templates, a target query statement is generated, wherein a set of query results is obtained by using the target query statement to perform a joint query on multiple data tables, and the set of query results includes business data that needs to be obtained from the target database according to the instructions of business needs.

[0135] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0136] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0139] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0140] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0141] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0142] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0143] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0144] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for generating a query statement, characterized in that: include: Acquire multiple data tables in a target database, wherein the target database includes a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is used to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is realized through the multiple data tables; Based on business requirements, generating business rules for executing query operations on the multiple data tables, wherein the business rules include construction rules of a common statement template for executing the query operations on the multiple data tables; Based on the business rules and the general statement template, a target query statement is generated, wherein a set of query results is obtained by using the target query statement to perform a joint query on the multiple data tables, and the set of query results includes business data that needs to be obtained from the target database according to the instructions of the business needs.

2. The method according to claim 1, characterized in that The generating, based on the business requirements, business rules for performing query operations on the multiple data tables includes: Based on N groups of fields that need to be operated on each of the multiple data tables, business rules for performing query operations on the multiple data tables are generated, wherein the business requirements include processing operations performed on the N groups of fields, and N is a positive integer greater than or equal to 1.

3. The method according to claim 2, characterized in that The generating of business rules for performing query operations on the multiple data tables based on the N groups of fields required to perform operations on each of the multiple data tables includes: An i-th independent query statement template for performing a query operation on an i-th data table in the multiple data tables is generated by performing the following processing on the i-th group of fields in the N groups of fields, where i is a positive integer greater than or equal to 1 and less than or equal to N: Determine an i-th group of operations to be performed on the i-th group of fields from a group of operation options; Recombining each field in the i-th group of fields according to the i-th group of operations to obtain a combined i-th group of fields; Based on the combined i-th group of fields, an i-th business rule for executing a query operation on an i-th data table among the multiple data tables is generated.

4. The method according to claim 1, characterized in that: The generating a target query statement based on the business rule and the general statement template includes: Based on the business rules and the general statement template, generating a target statement template that allows a joint query to be performed on the multiple data tables; The target query statement is obtained by configuring parameters of the target statement template.

5. The method according to claim 4, characterized in that The step of obtaining the target query statement by configuring parameters of the target statement template includes: Obtaining the data type of each field in the N groups of fields included in the multiple data tables; Based on the data type of each field, the multiple data tables are parsed to obtain M groups of fields matching the target sentence template, where M is a positive integer greater than or equal to 1; The target query statement is obtained by configuring parameters for each group of fields in the M groups of fields.

6. The method according to claim 4, characterized in that The generating, based on the business rule and the general statement template, a target statement template that allows a joint query to be performed on the multiple data tables comprises: In the case where the business rule includes a group of sub-rules, determining a first sub-group statement template having a mapping relationship with a first part of sub-rules from the general statement template, wherein the group of sub-rules includes the first part of sub-rules and the second part of sub-rules; By modifying at least part of the statement templates of the first subgroup of statement templates, a second subgroup of statement templates having a mapping relationship with the second part of sub-rules is obtained; The target sentence template is generated based on the first subgroup sentence template and the second subgroup sentence template.

7. The method according to any one of claims 1 to 6, characterized in that The step of obtaining multiple data tables in the target database includes: Based on the business requirement, determining the target database that needs to be accessed to meet the business requirement; The multiple data tables are obtained from the target database by configuring parameters of the target database.

8. A query statement generating device, characterized in that: include: an acquisition unit, configured to acquire a plurality of data tables in a target database, wherein the target database includes a data mapping layer and a data management layer, the mapping tables in the data mapping layer have a one-to-one correspondence with the data tables in the target database, the data management layer is configured to store business processing data in a preset format, and data interaction between the data mapping layer and the data management layer is implemented through the plurality of data tables; A first processing unit is used to generate a business rule for performing a query operation on the multiple data tables based on business requirements, wherein the business rule includes a construction rule of a common statement template for performing the query operation on the multiple data tables; The second processing unit is used to generate a target query statement based on the business rules and the general statement template, wherein a set of query results is obtained by using the target query statement to perform a joint query on the multiple data tables, and the set of query results includes business data that needs to be obtained from the target database according to the instructions of the business needs.

9. A processor, characterized in that: The processor is used to run a program, wherein the program executes the method according to any one of claims 1 to 7 when running.

10. An electronic device, characterized in that: The invention comprises one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of claims 1 to 7.