Data query method, device, equipment and medium
By automatically generating data query rules, the problem of low data query efficiency in the existing technology is solved, personalized data query is realized, and the audit efficiency of the power supply bureau is improved.
Patent Information
- Application Number
- CN202110327429.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-26
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-03-26
AI Technical Summary
The existing online audit module of the marketing system cannot meet personalized business needs, resulting in low data query efficiency. In addition, audit rules are not updated in a timely manner due to policy or business changes, which increases the query workload and reduces the audit efficiency of the power supply bureau.
By obtaining the target query formula input by the user, determine the query object and associated query conditions, search the data table association knowledge base to generate the data table association structure and joint query fields, automatically generate the target query rules to match the query result data, and realize personalized data Formulation of query rules.
It improves the efficiency of data query, meets personalized business needs, reduces the workload of data query, and improves the efficiency of the power supply bureau's audit work.
Smart Images

Figure CN112989171B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of database technology, and in particular to a data query method, device, equipment and medium. Background Art
[0002] With the continuous development of power grid construction, more and more application systems are included in the power grid, and the power distribution and utilization related data generated in the operation of various systems are also growing exponentially.
[0003] The power supply service center is a supervisory body for marketing business and service quality, responsible for auditing the business handling of the marketing system and on-site service. At present, the query of abnormal data in marketing archives mainly relies on the online audit module of the marketing system uniformly planned and developed by provincial companies. The audit rules involved may not meet the personalized business needs of certain regions, and the audit rules in the provincial marketing system may not be updated in time due to changes in power grid policies or business, resulting in too much abnormal data being queried, thereby increasing the workload of data query and reducing the audit efficiency of the power supply bureau. Therefore, how to formulate personalized data query rules and improve data query efficiency is an urgent problem to be solved. Summary of the invention
[0004] The embodiments of the present invention provide a data query method, device, equipment and medium to implement the formulation of personalized data query rules and improve data query efficiency.
[0005] In a first aspect, an embodiment of the present invention provides a data query method, including:
[0006] Acquire a target query formula input by a user, and determine at least one query object and associated query conditions in the target query formula;
[0007] Acquire at least one original query data table matching the query object, and search in a data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table;
[0008] Generate at least one data table association structure pair according to the search results, and query in a data table structure knowledge base to obtain joint query fields corresponding to each data table association structure pair;
[0009] According to each joint query field, a target query rule corresponding to the target query formula is generated, and query result data matching the target query rule is obtained through query.
[0010] In a second aspect, an embodiment of the present invention further provides a data query device, including:
[0011] A target query formula acquisition module, used to acquire a target query formula input by a user, and determine at least one query object and associated query conditions in the target query formula;
[0012] An associated data table determination module is used to obtain at least one original query data table matching the query object, and search in a data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table;
[0013] A joint query field determination module is used to generate at least one data table association structure pair according to the search results, and query the data table structure knowledge base to obtain the joint query fields corresponding to each data table association structure pair;
[0014] The target query rule generation and data query module is used to generate a target query rule corresponding to the target query formula according to each joint query field, and query to obtain query result data matching the target query rule.
[0015] In a third aspect, an embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the data query method as described in any embodiment of the present invention is implemented.
[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data query method as described in any embodiment of the present invention.
[0017] In the technical solution provided by the embodiment of the present invention, at least one query object and associated query conditions are determined in the target query formula input by the user, at least one original query data table matching the query object is obtained, and a data table association relationship knowledge base is searched to see whether there are associated data tables that meet the associated query conditions with each original query data table, and then at least one data table association structure pair is generated according to the search results, and in the data table structure knowledge base, a joint query field corresponding to each data table association structure pair is queried, and then a target query rule corresponding to the target query formula is generated according to each joint query field, and query result data matching therewith is queried, and the target query rule corresponding thereto is automatically generated through the target query formula input by the user, thereby realizing the formulation of personalized data query rules and improving data query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flowchart of a data query method in Embodiment 1 of the present invention;
[0019] Figure 2It is a flowchart of a data query method in Embodiment 2 of the present invention;
[0020] Figure 3 It is a structural schematic diagram of a data query device in Embodiment 3 of the present invention;
[0021] Figure 4 It is a schematic diagram of the hardware structure of a computer device in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0022] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0023] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the operations (or steps) as sequential processes, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0024] Embodiment 1
[0025] Figure 1 It is a flowchart of a data query method provided in the first embodiment of the present invention. The embodiment of the present invention can be applied to the situation where the table query fields are automatically determined and the query rules are generated according to the query formula input by the user. The method can be executed by the data query device provided in the embodiment of the present invention. The device can be implemented in software and / or hardware and can generally be integrated in a computer device.
[0026] like Figure 1 As shown, a data query method provided in this embodiment specifically includes:
[0027] S110: Acquire a target query formula input by a user, and determine at least one query object and associated query conditions in the target query formula.
[0028] Target query refers to the query conditions entered by the user.
[0029] The query object refers to the key field in the target query.
[0030] The associated query condition refers to the judgment relationship between the query object.
[0031] At least one query object and associated query condition are determined in the target query expression input by the user. For example, the target query expression input by the user may be "metering point greater than 10kW", where "metering point" is the query object and "greater than 10kW" is the associated query condition.
[0032] S120: Acquire at least one original query data table matching the query object, and search in a data table association relationship knowledge base whether there is an associated data table that satisfies an associated query condition with each original query data table.
[0033] The original query data table refers to the data table containing the query object. For example, when the user queries the data in the marketing business system of the external power grid, if the target query expression entered by the user is "the metering point is greater than 10kW", all data tables containing the key field of "metering point" (i.e., the query object) can be obtained in the marketing business system of the external power grid. When there is more than one original query data table matching the query object, all the original query data tables can be stored in a data list to obtain a list of original query data tables.
[0034] The data table association relationship knowledge base is used to record the set of relationships between one or more data tables and other data tables. The data table association relationship knowledge base corresponds one-to-one with the target business system (i.e., the system corresponding to the user when querying data, such as the marketing business system, material business system or financial system, etc.).
[0035] The associated query condition is used to determine the associated data table that has an associated relationship with the original query data table. In the embodiment of the present invention, the associated query condition may be whether there is an association feasibility between the original query data table and the associated data table.
[0036] An associated data table refers to a data table that satisfies the associated query conditions with the original query data table.
[0037] After obtaining the target query formula input by the user, at least one original query data table matching the query object can be obtained in the target business system corresponding to the query data, and a search can be conducted in the data table association relationship knowledge base corresponding to the target business system to determine whether there is an associated data table that satisfies the associated query conditions with each original query data table. If there is a data table that satisfies the associated query conditions, it will be used as an associated data table of the original query data table.
[0038] Considering that when the user queries data, he may only know the query field corresponding to the expected query result, but he is not clear about the association relationship between the data table corresponding to the query field and other data tables. That is to say, after the user enters the target query formula, he may not be able to directly query data according to the target query formula and obtain the query result matching the target query formula. For example, when the target query expression entered by the user is "the metering point is greater than 10kW", the program code corresponding to the metering point data table containing the key field of "metering point" cannot judge the size relationship of the metering point. That is to say, the user cannot obtain the query result matching the target query expression of "the metering point is greater than 10kW", but needs to query the dictionary table through the electricity price code in the electricity price code table to obtain the query result that meets "the metering point is greater than 10kW". Therefore, in an embodiment of the present invention, when at least one original query data table matching the query object is obtained, the data table association relationship knowledge base is searched to see whether there is an associated data table that meets the associated query condition with each original query data table, that is, when the metering point data table is obtained, the electricity price code table that meets the associated query condition can be searched in the data table association relationship knowledge base.
[0039] Optionally, before searching in the data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table, the method may further include: if there is an anomaly in the data in the original query data table, discarding the original query data table.
[0040] Before searching the associated data table, you can also judge the accuracy and completeness of the original data table. For example, when the data in an original query data table is lost, you can abandon the original query data table and then search to ensure the accuracy of the data query results and improve data query efficiency.
[0041] S130. Generate at least one data table association structure pair according to the search results, and query in a data table structure knowledge base to obtain joint query fields corresponding to each data table association structure pair.
[0042] A data table association structure pair refers to a data table set including an original query data table and associated data tables that meet the associated query conditions.
[0043] The data table structure knowledge base is used to record the collection of all data table structures. The data table structure knowledge base contains the field name, type, relationship with the primary key field (i.e., primary key), field width, and storage order in the data table, etc. The data table structure knowledge base corresponds to the target business system one by one.
[0044] The joint query field refers to the field corresponding to the data table association structure pair. Through the joint query field, you can query the associated data table that meets the associated query conditions with the original query data table, and determine the data table that can be associated with the original query data table.
[0045] At least one data table association structure pair is generated based on the associated data tables that meet the associated query conditions with each original query data table searched in the data table association relationship knowledge base, and the joint query fields corresponding to each data table association structure pair are queried in the data table structure knowledge base.
[0046] Exemplarily, by searching the data table association relationship knowledge base for associated data tables that meet the associated query conditions with the metering point table, at least one data table association structure pair including the metering point table and the electricity price code table can be generated, and the joint query fields corresponding to the data table association structure pair are queried in the data table structure knowledge base, and the obtained joint query fields are "region code" and "metering point electricity price", that is, the electricity price code table can be queried through the two fields of "region code" and "metering point electricity price" and the corresponding electricity price code can be obtained, thereby realizing that the associated data table that can be associated with the original query data table can be automatically determined according to the target query formula input by the user.
[0047] S140: Generate a target query rule corresponding to the target query formula according to each joint query field, and query to obtain query result data matching the target query rule.
[0048] The target query rule refers to a query rule generated based on the joint query field that corresponds to the target query formula and can obtain matching query result data.
[0049] Query result data refers to the data results obtained by querying the target query rules.
[0050] A target query rule corresponding to the target query formula is generated according to each joint query field, and the target query rule is used to query data to obtain query result data that satisfies the target query formula input by the user.
[0051] Optionally, generating a target query rule corresponding to the target query formula according to each joint query field may include: configuring the query order and connection mode of each joint query field according to each joint query field to generate the target query rule corresponding to the target query formula.
[0052] The query order of each joint query field is used to determine the order in which each joint query field in the generated target query rule is applied when querying data.
[0053] The connection mode of each joint query field is used to determine the connection mode of each joint query field in the generated target query rule. The connection mode may include at least AND, OR, NOT, CONTENT, Left Semi Join, and Left Anti Join.
[0054] It should be noted that when generating a target query rule corresponding to a target query formula, if there is a field specified by the user, the target query rule corresponding to the target query formula can be generated according to each joint query field and / or the user's specified field. Furthermore, the echo field of interest to the user can be configured according to each joint query field and / or the user's specified field, wherein the echo field is used to determine the feedback form of the query result data and to verify the accuracy of the target query rule.
[0055] As an optional implementation, after querying and obtaining query result data matching the target query rule, the method may further include: performing statistical analysis on the query result data, and operating and maintaining the data table structure knowledge base and the data table association relationship knowledge base.
[0056] Among them, when performing statistical analysis on the query result data, any analysis method such as list query or chart statistics can be used, and the embodiment of the present invention does not make specific limitations on this.
[0057] Knowledge base operation and maintenance refers to the improvement and updating of the data table structure knowledge base and the data table association relationship knowledge base to improve the accuracy of the data table structure knowledge base and the data table association relationship knowledge base.
[0058] After finding the query result data that matches the target query rules, the query results can be analyzed, providing a reference for users to understand and optimize the target query rules and query result data. The data table structure knowledge base and the data table relationship knowledge base can also be operated and maintained to ensure the consistency of the data table structure and the data table relationship, and to improve the accuracy of the generated target query rules.
[0059] The technical solution provided by the embodiment of the present invention determines at least one query object and associated query conditions in a target query formula input by a user, obtains at least one original query data table matching the query object, and searches a data table association relationship knowledge base to see whether there is an associated data table that satisfies the associated query conditions with each original query data table, then generates at least one data table association structure pair based on the search results, and in the data table structure knowledge base, queries to obtain joint query fields corresponding to each data table association structure pair, then generates a target query rule corresponding to the target query formula based on each joint query field, and queries to obtain query result data matching the target query formula, automatically generates a target query rule corresponding to the target query formula input by the user and capable of obtaining query data results, thereby realizing the formulation of personalized data query rules and improving data query efficiency.
[0060] Embodiment 2
[0061] Figure 2 This is a flow chart of a data query method provided by Embodiment 2 of the present invention. This embodiment is specific based on the above embodiment, wherein a search can be performed in a data table association relationship knowledge base to determine whether there is an associated data table that satisfies the associated query condition with each original query data table, specifically:
[0062] Obtain an original query data table in turn as the current processing data table;
[0063] In a data table association relationship knowledge base, obtaining candidate associated data tables that have a direct connection relationship with a currently processed data table and / or have at least one level of cascade relationship;
[0064] In the data table association relationship knowledge base, obtain the standard query conditions between each candidate association data table and the current processing data table;
[0065] Calculate the similarity between each standard query condition and the associated query condition, and obtain a candidate associated data table whose similarity calculation result meets the threshold value as the associated data table of the original query data table;
[0066] Return to execute the operation of obtaining one original query data table in turn as the current processing data table until the processing of all original query data tables is completed.
[0067] Furthermore, the query result data matching the target query rule may include:
[0068] According to the target query rule, a target query script corresponding to the target query rule is generated by using a pre-created script generation template;
[0069] Execute the target query script to obtain the query result data that matches the target query rules.
[0070] like Figure 2 As shown, a data query method provided in this embodiment specifically includes:
[0071] S210: Acquire a target query formula input by a user, and determine at least one query object and associated query conditions in the target query formula.
[0072] S220: Acquire at least one original query data table matching the query object.
[0073] S230, sequentially obtaining an original query data table as a current processing data table.
[0074] The currently processed data table refers to the original query data table that currently needs to determine the feasibility of the association between tables and the accuracy of the data table.
[0075] S240: Acquire, from a data table association relationship knowledge base, candidate associated data tables that have a direct connection relationship with the currently processed data table and / or have at least one level of cascade relationship.
[0076] A direct connection relationship means that the currently processed data table has a relationship that can be directly connected to the alternative associated data table based on the fields that indicate that the data tables are allowed to be connected.
[0077] A cascade relationship refers to a relationship in which the current processing data table needs to be connected to the candidate associated data table through an intermediate data table. For example, the data table connection relationship corresponding to the first-level cascade relationship is "current processing data table-intermediate data table 1-alternative associated data table", and the data table connection relationship corresponding to the second-level cascade relationship is "current processing data table-intermediate data table 1-intermediate data table 2-alternative associated data table", etc. In an embodiment of the present invention, in order to improve data query efficiency, the maximum number of cascade relationship levels allowed for the alternative associated data table can be pre-set, for example, it can be a second-level cascade relationship, that is, the current processing data table can be connected to the candidate associated data table through at most two intermediate tables.
[0078] The candidate associated data tables refer to all data tables in the data table association relationship knowledge base that have a mapping relationship with the currently processed data table. The candidate associated data tables may be one or more.
[0079] According to the data table association relationship knowledge base, an alternative associated data table having a direct connection relationship with the currently processed data table and / or having at least one level of cascade relationship is determined.
[0080] It should be pointed out that in the data table association relationship knowledge base, if it is impossible to obtain an alternative associated data table that has a direct connection with the currently processed data table and has at least one level of cascading relationship, then feedback that the currently processed data table cannot be connected can be displayed in the display interface of the system front end to prompt the user that data query operations cannot be performed based on the currently processed data table.
[0081] S250: In a data table association relationship knowledge base, obtain standard query conditions between each candidate associated data table and the currently processed data table.
[0082] The standard query condition is used to determine the association relationship between each candidate associated data table and the currently processed data table.
[0083] S260: Calculate the similarity between each standard query condition and the associated query condition, and obtain a candidate associated data table whose similarity calculation result meets a threshold value as the associated data table of the original query data table.
[0084] Similarity calculation is used to determine the similarity between each standard query condition and the associated query condition.
[0085] The similarity calculation result refers to the result obtained after similarity calculation is performed on each standard query condition and the associated query condition.
[0086] The threshold value refers to a standard value used to measure the similarity result. When the similarity calculation result corresponding to a candidate associated data table meets the threshold value, the candidate associated data table can be used as the associated data table of the original query data table.
[0087] It should be pointed out that when calculating the similarity between each standard query condition and the associated query condition, it can be determined based on the mapping relationship between the pre-set type of the associated query condition and each standard query condition, or any similarity calculation method in the prior art can be used to calculate the similarity of the query conditions. The embodiment of the present invention does not make specific limitations on this.
[0088] Taking into account that the currently processed data table may have a direct relationship and / or at least one level of cascade relationship with multiple alternative associated data tables, different alternative associated data tables may correspond to different standard query conditions. In order to determine the associated data table related to the associated query condition in the target query formula input by the user, the similarity between each standard query condition and the associated query condition can be calculated, and the associated data table of the original query data table can be determined based on the relationship between the similarity calculation result and the threshold value.
[0089] S270, determine whether the processing of all original query data tables is completed, if not, return to execute S230, if so, execute S280.
[0090] If the processing of all the original query data tables has been completed, a data table association structure pair is generated based on the search results, and the joint query field is determined; if the processing of all the original query data tables has not been completed, you can return to execute the operation of obtaining one original query data table in turn as the current processing data table until the processing of all the original query data tables is completed.
[0091] S280: Generate at least one data table association structure pair according to the search results, and query in a data table structure knowledge base to obtain joint query fields corresponding to each data table association structure pair.
[0092] When auditing the business handling and on-site service of the marketing system, the main purpose is to discover business problems, process problems or procedural problems in the system. In the context of complex business and multi-system linkage, it is usually impossible to confirm whether the structure of each data table and the data in the data table are reasonable and accurate. However, the key fields in some key data tables can be used as the benchmark for data accuracy and consistency verification. For example, suppose that when a data table needs to obtain user information, it must be connected with the "user number" field in the electricity customer table (that is, the associated data table), where the "user number" field is the key field, but not all data tables include the "user number" field. Therefore, it is necessary to determine the corresponding fields (that is, joint query fields) of non-same-name fields in each original query data table when the data table is allowed to be directly connected to the electricity customer table based on the data table association relationship knowledge base and the data table structure knowledge base. If there is no field that allows direct connection to the data table, when obtaining user information, the data table can be connected through the intermediate table, so as to ensure that the generated target query rule can include the key field "user number" and ensure the accuracy of the generated target query rule.
[0093] S290: Generate a target query rule corresponding to the target query formula according to each joint query field.
[0094] S2100: Generate a target query script corresponding to the target query rule by using a pre-created script generation template according to the target query rule.
[0095] A script generation template is used to generate a script file corresponding to the target query rule. Considering that the big data technology system of Hadoop (a distributed system infrastructure), Hive (a data warehouse tool based on Hadoop) and Spark (a big data processing computing engine) is generally used in the power grid big data platform, therefore, in an embodiment of the present invention, the pre-created script generation template can be a pre-created Velocity (a Java-based template engine) template based on the Spark computing framework and Spark SQL (a module for processing structured data in the Spark computing framework) running on Yarn (a resource manager for distributed clusters). The script generation template can be operated and maintained online, and while decoupling, it can also ensure that the workload of the operation and maintenance personnel is reduced when the script generation template is modified.
[0096] The target query script refers to the executable program code corresponding to the target query rule. The script can be deployed using the Spark OnYarn submission method.
[0097] The target query script is customized using the pre-created script generation template to generate a target query script corresponding to the target query rule, ensuring that the target query script corresponding to the target query rule can be executed normally in the big data platform and the expected query result data can be obtained.
[0098] It should be pointed out that when generating a target query script corresponding to a target query rule, the version of the target query script can be specified, and the version of the specified target query script can be enabled or disabled according to the actual deployment status of the big data platform. A target query script corresponding to a target query rule can correspond to multiple versions, and the actual execution of the target query script corresponding to the version deployed by the big data platform can be based on the version. For example, when querying data, only the latest version of the target query script is used for data query, and other historical versions are only used for backup of the target query script, so that users can compare and analyze the target query rules corresponding to each version of the target query script.
[0099] Optionally, using a pre-created script generation template to generate a target query script corresponding to the target query rule may include: determining a target linked table path corresponding to the target query rule based on a data table association relationship knowledge base, and generating a target linked table statement; using a pre-created script generation template to generate a target query script corresponding to the target query rule based on the target query rule and the target linked table statement.
[0100] The target joint table path refers to the joint table method between all data tables involved in the target query rule.
[0101] The target table join statement refers to a table lookup statement corresponding to the target query rule obtained by connecting all the data tables involved in the target query rule through syntax.
[0102] Different join table methods may cause certain deviations in the final data query results. Therefore, based on the data table association relationship knowledge base, the most accurate and efficient target join table path corresponding to the target query rule can be determined, and a target join table statement can be generated. Then, a pre-created script generation template is used to generate a target query script corresponding to the target query rule according to the target query rule and the target join table statement, thereby improving the accuracy of the generated target query script and the accuracy of the query result data obtained by the query.
[0103] It should be pointed out that when determining the target joint table path according to the joint query field in the target query rule, if there are multiple data tables with the same joint query field, it is necessary to ensure that the selected data table should be the core data table (i.e., the associated data table), and select the fields in sequence according to the priority in the data table association relationship knowledge base, and use the pre-created script generation template to generate the target query script corresponding to the target query rule. If the target joint table path is determined according to the query field specified by the user and the source of the joint table field, it is not necessary to select the field according to the priority in the data table association relationship knowledge base, and force the user's specified fields and joint table fields to use the pre-created script generation template to generate the target query script corresponding to the target query rule.
[0104] S2110. Execute the target query script to obtain query result data matching the target query rule.
[0105] After generating the target query script corresponding to the target query rule, the target query script can be automatically uploaded to the big data platform, executed to query the data, and obtain the query result data that matches the target query rule, that is, the data that satisfies the target query formula input by the user.
[0106] Optionally, executing the target query script to query and obtain query result data matching the target query rules may include: executing the target query script according to a pre-configured timer corresponding to the target query script to query and obtain query result data matching the target query rules.
[0107] The timer is used to determine the execution time of the target query script and the push time of the query result data.
[0108] According to a pre-configured timer, a shell command can be automatically generated and the target query script can be executed. Data query can be performed according to the target query rule corresponding to the target query script, and the obtained query result data can be pushed to a specified location according to the push time of the query result data pre-configured in the timer. For example, it can be pushed to a target query rule result set for storing the query result data corresponding to the target query rule.
[0109] For details not explained in this embodiment, please refer to the aforementioned embodiments and will not be repeated here.
[0110] The above technical scheme sequentially obtains an original query data table as the current processing data table, obtains an alternative associated data table in the data table association relationship knowledge base, obtains the standard query condition in the data table association relationship knowledge base, and then determines the associated data table of the original query data table according to the similarity between each standard query condition and the associated query condition, and generates a target query rule corresponding to the target query formula according to each joint query field, and then generates a target query script according to the target query rule using a pre-created script generation template, and automatically generates the corresponding target query rule according to the target query formula input by the user, thereby realizing the formulation of personalized data query rules and improving data query efficiency. At the same time, the script generation template is used to generate the target query script, which reduces the system development cycle and reduces the technical requirements for users.
[0111] Embodiment 3
[0112] Figure 3 It is a structural diagram of a data query device provided in Example 3 of the present invention. The embodiment of the present invention can be applied to the situation where table query fields are automatically determined and query rules are generated according to the query formula input by the user. The device can be implemented in software and / or hardware and can generally be integrated in a computer device.
[0113] like Figure 3 As shown, the data query device specifically includes: a target query formula acquisition module 310, a related data table determination module 320, a joint query field determination module 330 and a target query rule generation and data query module 340. Among them,
[0114] The target query formula acquisition module 310 is used to acquire the target query formula input by the user, and determine at least one query object and associated query conditions in the target query formula;
[0115] The associated data table determination module 320 is used to obtain at least one original query data table matching the query object, and search in the data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table;
[0116] The joint query field determination module 330 is used to generate at least one data table association structure pair according to the search results, and query the data table structure knowledge base to obtain the joint query fields corresponding to each data table association structure pair;
[0117] The target query rule generation and data query module 340 is used to generate a target query rule corresponding to the target query formula according to each joint query field, and query to obtain query result data matching the target query rule.
[0118] The technical solution provided by the embodiment of the present invention determines at least one query object and associated query conditions in a target query formula input by a user, obtains at least one original query data table matching the query object, and searches a data table association relationship knowledge base to see whether there is an associated data table that satisfies the associated query conditions with each original query data table, then generates at least one data table association structure pair based on the search results, and in the data table structure knowledge base, queries to obtain joint query fields corresponding to each data table association structure pair, then generates a target query rule corresponding to the target query formula based on each joint query field, and queries to obtain query result data matching the target query formula, automatically generates a target query rule corresponding to the target query formula input by the user, realizes the formulation of personalized data query rules, and improves data query efficiency.
[0119] Optionally, the associated data table determination module 320 is specifically used to: obtain one original query data table in turn as the current processing data table; obtain, from the data table association relationship knowledge base, an alternative associated data table that has a direct connection with the current processing data table and / or has at least one level of cascade relationship; obtain, from the data table association relationship knowledge base, a standard query condition between each of the alternative associated data tables and the current processing data table; perform similarity calculation on each of the standard query conditions and the associated query conditions, and obtain an alternative associated data table whose similarity calculation result meets a threshold value as the associated data table of the original query data table; return to execute the operation of obtaining one original query data table in turn as the current processing data table until the processing of all the original query data tables is completed.
[0120] Optionally, the target query rule generation and data query module 340 is specifically used to configure the query order and connection mode of each joint query field according to each joint query field, and generate a target query rule corresponding to the target query formula.
[0121] Optionally, the target query rule generation and data query module 340 includes: a target query script generation unit and a target query script execution unit, wherein:
[0122] A target query script generating unit, configured to generate a target query script corresponding to the target query rule by using a pre-created script generating template according to the target query rule;
[0123] The target query script execution unit is used to execute the target query script to query and obtain query result data that matches the target query rule.
[0124] Optionally, a target query script generation unit is specifically used to determine a target linked table path corresponding to the target query rule and generate a target linked table statement based on all data tables involved in the target query rule and the data table association relationship knowledge base; and to generate a target query script corresponding to the target query rule based on the target query rule and the target linked table statement using a pre-created script generation template.
[0125] Optionally, a target query script execution unit is specifically used to execute the target query script according to a pre-configured timer corresponding to the target query script, and query to obtain query result data that matches the target query rules, wherein the timer is used to determine the execution time of the target query script and the push time of the query result data.
[0126] Optionally, the above-mentioned device also includes: a query result data analysis and knowledge base operation and maintenance module, wherein the query result data analysis and knowledge base operation and maintenance module is used to perform statistical analysis on the query result data, and operate and maintain the data table structure knowledge base and the data table association relationship knowledge base.
[0127] The above-mentioned data query device can execute the data query method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the data query method.
[0128] Embodiment 4
[0129] Figure 4 A schematic diagram of the hardware structure of a computer device provided in Embodiment 4 of the present invention is shown in FIG. Figure 4 As shown, the computer device includes:
[0130] one or more processors 410, Figure 4 A processor 410 is taken as an example;
[0131] Memory 420;
[0132] The computer device may further include: an input device 430 and an output device 440 .
[0133] The processor 410, memory 420, input device 430 and output device 440 in the computer device can be connected via a bus or other means. Figure 4 The example of connecting through bus is taken in the following.
[0134] The memory 420 is a non-transitory computer-readable storage medium that can be used to store software programs, computer executable programs, and module packages, such as the program instructions / module packages (for example, the attached Figure 3 The processor 410 executes various functional applications and data processing of the computer device by running the software programs, instructions and modules stored in the memory 420, that is, implementing the data query method in the above method embodiment.
[0135] The memory 420 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 420 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 420 may optionally include a memory remotely arranged relative to the processor 410, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0136] The input device 430 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the computer device. The output device 440 may include a display device such as a display screen.
[0137] Embodiment 5
[0138] Embodiment 5 of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, a data query method provided by all the embodiments of the present invention is implemented. That is, when the program is executed by a processor, the following is implemented:
[0139] Acquire a target query formula input by a user, and determine at least one query object and associated query conditions in the target query formula;
[0140] Acquire at least one original query data table matching the query object, and search in a data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table;
[0141] Generate at least one data table association structure pair according to the search results, and query in a data table structure knowledge base to obtain joint query fields corresponding to each data table association structure pair;
[0142] According to each joint query field, a target query rule corresponding to the target query formula is generated, and query result data matching the target query rule is obtained through query.
[0143] Any combination of one or more computer-readable media can be used. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0144] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0145] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0146] Computer program code for performing the operation of the present invention may be written in one or more programming languages or combinations thereof, including object-oriented programming languages (such as Java, Smalltalk, C++), and conventional procedural programming languages (such as "C" language or similar programming languages). The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network (including a local area network (LAN) or a wide area network (WAN)), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0147] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A data query method, characterized in that: include: Acquire a target query formula input by a user, and determine at least one query object and associated query conditions in the target query formula; Acquire at least one original query data table matching the query object, and search in a data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table; wherein the data table association relationship knowledge base corresponds one-to-one to the target business system; Generate at least one data table association structure pair according to the search results, and query in a data table structure knowledge base to obtain joint query fields corresponding to each data table association structure pair, wherein the data table structure knowledge base corresponds to the target business system one by one; Generate a target query rule corresponding to the target query formula according to each joint query field, and query to obtain query result data matching the target query rule; Searching in the data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table includes: Obtain an original query data table in turn as the current processing data table; In the data table association relationship knowledge base, an alternative associated data table having a direct connection relationship with the currently processed data table and / or having at least one level of cascade relationship is obtained; In the data table association relationship knowledge base, obtaining a standard query condition between each of the candidate associated data tables and the currently processed data table; Calculate the similarity between each of the standard query conditions and the associated query condition, and obtain a candidate associated data table whose similarity calculation result meets a threshold value as the associated data table of the original query data table; Return to execute the operation of sequentially obtaining an original query data table as the current processing data table until the processing of all the original query data tables is completed; Querying to obtain query result data matching the target query rule includes: generating a target query script corresponding to the target query rule using a pre-created script generation template according to the target query rule; executing the target query script to query to obtain query result data matching the target query rule; The query order of each joint query field is used to determine the order in which each joint query field in the generated target query rule is applied when querying data; The connection mode of each joint query field is used to determine the connection mode of each joint query field in the generated target query rule; The connection modes include at least AND, OR, NOT, CONTENT, left semi-connection, and left anti-connection.
2. The method according to claim 1, characterized in that: According to each joint query field, a target query rule corresponding to the target query formula is generated, including: According to each joint query field, the query order and connection mode of each joint query field are configured to generate a target query rule corresponding to the target query formula.
3. The method according to claim 1, characterized in that Using a pre-created script generation template, a target query script corresponding to the target query rule is generated, including: According to all data tables involved in the target query rule and the data table association relationship knowledge base, determine the target joint table path corresponding to the target query rule, and generate a target joint table statement; A pre-created script generation template is used to generate a target query script corresponding to the target query rule according to the target query rule and the target linked table statement.
4. The method according to claim 1, characterized in that: Executing the target query script to obtain query result data matching the target query rule includes: According to a pre-configured timer corresponding to the target query script, the target query script is executed to obtain query result data matching the target query rule, wherein the timer is used to determine the execution time of the target query script and the push time of the query result data.
5. The method according to claim 1, characterized in that After obtaining the query result data matching the target query rule through query, the method further includes: Statistical analysis is performed on the query result data, and operation and maintenance are performed on the data table structure knowledge base and the data table association relationship knowledge base.
6. A data query device, characterized in that: include: A target query formula acquisition module, used to acquire a target query formula input by a user, and determine at least one query object and associated query conditions in the target query formula; An associated data table determination module is used to obtain at least one original query data table matching the query object, and search in a data table association relationship knowledge base whether there is an associated data table that satisfies the associated query condition with each original query data table; A joint query field determination module is used to generate at least one data table association structure pair according to the search results, and query the data table structure knowledge base to obtain the joint query fields corresponding to each data table association structure pair; A target query rule generation and data query module is used to generate a target query rule corresponding to the target query formula according to each joint query field, and query to obtain query result data matching the target query rule; Among them, the data table association relationship knowledge base corresponds to the target business system one by one; among them, the data table structure knowledge base corresponds to the target business system one by one; The associated data table determination module is specifically used to: sequentially obtain an original query data table as the current processing data table; obtain, from the data table association relationship knowledge base, an alternative associated data table that has a direct connection relationship with the current processing data table and / or has at least one level of cascade relationship; obtain, from the data table association relationship knowledge base, a standard query condition between each of the alternative associated data tables and the current processing data table; perform similarity calculation on each of the standard query conditions and the associated query condition, and obtain an alternative associated data table whose similarity calculation result meets a threshold value as the associated data table of the original query data table; return to execute the operation of sequentially obtaining an original query data table as the current processing data table until the processing of all the original query data tables is completed; The target query rule generation and data query module includes: a target query script generation unit and a target query script execution unit, wherein: A target query script generating unit, configured to generate a target query script corresponding to the target query rule according to the target query rule by using a pre-created script generating template; A target query script execution unit, used to execute the target query script to query and obtain query result data matching the target query rule; The query order of each joint query field is used to determine the order in which each joint query field in the generated target query rule is applied when querying data; The connection mode of each joint query field is used to determine the connection mode of each joint query field in the generated target query rule; The connection modes include at least AND, OR, NOT, CONTENT, left semi-connection, and left anti-connection.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Data query method and system of electric power business systems
CN104991975A
Electric power marketing inspection method, device and computer-readable storage medium
CN109146316A
Information query method and device for associated data, computer equipment and storage medium
CN110321344A
Data query method and device for distributed database and storage medium
CN111797134A
Business data query method, device and equipment and storage medium
CN112506946A
