On-the-fly query method, device and storage medium

By generating query code and analyzing the generated query statements for relational and graph databases, the problem of difficulty in simultaneously querying multiple attributes and complex relationships of data objects in existing ad hoc query methods is solved, and efficient querying of complex relational data is achieved.

CN116701432BActive Publication Date: 2026-01-06CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310664951.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-06
Publication Date
2026-01-06
Estimated Expiration
2043-06-06

AI Technical Summary

Technical Problem

Existing ad-hoc query methods struggle to simultaneously perform queries on multiple attributes of a data object and queries on complex relationships between data objects, resulting in poor query efficiency.

Method used

By generating query code, we analyze and generate query statements for relational databases and graph databases. Based on the order of the query chain, we query multiple attribute features from relational databases and complex relationship features from graph databases, and generate and display the query results.

Benefits of technology

It enables ad-hoc queries on complex relational data, optimizes query performance, and allows simultaneous querying of multiple attribute features and complex relational features of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116701432B_ABST
    Figure CN116701432B_ABST
Patent Text Reader

Abstract

The application provides an ad hoc query method and device and a storage medium, relates to the technical field of communication, and can solve the problem of poor ad hoc query effect on complex relationship data. The method comprises the following steps: acquiring a query code corresponding to target data, wherein the query code is generated by splicing according to a preset formula and query requirements; analyzing the query code to generate a relational database query statement, a graph database query statement and a query link; based on the sequence of the query link, querying multiple attribute characteristics between the target data from a relational database according to the relational database query statement, and querying complex relationship characteristics of the target data from a graph database according to the graph database query statement; and generating and displaying a query result according to the complex relationship characteristics between the target data and the multiple attribute characteristics of the target data. The embodiment of the application is used in the process of ad hoc query on complex relationship data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer network technology, and in particular to an ad-hoc query method, apparatus and storage medium. Background Technology

[0002] With the development of computer languages, the demand for fast, real-time queries is increasing, and users need to quickly find the data they need in various scenarios.

[0003] In existing technologies, when users need to quickly query data, they typically use ad-hoc queries. Ad-hoc queries allow users to flexibly select query conditions based on their needs and ultimately output the corresponding query results. However, existing ad-hoc queries can only guarantee queries on multiple attributes of the data object itself, or only guarantee queries on complex relationships between data objects. It is difficult to simultaneously achieve queries on multiple attributes of the data object itself and queries on complex relationships between data objects.

[0004] Therefore, existing ad-hoc queries cannot meet the needs of scenarios where complex relational data queries need to include both the complex relational features between data objects and the multiple attribute features of the data objects themselves, resulting in poor query efficiency. Summary of the Invention

[0005] This application provides an ad-hoc query method, apparatus, and storage medium, which can solve the problem of poor ad-hoc query performance for complex relational data.

[0006] To achieve the above objectives, this application adopts the following technical solution:

[0007] Firstly, this application provides an ad-hoc query method, which includes: obtaining a query code corresponding to target data, the query code being generated by concatenating a preset formula and query requirements; analyzing the query code to generate a relational database query statement, a graph database query statement, and a query chain, the query chain indicating the order of queries; based on the order of the query chain, querying multiple attribute features of the target data from the relational database according to the relational database query statement, and querying complex relationship features between the target data from the graph database according to the graph database query statement; generating and displaying query results based on the complex relationship features between the target data and the multiple attribute features of the target data; wherein the relational database and the graph database are stored on a server, the relational database including multiple attribute features of the data, and the graph database including complex relationship features between the data.

[0008] Based on the above technical solution, the ad-hoc query method provided in this application first obtains the query code corresponding to the data to be queried; then, it analyzes the query code to generate relational database query statements, graph database query statements, and query chains; next, based on the order of the query chains, and according to the relational database query statement, it queries the multiple attribute features of the data from the relational database, and according to the graph database query statement, it queries the complex relationship features between the data from the graph database; finally, it generates and displays the query results based on the complex relationship features between the data and the multiple attribute features of the data. Since the query code is generated by the user according to a preset formula and query requirements, and the relational database includes multiple attribute features of the data, and the graph database includes complex relationship features between the data, the two different query statements obtained from the query code can be used to query both the multiple attribute features of the data from the relational database and the complex relationship features between the data from the graph database, thus realizing ad-hoc querying of complex relational data and optimizing the query effect.

[0009] In the first possible implementation of the first aspect, before analyzing the query code, the method further includes submitting the query code corresponding to the target data to the server.

[0010] In the second possible implementation of the first aspect, before analyzing the query code, the method further includes: collecting raw data from an external data source, the raw data including the target data; cleaning and filtering the raw data to remove invalid data from the raw data.

[0011] In the third possible implementation of the first aspect, after removing invalid data from the original data, the method further includes: preprocessing the removed original data to obtain complex relationship features between the original data and multiple attribute features of the original data; storing the complex relationship features between the original data in the graph database based on the identity identifier of the original data, and storing the multiple attribute features of the original data in the relational database.

[0012] In the fourth possible implementation of the first aspect, the above-mentioned analysis of the query code to generate relational database query statements, graph database query statements, and query links includes: performing lexical and syntactic analysis on the query code; generating relational database query statements when the keywords in the query code belong to the relational database; generating graph database query statements according to a preset query function when the keywords in the query code belong to the graph database; and arranging the query links according to the connectors in the query code and the identity identifiers of the target data.

[0013] Secondly, this application provides an ad-hoc query device, comprising: a query input unit, a query processing unit, and a result display unit, wherein: the query input unit is used to obtain a query code corresponding to target data, the query code being generated by concatenating a preset formula and query requirements; the query processing unit is used to analyze the query code obtained by the query input unit, generating a relational database query statement, a graph database query statement, and a query link, the query link being used to indicate the order of queries; the query processing unit is further used to, based on the order of the query links, query multiple attribute features of the target data from the relational database according to the relational database query statement, and query complex relationship features between the target data from the graph database according to the graph database query statement; the result display unit is used to generate and display query results based on the complex relationship features between the target data and the multiple attribute features of the target data obtained by the query processing unit; wherein the relational database and the graph database are stored on a server, the relational database including multiple attribute features of the data, and the graph database including complex relationship features between the data.

[0014] In the first possible implementation of the second aspect, the query input unit is further configured to submit the query code corresponding to the target data to the server before the query processing unit analyzes the query code.

[0015] In a second possible implementation of the second aspect, the above-mentioned apparatus further includes: a data acquisition unit, wherein: the data acquisition unit is configured to: acquire raw data from an external data source, the raw data including the target data, before the query processing unit analyzes the query code; perform data cleaning and data filtering on the raw data to remove invalid data from the raw data.

[0016] In a third possible implementation of the second aspect, the above-mentioned apparatus further includes: a data separation unit, wherein: the data separation unit is configured to: after the data acquisition unit removes invalid data from the original data, preprocess the removed original data to obtain complex relationship features between the original data and multiple attribute features of the original data; based on the identity identifier of the original data, store the complex relationship features between the original data in the graph database, and store the multiple attribute features of the original data in the relational database.

[0017] In the fourth possible implementation of the second aspect, the query processing unit is specifically used for: performing lexical and syntactic analysis on the query code; generating a relational database query statement if the keywords in the query code belong to the relational database; generating a graph database query statement according to a preset query function if the keywords in the query code belong to the graph database; and arranging the query chain according to the connectors of the query code and the identity identifiers of the target data.

[0018] Thirdly, this application provides an ad-hoc query apparatus, which includes: a processor and a communication interface; the communication interface and the processor are coupled, and the processor is used to run computer programs or instructions to implement the ad-hoc query method as described in the first aspect and any possible implementation thereof.

[0019] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a terminal, cause the terminal to perform the ad-hoc query method as described in the first aspect and any possible implementation thereof.

[0020] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on an ad-hoc query device, cause the ad-hoc query device to execute the ad-hoc query method as described in the first aspect and any possible implementation thereof.

[0021] In a sixth aspect, embodiments of this application provide a chip including a processor and a communication interface coupled to the processor. The processor is used to run computer programs or instructions to implement the ad-hoc query method as described in the first aspect and any possible implementation thereof.

[0022] Specifically, the chip provided in this application embodiment also includes a memory for storing computer programs or instructions. Attached Figure Description

[0023] Figure 1 One of the flowcharts of an ad-hoc query method provided in this application embodiment;

[0024] Figure 2 A second flowchart of an ad-hoc query method provided in this application embodiment;

[0025] Figure 3 A third flowchart of an ad-hoc query method provided in this application embodiment;

[0026] Figure 4 A schematic diagram of the modules corresponding to an ad-hoc query method provided in an embodiment of this application;

[0027] Figure 5 A flowchart of an ad-hoc query method provided in this application embodiment is shown in Figure 4.

[0028] Figure 6 This is one of the structural schematic diagrams of an ad-hoc query device provided in an embodiment of this application;

[0029] Figure 7 This is a second schematic diagram of the structure of an ad-hoc query device provided in an embodiment of this application;

[0030] Figure 8 A third schematic diagram of the structure of an ad-hoc query device provided in this application embodiment;

[0031] Figure 9 This is a schematic diagram of another ad-hoc query device provided in an embodiment of this application. Detailed Implementation

[0032] The ad-hoc query method, apparatus, and storage medium provided in the embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0033] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0034] The terms "first" and "second," etc., used in the specification and drawings of this application are used to distinguish different objects or to distinguish different treatments of the same object, rather than to describe a specific order of objects.

[0035] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.

[0036] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0037] In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0038] Currently, ad-hoc queries allow users to flexibly select query conditions based on their needs and ultimately output the corresponding query results. For ad-hoc queries on complex relational data, it is necessary to include not only the complex relationship characteristics between data objects, but also the multiple attribute characteristics of the data objects themselves.

[0039] In existing technologies, ad-hoc queries using relational databases can only guarantee queries on multiple attributes of the data object itself, and it is difficult to query complex relationships between objects; while ad-hoc queries using graph databases can only guarantee queries on complex relationships between objects, and it is difficult to query queries on multiple attributes of the data object itself. Therefore, neither existing relational databases nor graph databases can simultaneously satisfy all these requirements, or the query results are unsatisfactory.

[0040] To address the poor performance of ad-hoc queries on complex relational data in existing technologies, this application provides an ad-hoc query method. First, the method obtains the query code corresponding to the data to be queried. Then, it analyzes the query code to generate relational database query statements, graph database query statements, and query chains. Next, based on the sequence of the query chains, and according to the relational database query statement, it queries the multiple attribute features of the data from the relational database, and according to the graph database query statement, it queries the complex relationship features between the data from the graph database. Finally, based on the complex relationship features and the multiple attribute features of the data, the query results are generated and displayed. Since the query code is generated by the user based on preset formulas and query requirements, and the relational database includes multiple attribute features of the data, while the graph database includes complex relationship features between the data, the method can subsequently use the two different query statements obtained from the query code to query both the multiple attribute features of the data from the relational database and the complex relationship features between the data from the graph database, thus achieving ad-hoc queries on complex relational data and optimizing query performance.

[0041] like Figure 1 The diagram shows a flowchart of an ad-hoc query method provided in an embodiment of this application. The method includes the following steps S101 to S104:

[0042] S101. Obtain the query code corresponding to the target data.

[0043] In this embodiment of the application, the target data mentioned above is the data that the user needs to query.

[0044] In this embodiment of the application, the above query code is generated by concatenating a preset formula and query requirements.

[0045] It should be noted that the process of obtaining the query code corresponding to the target data described above is performed on the client side.

[0046] For example, the target data mentioned above is the data corresponding to the above query requirement.

[0047] For example, the above-mentioned preset formula can be a query semantic formula.

[0048] For example, taking the above query semantic formula as formula (1), users can customize the combination of formula (1) and the conditions corresponding to their query requirements to obtain the query code. Formula (1) is as follows:

[0049] Q = [F (1) *M*V (1) *L*F (2) *M*V (2) *....*F (n) *M*V (n) ]->[DEPTH (m) *L*OUT (m) *L*IN (m) *L*DEGREE (m) ...] Formula (1)

[0050] Wherein, F represents the field name, M represents the field operator, V represents the query qualifier, L represents the logical operator, -> represents the concatenation operator, * represents the delimiter, and DEPTH represents the field name. (m) The functions for finding nodes at depth m are as follows: OUT(m) is the function for finding nodes with out-degree m, IN(m) is the function for finding nodes with in-degree m, and DEGREE(m) is the function for finding nodes with degree m.

[0051] For example, the logical operators mentioned above can be AND or OR.

[0052] For example, the connection symbols mentioned above are used to indicate the order of database queries.

[0053] For example, the functions included in the above M-field operators are shown in Table 1 below. It should be noted that Table 1 only shows a portion of the functions of the M-field operators. In practical applications, more functions may be included, which will not be elaborated here.

[0054] Table 1

[0055]

[0056]

[0057] S102. Analyze the query code to generate relational database query statements, graph database query statements, and query chains.

[0058] In this embodiment of the application, the relational database and the graph database are stored on the server.

[0059] In this embodiment of the application, the relational database includes multiple attribute features of the data.

[0060] For example, the relational database mentioned above can be a MySQL (Structured Query Language) database.

[0061] In this embodiment of the application, the graph database includes complex relationship features between data.

[0062] For example, the graph database mentioned above can be the NEO4J graph database.

[0063] In this embodiment of the application, the above query link is used to indicate the order of queries.

[0064] In this embodiment of the application, lexical analysis and syntax analysis can be performed on the query code obtained by the user-defined combination described above to generate specific database query statements (such as relational database query statements and graph database query statements) and query links, and then the query can be processed by combining them.

[0065] S103. Based on the order of the query chain, query the multiple attribute features of the target data from the relational database according to the query statement of the relational database, and query the complex relationship features between the target data from the graph database according to the query statement of the graph database.

[0066] In this embodiment of the application, the order of the above query links can be the query order indicated by the connection symbols in the above formula (1).

[0067] In this embodiment of the application, after obtaining the above query chain, relational database query statement and graph database query statement, the multiple attribute features of the data can be queried in the relational database and the complex relationship features between the data can be queried in the graph database according to the order of the query chain.

[0068] S104. Generate and display query results based on the complex relationship characteristics between target data and the multiple attribute characteristics of target data.

[0069] In this embodiment of the application, after obtaining the complex relationship features between the target data and the multiple attribute features of the target data, the final query results can be collected and organized, and the query results can be displayed to the user in a visual manner.

[0070] For example, the query results can be in tabular form or document form, etc.

[0071] In the ad-hoc query method provided in this application embodiment, the query code corresponding to the data to be queried can be obtained first; then the query code is analyzed to generate a relational database query statement, a graph database query statement, and a query chain; next, based on the order of the query chain, and according to the relational database query statement, the multiple attribute features of the data are queried from the relational database, and the complex relationship features between the data are queried from the graph database according to the graph database query statement; finally, the query results are generated and displayed based on the complex relationship features between the data and the multiple attribute features of the data. Since the above query code is generated by the user according to a preset formula and query requirements, and the above relational database includes multiple attribute features of the data, and the above graph database includes complex relationship features between the data, the two different query statements obtained from the analysis of the query code can be used to query both the multiple attribute features of the data from the relational database and the complex relationship features between the data from the graph database, thus realizing ad-hoc query of complex relational data and optimizing the query effect.

[0072] Optionally, in this embodiment of the application, before step S102 above, the ad-hoc query method provided in this embodiment of the application may further include the following step S101a:

[0073] S101a. Submit the query code corresponding to the target data to the server.

[0074] In this embodiment of the application, after the client receives the query code generated by the user, it needs to send the query code to the server for processing.

[0075] It should be noted that the above analysis of the query code was performed on the server side.

[0076] Optionally, in the embodiments of this application, such as Figure 2 As shown, prior to step S102 above, the ad-hoc query method provided in this application embodiment may further include the following steps S101b and S101c:

[0077] S101b: Collect raw data from external data sources.

[0078] In this embodiment of the application, the original data mentioned above includes the target data mentioned above.

[0079] For example, the original data mentioned above is known data.

[0080] S101c: Perform data cleaning and data filtering on the original data to remove invalid data from the original data.

[0081] In the embodiments of this application, the above-mentioned data cleaning and data filtering are used to re-examine and verify the original data, so as to delete duplicate information in the original data, correct erroneous information in the original data, and provide data consistency.

[0082] In this way, by collecting a large amount of known data and performing data cleaning and filtering, high-quality data can be obtained.

[0083] Optionally, in the embodiments of this application, such as Figure 3 As shown, after step S101c above, the ad-hoc query method provided in this application embodiment may further include the following steps S101d to S101e:

[0084] S101d: Preprocess the original data after removal to obtain the complex relationship features between the original data and the multiple attribute features of the original data.

[0085] In this embodiment of the application, the complex relationship features between the original data can be the relationship nodes and edge data between data objects.

[0086] In the embodiments of this application, the multiple attribute features of the original data can be the multiple attribute data of the data object itself.

[0087] In this embodiment of the application, the data after the above data cleaning and data filtering can be preprocessed to separate the relationship nodes and edge data between data objects and the multiple attribute data of the data objects themselves.

[0088] S101e: Based on the identity identifier of the original data, the complex relationship features between the original data are stored in the graph database, and the multiple attribute features of the original data are stored in the relational database.

[0089] In this embodiment of the application, each piece of data in the original data has its own unique identifier.

[0090] For example, the aforementioned identity identifier is used to associate complex relational features and multiple attribute features of a piece of data.

[0091] In this embodiment of the application, the relational nodes and edges between the separated data objects can be stored in a graph database, and the multiple attribute data of the separated object data itself can be stored in a relational database. At the same time, the unique identity of the data object is used as the association between the two.

[0092] In this way, by separating the complex relational features and multiple attribute features of the data and storing them in their respective databases, it is possible to query both features of a data simultaneously during subsequent queries.

[0093] The following explains the system used in the ad-hoc query method provided in the embodiments of this application:

[0094] In the embodiments of this application, such as Figure 4 As shown, the above system includes a client and a server.

[0095] In this embodiment of the application, the client includes a query input module and a result display module.

[0096] For example, the query input module described above is used by users to customize queries on the client according to combinable conditions.

[0097] For example, the above-mentioned result display module is used to display the return results of user-defined queries (displayed in a report or visual manner).

[0098] In this embodiment, the server includes a query processing module, a data acquisition module, and a data separation module.

[0099] For example, the data acquisition module described above is used for acquiring, cleaning, and filtering raw complex relationship data.

[0100] For example, the data separation module described above is used to preprocess the collected data, separate the relational nodes and connecting edge data between data objects and store them in a graph database, and separate the multiple attribute data of the objects themselves and store them in a relational database.

[0101] For example, the query processing module described above is used to perform lexical analysis and syntax analysis based on user-defined query statements, generate specific query database query statements and query chains, and combine them for query processing.

[0102] Optionally, in the embodiments of this application, such as Figure 5 As shown, in conjunction with the above step S101e, the above step S102 may include the following steps S102a to S102d:

[0103] S102a. Perform lexical and syntactic analysis on the query code.

[0104] In this embodiment of the application, the above lexical analysis involves scanning the query code character by character from left to right, and then identifying the words composed of each character according to the word formation rules.

[0105] In this embodiment of the application, the above-mentioned grammatical analysis is based on the above-mentioned lexical analysis, which combines the obtained words to obtain various phrases, and determines whether the above-mentioned query code is correct in logical structure.

[0106] S102b: If the keywords in the query code belong to a relational database, generate a relational database query statement.

[0107] In this embodiment of the application, the keywords mentioned above can represent the data that the user needs to query.

[0108] For example, the keywords mentioned above can be the words that appear most frequently among the words obtained from the lexical analysis.

[0109] In this application, the relational database query statement can be an SQL query statement.

[0110] For example, the keywords in the query code above can be matched with the keywords included in the relational database, and if the match is successful, a standard SQL query statement can be generated.

[0111] S102c: If the keyword in the query code belongs to a graph database, generate a graph database query statement according to the preset query function.

[0112] In this embodiment, the preset query function is a built-in function of the system.

[0113] For example, the above-mentioned preset query function can be customized and extended.

[0114] It should be noted that different preset query functions correspond to different query operations.

[0115] For example, the keywords in the above query code can be matched with the keywords included in the graph database. If the match is successful, a graph database query statement is generated according to the system's built-in function.

[0116] S102d. Arrange the query link according to the connector of the query code and the identity of the target data.

[0117] In this embodiment of the application, when generating the above query link, the unique identifier of the data to be queried needs to be used as the transmission identifier of the query link, and then the query link is arranged in sequence according to the connector in the query code.

[0118] In this way, by performing lexical and syntactic analysis on the query code, two different query statements and query chains are obtained, so as to simultaneously query the complex relational features and multiple attribute features of the data, thereby improving the query effect.

[0119] The following provides an exemplary description of the actual scenarios in which the ad-hoc query method provided in the embodiments of this application is applied:

[0120] Exemplarily, take the example of finding all colleagues who are in contact with colleagues surnamed Liu and aged 28. After pre-storing the enterprise member table in the MYSQL database and the enterprise member call record relationship in the NEO4J graph database, the entire query process can be implemented through the following steps S1 to S7.

[0121] S1. The user splices the query requirements through the visual front-end interface.

[0122] For example, the above query requirement is [NAME*START_WITH*Liu*AND*AGE*=*28]->DEPTH (1) .

[0123] S2. The front end submits the converted query requirements to the server.

[0124] S3. After receiving the query semantics, the server performs lexical analysis and syntax analysis in sequence.

[0125] S4. After performing lexical analysis and syntax analysis, a standard database query statement is formed.

[0126] Exemplarily, for keywords in the query requirements that belong to the relational database, a standard SQL query statement is formed.

[0127] Exemplarily, for keywords in the query requirements that belong to the graph database, a graph database query statement is formed according to the preset query function.

[0128] S5. Arrange the query links in sequence according to the connection symbol (—>).

[0129] Exemplarily, the primary key identity of the data object is used as the transfer identifier between the above query links.

[0130] S6. The query tasks on the query links are sequentially executed through the query scheduler, and the results are collected.

[0131] S7. The query results are output and displayed to the user in a front-end visual manner to achieve the purpose of ad hoc query of complex relationship data.

[0132] In the embodiments of the present application, the ad hoc query device can be divided into functional modules or functional units according to the above method examples. For example, each functional module or functional unit can be corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware, or in the form of software functional modules or functional units. Among them, the division of modules or units in the embodiments of the present application is illustrative, only a logical function division, and there can be other division methods in actual implementation.

[0133] Such as Figure 6 The diagram shown is a schematic representation of an ad-hoc query device provided in an embodiment of this application. The device includes a query input unit 201, a query processing unit 202, and a result display unit 203.

[0134] The query input unit 201 is used to obtain the query code corresponding to the target data, which is generated by concatenating a preset formula and query requirements. The query processing unit 202 is used to analyze the query code obtained by the query input unit 201 and generate a relational database query statement, a graph database query statement, and a query link, which indicates the order of queries. The query processing unit 202 is also used to query the multiple attribute features of the target data from the relational database based on the order of the query links and the relational database query statement, and to query the complex relationship features between the target data from the graph database based on the graph database query statement. The result display unit 203 is used to generate and display the query results based on the complex relationship features between the target data and the multiple attribute features of the target data obtained by the query processing unit 202. The relational database and the graph database are stored on the server. The relational database includes the multiple attribute features of the data, and the graph database includes the complex relationship features between the data.

[0135] Optionally, in this embodiment of the application, the query input unit 201 is further configured to submit the query code corresponding to the target data to the server before the query processing unit 202 analyzes the query code.

[0136] Optionally, in the embodiments of this application, such as Figure 7 As shown, the ad-hoc query device further includes a data acquisition unit 204, wherein the data acquisition unit 204 is used to: acquire raw data from an external data source before the query processing unit 202 analyzes the query code, the raw data including the target data; perform data cleaning and data filtering on the raw data to remove invalid data from the raw data.

[0137] Optionally, in the embodiments of this application, such as Figure 8 As shown, the ad-hoc query device further includes a data separation unit 205, wherein the data separation unit 205 is used to: after the data acquisition unit 204 removes invalid data from the original data, preprocess the removed original data to obtain complex relationship features between the original data and multiple attribute features of the original data; based on the identity of the original data, store the complex relationship features between the original data in the graph database, and store the multiple attribute features of the original data in the relational database.

[0138] Optionally, in this embodiment of the application, the query processing unit 202 is specifically used for: performing lexical and syntactic analysis on the query code; generating a relational database query statement when the keywords in the query code belong to the relational database; generating a graph database query statement according to a preset query function when the keywords in the query code belong to the graph database; and arranging the query link according to the connector of the query code and the identity identifier of the target data.

[0139] In the ad-hoc query device provided in this application embodiment, the query code corresponding to the data to be queried can be obtained first; then the query code is analyzed to generate a relational database query statement, a graph database query statement, and a query chain; next, based on the order of the query chain, and according to the relational database query statement, the multiple attribute features of the data are queried from the relational database, and the complex relationship features between the data are queried from the graph database according to the graph database query statement; finally, the query results are generated and displayed based on the complex relationship features between the data and the multiple attribute features of the data. Since the above query code is generated by the user according to a preset formula and query requirements, and the above relational database includes multiple attribute features of the data, and the above graph database includes complex relationship features between the data, the two different query statements obtained from the query code can be used to query both the multiple attribute features of the data from the relational database and the complex relationship features between the data from the graph database, thus realizing ad-hoc query of complex relational data and optimizing the query effect.

[0140] Figure 9 A schematic diagram of another possible structure of the ad-hoc query device involved in the above embodiments is shown. This ad-hoc query device includes a processor 302 and a communication interface 303. The processor 302 is used to control and manage the actions of the ad-hoc query device, for example, executing the steps performed by the query input unit 201, query processing unit 202, result display unit 203, data acquisition unit 204, and data separation unit 205, and / or performing other processes of the technology described herein. The communication interface 303 is used to support communication between the ad-hoc query device and other network entities. The ad-hoc query device may also include a memory 301 and a bus 304, the memory 301 being used to store the program code and data of the ad-hoc query device.

[0141] The memory 301 may be the memory in an ad-hoc query device, and the memory may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk or solid-state drive; the memory may also include a combination of the above types of memory.

[0142] The processor 302 described above can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0143] Bus 304 can be an Extended Industry Standard Architecture (EISA) bus, etc. Bus 304 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 9 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0144] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0145] This application provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the ad-hoc query method described in the above method embodiments.

[0146] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the ad-hoc query method in the method flow shown in the above method embodiments.

[0147] The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires; portable computer disks; hard disks; random access memory (RAM); read-only memory (ROM); erasable programmable read-only memory (EPROM); registers; hard disks; optical fibers; portable compact disc read-only memory (CD-ROM); optical storage devices; magnetic storage devices; or any suitable combination thereof; or any other form of computer-readable storage medium known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may reside in an application-specific integrated circuit (ASIC). In the embodiments of this application, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0148] Embodiments of the present invention provide a computer program product containing instructions that, when executed on a computer, cause the computer to perform actions such as... Figures 1 to 5 The ad-hoc query method described in [the document].

[0149] Since the ad-hoc query device, computer-readable storage medium, and computer program product in the embodiments of the present invention can be applied to the above methods, the technical effects they can achieve can also be referred to the above method embodiments. The embodiments of the present invention will not be repeated here.

[0150] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0151] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0152] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0153] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. An ad hoc query method, characterized by, The method comprises: acquiring a query code corresponding to target data, the query code being generated by splicing according to a preset formula and a query requirement; analyzing the query code to generate a relational database query statement, a graph database query statement, and a query link, the query link being used to indicate a sequence of the query; querying, from a relational database, multiple attribute features of the target data according to the relational database query statement and querying, from a graph database, complex relationship features between the target data according to the graph database query statement based on the sequence of the query link; generating and displaying a query result according to the complex relationship features between the target data and the multiple attribute features of the target data. The relational database and the graph database are stored in a server, the relational database comprises multiple attribute features of data, and the graph database comprises complex relationship features between data.

2. The method of claim 1, wherein, Before the analyzing the query code, the method further comprises: submitting the query code corresponding to the target data to the server.

3. The method according to claim 1 or 2, characterized in that, Before the analyzing the query code, the method further comprises: collecting original data from an external data source, the original data comprising the target data; performing data cleaning and data filtering on the original data to eliminate invalid data in the original data.

4. The method of claim 3, wherein, After the eliminating the invalid data in the original data, the method further comprises: performing preprocessing on the original data after the elimination to obtain complex relationship features between the original data and multiple attribute features of the original data; storing the complex relationship features between the original data to the graph database and storing the multiple attribute features of the original data to the relational database based on an identity of the original data.

5. The method of claim 4, wherein, The analyzing the query code to generate the relational database query statement, the graph database query statement, and the query link comprises: performing lexical and syntactic analysis on the query code; generating the relational database query statement in a case where a keyword in the query code belongs to the relational database; generating the graph database query statement according to a preset query function in a case where the keyword in the query code belongs to the graph database; arranging the query link according to a connector of the query code and an identity of the target data.

6. An ad hoc query apparatus characterized by comprising: The device comprises a query input unit, a query processing unit, and a result display unit, wherein: the query input unit is used to acquire a query code corresponding to target data, the query code being generated by splicing according to a preset formula and a query requirement; the query processing unit is used to analyze the query code acquired by the query input unit to generate a relational database query statement, a graph database query statement, and a query link, the query link being used to indicate a sequence of the query; The query processing unit is further configured to query, according to the relational database query statement, the multiple attribute features of the target data from a relational database based on the order of the query links, and query, according to the graph database query statement, the complex relationship features between the target data from a graph database. The result display unit is configured to generate and display a query result according to the complex relationship features between the target data and the multiple attribute features of the target data obtained by the query processing unit. The relational database and the graph database are stored in a server, the relational database includes the multiple attribute features of data, and the graph database includes the complex relationship features between data.

7. The apparatus of claim 6, wherein The query input unit is further configured to submit the query code corresponding to the target data to the server before the query processing unit analyzes the query code.

8. The apparatus of claim 6 or 7, wherein, The apparatus further includes a data collection unit, wherein: The data collection unit is configured to: collect original data from an external data source before the query processing unit analyzes the query code, the original data including the target data; perform data cleaning and data filtering on the original data to eliminate invalid data in the original data.

9. The apparatus of claim 8, wherein, The apparatus further includes a data separation unit, wherein: The data separation unit is configured to: perform preprocessing on the original data after the data collection unit eliminates the invalid data in the original data, to obtain the complex relationship features between the original data and the multiple attribute features of the original data; store the complex relationship features between the original data into the graph database and store the multiple attribute features of the original data into the relational database based on the identity of the original data.

10. The apparatus of claim 9, wherein The query processing unit is specifically configured to: perform lexical and syntactic analysis on the query code; generate the relational database query statement in a case where a keyword in the query code belongs to the relational database; generate the graph database query statement according to a preset query function in a case where the keyword in the query code belongs to the graph database; arrange the query links according to the connector of the query code and the identity of the target data.

11. An ad hoc query apparatus, characterized by including: a processor and a communication interface; the communication interface and the processor are coupled, and the processor is configured to run computer programs or instructions to implement the ad hoc query method in any one of claims 1-5.

12. A computer-readable storage medium having stored therein instructions, the computer-readable storage medium comprising: When a computer executes the instructions, the computer executes the ad hoc query method in any one of claims 1-5.

Citation Information

Patent Citations

  • Data query method and device and storage medium

    CN112416962A

  • Graph data query processing method and device and electronic equipment

    CN113312384A