Data query method and device

By constructing a knowledge graph of the database and using the concept layer and instance layer to determine SQL statements, the problem of being unable to accurately query the database in the existing technology is solved, and the effect of accurately querying the database can be achieved even when the amount and type of data increases.

CN114064909BActive Publication Date: 2025-09-30HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202010783351.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-06
Publication Date
2025-09-30
Estimated Expiration
2040-08-06

AI Technical Summary

Technical Problem

Existing technologies cannot effectively determine the SQL statements corresponding to the queryer's intent in the database, resulting in the inability to query the required data from the database. Especially when the amount and type of data increase, the annotated data, syntax trees and dictionaries cannot meet the query requirements.

Method used

By constructing a knowledge graph of the database and utilizing the concept layer and instance layer in the knowledge graph, the SQL statement corresponding to the query information is determined. Combining the general knowledge of the database and the query permissions, ambiguity is eliminated and the query results are directly determined.

Benefits of technology

Even if the database scales up, SQL statements and query results can still be accurately determined, which improves the accuracy and efficiency of data queries and reduces dependence on labeled data and dictionaries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064909B_ABST
    Figure CN114064909B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a data query method and device. In this method, the knowledge graph of the database to be queried is first determined, and then the structured query language SQL statement corresponding to the query information is determined through the knowledge graph, and then the query result corresponding to the SQL statement in the database is determined based on the SQL statement. When performing data query through the solution of the present application, even if the amount of data stored in the database and the type of data increase, the knowledge graph of the database can also reflect the relationship between the entities of the database. Therefore, even if the scale of the database expands, the SQL statement corresponding to the query information can be determined through the solution of the present application, and the query result can be further obtained to realize data query, thereby solving the problem that the SQL statement cannot be determined by the existing technology, resulting in the inability to query the required data from the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a data query method and device. Background Art

[0002] With the advancement of information technology, data of all types is increasing. For example, businesses often accumulate vast amounts of data during their operations. Consequently, multiple databases storing large amounts of data are often created. Furthermore, with the current trend of digital transformation, the demand for business analysis and digital operations is increasing. To meet this demand, it is often necessary to retrieve the data required by the queryer from these massive databases.

[0003] Currently, when obtaining the data required by the query personnel from the database, the text or voice output by the query personnel can be obtained, and the text or voice is used to represent the query personnel's intention to obtain data; then, the structured query language (SQL) statement corresponding to the text or voice is determined; then, the database is queried using the SQL statement to determine the data corresponding to the SQL statement. The data corresponding to the SQL statement is the data required by the query personnel, thereby satisfying the query personnel's need to obtain data.

[0004] When determining the SQL statement, deep learning methods and slot filling methods are generally used. When using deep learning methods, a large amount of annotated data is pre-determined, each of which is used to indicate the correspondence between a text or voice and an SQL statement. Then, after receiving the text or voice input by the query operator, the corresponding SQL statement can be determined based on the correspondence indicated by the annotated data.

[0005] Slot filling refers to the process of completing information to translate the queryer's intent into the corresponding command. When slot filling is used, the syntax tree and dictionary are used to identify key parameters contained in the queryer's text or voice input. These key parameters are then filled into the corresponding slots, and the corresponding SQL statement is determined from the filled slots.

[0006] As can be seen from the above description, deep learning methods have a strong reliance on labeled data, while slot-filling methods have a strong reliance on syntax trees and dictionaries. However, with the development of information technology, the amount and type of data stored in databases are increasing. As a result, sometimes labeled data, syntax trees, and dictionaries cannot meet the data query needs of the query operator. Therefore, using existing methods, it is impossible to determine the SQL statement corresponding to the text or voice input by the query operator, which further leads to the inability to retrieve the required data from the database. Summary of the Invention

[0007] In order to solve the problem in the prior art that the corresponding SQL statement cannot be determined and thus the required data cannot be queried from the database, the present application discloses a data query method and device through the following embodiments.

[0008] In a first aspect, an embodiment of the present application discloses a data query method, comprising:

[0009] Determining a knowledge graph of a database to be queried, the knowledge graph being used to indicate relationships between entities in a data model of the database;

[0010] Determining, based on the knowledge graph, a structured query language SQL statement corresponding to query information, wherein the query information includes: query text information and / or query voice information;

[0011] Determine the query result corresponding to the SQL statement in the database.

[0012] Through the above method, the query results of the database can be determined based on the knowledge graph of the database. Even if the amount of data stored in the database and the type of data increase, the knowledge graph of the database can still reflect the relationship between the entities in the database. Therefore, even if the scale of the database expands, the SQL statement corresponding to the query information can still be determined through the knowledge graph, and further based on the SQL statement, the corresponding query result in the database can be determined, thereby solving the problem that the SQL statement cannot be determined using existing technologies, resulting in the inability to query the required data from the database.

[0013] In an optional design, the knowledge graph includes: a concept layer and an instance layer;

[0014] The data model includes: a logical model and a physical model;

[0015] The entities in the data model of the database include: logical entities in the logical model and physical entities in the physical model;

[0016] The concept layer is used to indicate the relationship between at least one logical entity in the logical model;

[0017] The instance layer is used to indicate the relationship between at least one physical entity in the physical model.

[0018] Through the concept layer in the knowledge graph, the relationship between the logical entities of the database can be determined, and through the instance layer in the knowledge graph, the relationship between the physical entities of the database can be determined.

[0019] In an optional design, determining the knowledge graph of the database to be queried includes:

[0020] Determining, according to a logical model in the data model, the at least one logical entity and a relationship between the at least one logical entity;

[0021] determining the concept layer according to the at least one logical entity and the relationship between the at least one logical entity;

[0022] determining, according to the physical model in the data model, the at least one physical entity and the relationship between the at least one physical entity;

[0023] The instance layer is determined according to the at least one physical entity and the relationship between the at least one physical entity.

[0024] Through the above steps, a knowledge graph including a concept layer and an instance layer can be determined so as to implement data query based on the knowledge graph.

[0025] In an optional design, determining a structured query language SQL statement corresponding to the query information based on the knowledge graph includes:

[0026] Determining query terms included in the query information;

[0027] Determining a first logical entity corresponding to the query term in the concept layer;

[0028] determining first physical entities corresponding to the first logical entities and the query terms, and determining a query relationship between the first physical entities;

[0029] An SQL field corresponding to the first physical entity is determined, and a corresponding SQL statement is determined based on the SQL field and the query relationship.

[0030] In the above steps, the first logical entity corresponding to the query term is first determined, and then the first physical entity corresponding to the first logical entity is determined. Thus, through the first logical entity, the scope of the first physical entity to be queried is narrowed, the query operations required to determine the first physical entity corresponding to the query term can be reduced, and the speed of determining the first physical entity can be increased, further improving the efficiency of determining the SQL statement.

[0031] An optional design also includes:

[0032] determining conventional knowledge corresponding to the database;

[0033] The conventional knowledge includes at least one of the abbreviation and full name of the query term, synonyms of the query term, near-synonyms of the query term, and query information examples.

[0034] An optional design also includes:

[0035] After determining the query terms included in the query information, converting the query terms according to conventional knowledge corresponding to the database;

[0036] The step of determining the structured query language SQL statement corresponding to the query information includes:

[0037] The SQL statement corresponding to the query information is determined based on the converted query terms.

[0038] Through the above steps, the query information can be converted according to the conventional knowledge corresponding to the database, and then the SQL statement can be determined based on the converted query information, that is, data query can be realized in combination with the conventional knowledge corresponding to the database, thereby improving the accuracy of determining the SQL statement and further improving the accuracy of data query.

[0039] An optional design also includes:

[0040] If a first query term in the query terms corresponds to at least two physical entities, after determining the query terms included in the query information, determining relationships between the at least two physical entities and other query terms respectively;

[0041] Determining, according to the query authority of the inputter of the query information and / or the content contained in the database, a first target relationship among the relationships that the inputter can query;

[0042] The determining the SQL field corresponding to the first physical entity includes:

[0043] Determining the first physical entity indicated by the first target relationship as a first target physical entity;

[0044] Determine the SQL field corresponding to the first target physical entity.

[0045] Through the above steps, the ambiguity of the query information can be eliminated based on the relationship between the at least two physical entities corresponding to the first query term and other query terms, and the true query intention of the person inputting the query information can be determined, thereby improving the accuracy of data query.

[0046] An optional design also includes:

[0047] If a first query term in the query terms corresponds to at least two physical entities, after determining the query terms included in the query information, determining a first relationship set consisting of relationships between the at least two physical entities and other physical entities in the database;

[0048] determining, according to the query authority of the inputter of the query information, a second relationship set consisting of relationships that the inputter can query in the first relationship set;

[0049] determining a quantized length of at least one relation included in the second relation set;

[0050] determining a second target relationship according to the quantized length;

[0051] The determining the SQL field corresponding to the first physical entity includes:

[0052] Determining the first physical entity indicated by the second target relationship as the second target physical entity;

[0053] Determine the SQL field corresponding to the second target physical entity.

[0054] Through the above steps, the ambiguity of the query information can be eliminated based on the relationship between the at least two physical entities corresponding to the first query term and other physical entities in the database, and the true query intention of the person inputting the query information can be determined, thereby improving the accuracy of data query.

[0055] An optional design also includes:

[0056] Determining a third correspondence between the historical query information and the historical query results based on the first correspondence between the historical query information and the historical SQL statements, and the second correspondence between the historical SQL statements and the historical query results;

[0057] If the current query information belongs to the historical query information, the query result corresponding to the current query information is determined according to the third corresponding relationship.

[0058] If the current query information belongs to the historical query information, the solution provided by the above steps can directly determine the query result corresponding to the current query information based on the third correspondence, thereby improving query efficiency. Furthermore, when determining the query result through this solution, there is no need to rely on the knowledge graph. Therefore, even if the device running the knowledge graph is in the process of cold start, the query result can still be obtained, meeting the database query requirements.

[0059] An optional design also includes:

[0060] Determining display rules for the query results;

[0061] After determining the query result corresponding to the SQL statement in the database, the query result is displayed according to the display rule.

[0062] The display rules are usually used to indicate the sorting order of each data contained in the database. Through this solution, the query results can be displayed according to the order indicated by the display rules, meeting the query result viewing needs of the query personnel.

[0063] In a second aspect, an embodiment of the present application provides a data query device, comprising:

[0064] A graph determination module, configured to determine a knowledge graph of a database to be queried, wherein the knowledge graph is configured to indicate relationships between entities in a data model of the database;

[0065] A statement determination module is used to determine a structured query language SQL statement corresponding to the query information based on the knowledge graph, wherein the query information includes: query text information and / or query voice information;

[0066] The first query module is used to determine the query result corresponding to the SQL statement in the database.

[0067] In an optional design, the knowledge graph includes: a concept layer and an instance layer;

[0068] The data model includes: a logical model and a physical model;

[0069] The entities in the data model of the database include: logical entities in the logical model and physical entities in the physical model;

[0070] The concept layer is used to indicate the relationship between at least one logical entity in the logical model;

[0071] The instance layer is used to indicate the relationship between at least one physical entity in the physical model.

[0072] In an optional design, the graph determination module is used to determine the at least one logical entity and the relationship between the at least one logical entity based on the logical model in the data model, determine the conceptual layer based on the at least one logical entity and the relationship between the at least one logical entity, determine the at least one physical entity and the relationship between the at least one physical entity based on the physical model in the data model, and determine the instance layer based on the at least one physical entity and the relationship between the at least one physical entity.

[0073] In an optional design, the statement determination module is used to determine the query terms included in the query information; determine the first logical entity corresponding to the query terms in the conceptual layer, determine the first physical entity corresponding to the first logical entity and the query terms, and determine the query relationship between the first physical entities, determine the SQL field corresponding to the first physical entity, and determine the corresponding SQL statement based on the SQL field and the query relationship.

[0074] An optional design also includes:

[0075] A general knowledge determination module, configured to determine the general knowledge corresponding to the database;

[0076] The conventional knowledge includes at least one of the abbreviation and full name of the query term, synonyms of the query term, near-synonyms of the query term, and query information examples.

[0077] An optional design also includes:

[0078] a conversion module, configured to convert the query terms included in the query information according to conventional knowledge corresponding to the database after determining the query terms included in the query information;

[0079] The statement determination module is specifically used to determine the SQL statement corresponding to the query information according to the converted query terms.

[0080] An optional design also includes:

[0081] a first relationship determination module;

[0082] If a first query term in the query terms corresponds to at least two physical entities, the first relationship determination module is configured to, after determining the query terms included in the query information, determine the relationships between the at least two physical entities and other query terms, and determine, based on the query authority of the inputter of the query information and / or the content contained in the database, a first target relationship that the inputter can query among the relationships;

[0083] The statement determination module is specifically configured to determine that the first physical entity indicated by the first target relationship is a first target physical entity; and determine an SQL field corresponding to the first target physical entity.

[0084] An optional design also includes:

[0085] a second relationship determination module;

[0086] If a first query term in the query terms corresponds to at least two physical entities, the second relationship determination module is configured to, after determining the query terms included in the query information, determine a first relationship set consisting of relationships between the at least two physical entities and other physical entities in the database; determine, based on the query authority of a user inputting the query information, a second relationship set consisting of relationships that the user can query in the first relationship set; determine a quantized length of at least one relationship included in the second relationship set; and determine a second target relationship based on the quantized length;

[0087] The statement determination module is specifically configured to determine that the first physical entity indicated by the second target relationship is the second target physical entity; and determine an SQL field corresponding to the second target physical entity.

[0088] An optional design also includes:

[0089] The second query module is used to determine the third correspondence between the historical query information and the historical query results based on the first correspondence between the historical query information and the historical SQL statements, and the second correspondence between the historical SQL statements and the historical query results. If the current query information belongs to the historical query information, the query result corresponding to the current query information is determined according to the third correspondence.

[0090] An optional design also includes:

[0091] The rule determination module is used to determine a display rule for the query result, and after determining the query result corresponding to the SQL statement in the database, display the query result according to the display rule.

[0092] In a third aspect, an embodiment of the present application provides a terminal device, comprising a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program stored in the memory so that the terminal device executes the method described in the second aspect.

[0093] In a fourth aspect, an embodiment of the present application provides a readable storage medium, which is used to store instructions. When the instructions are executed, the method described in the first aspect is implemented.

[0094] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when run on an electronic device, enables the electronic device to implement all or part of the steps in the embodiment corresponding to the first aspect.

[0095] In the solution provided in the embodiment of the present application, the SQL statement corresponding to the query information is determined based on the knowledge graph of the database, and then the query result of the database is determined by the SQL statement.

[0096] Compared with the prior art, the solution provided by the embodiment of the present application does not need to rely on labeled data, syntax trees and dictionaries. In the solution provided by the embodiment of the present application, the SQL statement corresponding to the query information is determined by the knowledge graph, and further based on the SQL statement, the corresponding query result in the database is determined. Even if the amount of data stored in the database and the type of data increase, the knowledge graph of the database can also reflect the relationship between the entities of the database. In other words, even if the scale of the database expands, the query of the database can still be realized through the knowledge graph, thereby solving the problem that the SQL statement cannot be determined by the prior art, resulting in the inability to query the required data from the database.

[0097] Furthermore, in the solution provided in the embodiment of the present application, general knowledge related to the database can also be obtained, and the query terms in the query information can be converted through the general knowledge, and the corresponding SQL statements can be determined through the converted query terms, that is, data query can be implemented in combination with the general knowledge corresponding to the database, thereby improving the accuracy of determining the SQL statement and further improving the accuracy of data query.

[0098] In addition, in an embodiment of the present application, it is also possible to determine the true query intention of the inputter of the query information based on the query authority of the inputter of the query information and / or the content contained in the database, and / or based on the relationship between the ambiguous first query term in the query information and other physical entities in the database, and determine the corresponding SQL statement based on the true query intention, thereby eliminating the ambiguity of the query information and improving the accuracy of data query.

[0099] Moreover, in the solution adopted in the embodiment of the present application, a correspondence between historical query information and historical query results can also be established. If the current query information belongs to the historical query information, the query result corresponding to the current query information can be directly determined based on the correspondence between the historical query information and the historical query results, thereby further improving the efficiency of data query. BRIEF DESCRIPTION OF THE DRAWINGS

[0100] Figure 1 A schematic diagram of the workflow of a data query method disclosed in an embodiment of the present application;

[0101] Figure 2 A schematic diagram of a workflow for determining a knowledge graph in a data query method disclosed in an embodiment of the present application;

[0102] FIG3( a ) is a schematic diagram of a physical table included in a database in a data query method disclosed in an embodiment of the present application;

[0103] FIG3( b ) is a schematic diagram of a role's demand for data query in a data query method disclosed in an embodiment of the present application;

[0104] FIG3( c ) is a schematic diagram of a logic model in a data query method disclosed in an embodiment of the present application;

[0105] FIG3( d ) is a schematic diagram of a conceptual layer in a data query method disclosed in an embodiment of the present application;

[0106] FIG4( a ) is a schematic diagram of a physical model in a data query method disclosed in an embodiment of the present application;

[0107] FIG4( b ) is a schematic diagram of a physical table in a data query method disclosed in an embodiment of the present application;

[0108] FIG4( c ) is a schematic diagram of an instance layer in a data query method disclosed in an embodiment of the present application;

[0109] Figure 5 A schematic diagram of a workflow for determining an SQL statement in a data query method disclosed in an embodiment of the present application;

[0110] Figure 6 A schematic diagram of a workflow for determining a second target relationship in a data query method disclosed in an embodiment of the present application;

[0111] Figure 7 A schematic diagram of the structure of a data query device disclosed in an embodiment of the present application;

[0112] Figure 8 A schematic diagram of the structure of a terminal device disclosed in an embodiment of the present application;

[0113] Figure 9 This is a schematic diagram of the structure of a terminal device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0114] The terms "first", "second" and "third" in the specification, claims and drawings of this application are used to distinguish different objects rather than to limit a specific order.

[0115] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0116] To make the description of the following embodiments clear and concise, a brief introduction to the related technologies is first given:

[0117] With the development of information technology, various types of data are increasing, which leads to more and more types of data stored in databases. Moreover, as time goes by, the amount of various types of data stored in databases is also increasing, resulting in an increasingly large amount of data in databases.

[0118] For example, in the process of business development, various types of data about employees, products, and customers are often accumulated and stored in the company's database, resulting in a large amount of various types of data being stored in the company's database. Accordingly, the company's database has a huge amount of data.

[0119] In addition, in order to meet the needs of business analysis and digital operations, it is sometimes necessary to query the database in order to obtain the data required by the query personnel from the database.

[0120] Currently, when retrieving data from a database containing multiple physical tables, a physical table query method can be used. For example, if the database includes a business intelligence (BI) physical table, a query operator can retrieve the required data by querying the BI physical table. However, this method requires the query operator to locate the desired physical table among the numerous physical tables in the database and then review the data contained in the physical table. This is cumbersome, time-consuming, and consumes a significant amount of human resources.

[0121] Alternatively, database queries can be performed using SQL statements. This requires the query operator to write a structured query language (SQL) statement based on the query requirements, and then use this SQL statement to query the corresponding data in the database. However, this method requires the query operator to understand SQL technology, which requires a certain level of expertise and increases the barrier to entry for data query.

[0122] In response to the problems with the above two solutions, there is currently a solution that converts text or voice into SQL statements. In this solution, if the data required by the query operator needs to be obtained from the database, the text or voice output by the query operator is first obtained. This text or voice is used to represent the query operator's intention to query data. For example, if the query operator needs to obtain the total revenue of Department A in 2019, the terminal device can input text containing "the total revenue of Department A in 2019" into the terminal device through an input tool such as a physical keyboard or a virtual keyboard, so that the terminal device can obtain the text representing the query operator's query intention; alternatively, the query operator can issue a voice containing "the total revenue of Department A in 2019", and the terminal device can obtain the voice representing the query operator's query intention through a voice collection device such as a microphone; then, the terminal device converts the text or voice into a corresponding SQL statement, that is, determines the SQL statement corresponding to the text or voice; then, the database is queried using the SQL statement to determine the data corresponding to the SQL statement. The data corresponding to the SQL statement is the data required by the query operator, so that the query operator can obtain the query results.

[0123] Moreover, in this solution, the query personnel only need to enter text or voice that represents their intention to query data. The query personnel do not need to query each physical table personally. For the query personnel, the implementation method is relatively simple and quick. In addition, this method has low professional requirements for the query personnel, lowering the threshold for data query.

[0124] In addition, when converting the text or voice output by the query operator into the corresponding SQL statement, the following deep learning methods and slot filling methods are currently commonly used.

[0125] Among them, if the deep learning method is adopted, a large amount of annotated data needs to be prepared in advance, and each annotated data is used to indicate the correspondence between a text or voice and an SQL statement; then, after receiving the text or voice output by the query personnel, the SQL statement corresponding to the text or voice is determined according to the correspondence indicated by the annotated data. For example, the text or voice is input into the algorithm model containing the annotated data, and the algorithm model can output the corresponding SQL statement.

[0126] Slot filling, on the other hand, refers to the process of completing information to translate the queryer's intent into the corresponding instructions. Using this method, key parameters included in the queryer's text or voice input are identified through a syntax tree and dictionary. These key parameters are then filled into the corresponding slots, and the corresponding SQL statement is determined from the filled slots.

[0127] A syntax tree is a graphical representation of a sentence structure. Specifically, in this method, the content of the text or speech is matched with the dictionary to determine each word in the text or speech, each of which is the key parameter. The syntax tree is then used to determine the corresponding slot for each key parameter, and the key parameter is then filled into the corresponding slot.

[0128] However, both the deep learning method and the slot filling method have certain defects. Among them, the deep learning method has a strong dependence on annotated data. When using this method to convert the text or voice output by the query personnel, the pre-set annotated data needs to include the annotated data corresponding to the text or voice. However, with the development of information technology, the amount of data and the type of data stored in the database are increasing, and the query demand is increasing accordingly. In some cases, the pre-prepared annotated data often cannot fully include the SQL statements corresponding to the text or voice output by the query personnel, and cannot meet the query requirements of the query personnel. That is, the SQL statement cannot be determined through the deep learning method, and accordingly, the required data cannot be queried from the database.

[0129] In addition, the slot filling method has a strong dependence on syntax trees and dictionaries. As the database expands, the data in the database often involves multiple fields, which requires preparing and maintaining dictionaries and syntax trees under multiple fields. As a result, in some cases, the syntax trees and dictionaries may not be able to meet the query requirements of the query personnel. That is, the SQL statement cannot be determined through the slot filling method, and further, the required data cannot be queried from the database.

[0130] That is to say, through existing deep learning methods and slot filling methods, it is sometimes impossible to determine the SQL statement corresponding to the text or voice output by the query person, and further, it is impossible to query the required data from the database.

[0131] In order to solve the problem in the prior art that the corresponding SQL statement cannot be determined and thus the required data cannot be queried from the database, the present application discloses a data query method and device through the following embodiments.

[0132] The following will specifically describe the embodiments of the present application with reference to the accompanying drawings to clarify the data query method provided by the embodiments of the present application.

[0133] See also Figure 1 As shown in the workflow diagram, the data query method provided in the embodiment of the present application includes the following steps:

[0134] Step S11: Determine a knowledge graph of the database to be queried, where the knowledge graph is used to indicate the relationships between entities in the data model of the database.

[0135] Among them, knowledge graph technology is a technology that describes the relationship between things through a graphical model. Its essence is a semantic network that reveals the relationship between entities. Generally, a knowledge graph consists of multiple nodes. In the embodiment of the present application, the knowledge graph indicates the relationship between the entities of the database.

[0136] Step S12: Determine the structured query language SQL statement corresponding to the query information based on the knowledge graph.

[0137] The query information includes query text information and / or query voice information. The query information can represent the query person's intention to query data.

[0138] When the query personnel need to query the data in the database, they can input the query information through the input tool. For example, the query personnel can input the query text information through a mouse, a physical keyboard or a virtual keyboard, or the query personnel can also send out corresponding query voice information and collect the query voice information sent by the query personnel through a voice collection device (such as a microphone, etc.).

[0139] In the solution provided in the embodiment of the present application, after obtaining the query information, the various entities included in the query information can be determined, and then the query relationship between the various entities in the query information can be determined through the relationship between the various entities indicated by the knowledge graph, and then the SQL statement corresponding to the query information can be determined based on the various entities included in the query information and the query relationship between the various entities.

[0140] Step S13: Determine the query result corresponding to the SQL statement in the database.

[0141] In this step, the database is queried using the SQL statement corresponding to the query information to obtain query results corresponding to the query information in the database, thereby satisfying the query needs of the inquirer.

[0142] In the solution provided in the embodiment of the present application, the SQL statement corresponding to the query information is determined based on the knowledge graph of the database, and then the query result of the database is determined by the SQL statement. Compared with the prior art, the solution provided in the embodiment of the present application does not need to rely on labeled data, syntax trees and dictionaries, and even if the amount of data stored in the database and the type of data increase, the knowledge graph of the database can also reflect the relationship between the entities of the database, that is, even if the scale of the database expands, the SQL statement corresponding to the query information can still be determined through the knowledge graph, and further based on the SQL statement, the corresponding query result in the database is determined, thereby solving the problem that the SQL statement cannot be determined by the prior art, resulting in the inability to query the required data from the database.

[0143] In embodiments of the present application, the knowledge graph typically includes a concept layer and an instance layer. Furthermore, the data model includes a logical model and a physical model. Accordingly, the entities in the database data model include logical entities in the logical model and physical entities in the physical model. The concept layer indicates the relationship between at least one logical entity in the logical model, while the instance layer indicates the relationship between at least one physical entity in the physical model.

[0144] The logical entity refers to the entity described by the database's logical model, indicating the database's specific functions and processing information. For example, in a sales business, the entity information "Customer" includes attributes such as customer name and contact information. In this case, "Customer" can be considered a logical entity. The physical entity refers to the attributes of the entity indicated by the physical table. The physical entity describes the organizational structure of the data in the database on the storage medium. For example, in a sales business, the entity information "Customer" includes attributes such as customer name and contact person. In this case, "Customer Name" and "Contact Information" can be considered physical entities.

[0145] A database often includes multiple physical tables. For example, a database for a commercial application often includes multiple physical tables. In a feasible implementation provided in an embodiment of the present application, the physical entity of the database may include the titles of each row or column in the physical table of the database.

[0146] In a feasible solution provided in an embodiment of the present application, the logical entity of the database is the physical entity, or a logical entity of the database is a higher-level concept of at least one physical entity, that is, a logical entity can indicate the at least one physical entity.

[0147] For example, see Table 1:

[0148] Table 1 Sales volume of electronic products

[0149]

[0150] Table 1 is a physical table of electronic product sales data in a database. The column headings "Smartphone," "Computer," "Router," and "Switch" can be considered physical entities in the database. Furthermore, the values ​​in each row of Table 1 are attributes of the physical entity corresponding to that row. For example, the sales volume of smartphones in January 2020 is an attribute of the smartphone.

[0151] In addition, with respect to Table 1, the logical entities may include "smartphone," "computer," "router," and "switch." Alternatively, the logical entity may include a superordinate concept of the four physical entities "smartphone," "computer," "router," and "switch." This superordinate concept may be "electronic product." In this case, the logical entity "electronic product" may indicate the physical entities "smartphone," "computer," "router," and "switch." That is, one logical entity may indicate at least one physical entity.

[0152] Or, in another example, the database includes the physical tables shown in Table 2:

[0153] Table 2 Mobile phone sales

[0154]

[0155] Among them, Table 2 is a physical table of mobile phone sales data in the database. The title of each column (i.e., "P40", "P40Pro", "nova7" and "nova7 Pro") is a model of the mobile phone. In this case, "P40", "P40Pro", "nova7" and "nova7 Pro" can be regarded as physical entities of the database, and the value of each row in Table 2 is the attribute of the physical entity corresponding to the row. For example, the sales of P40 in January 2020 is an attribute of the smart P40.

[0156] In addition, with respect to Table 2, the logical entities may include "P40," "P40 Pro," "nova7," and "nova7 Pro." Alternatively, the logical entity may include a superordinate concept of the four physical entities "P40," "P40 Pro," "nova7," and "nova7 Pro." The superordinate concept may be "smartphone." In this case, the logical entity "smartphone" may indicate physical entities such as "P40," "P40 Pro," "nova7," and "nova7 Pro." Alternatively, the superordinate concept may be "electronic product." That is, the logical entity "electronic product" may indicate physical entities such as "P40," "P40 Pro," "nova7," and "nova7 Pro."

[0157] An enterprise often includes staff with multiple roles, such as frontline employees, department heads, and bosses. In this case, in another example, the physical entities of a database may include frontline employees, department heads, and bosses. In this case, the database may include the logical entity "Role," and the physical entities of frontline employees, department heads, and bosses correspond to the logical entity "Role."

[0158] In the embodiment of the present application, an operation of determining the knowledge graph of the database to be queried is disclosed. Figure 2 As shown in the workflow diagram, determining the knowledge graph of the database to be queried generally includes the following steps:

[0159] Step S111: Determine the at least one logical entity and the relationship between the at least one logical entity according to the logical model in the data model.

[0160] In the embodiments of the present application, the database data model includes a logical model. The database logical model can be in the form of a hierarchical model, a network model, or a relational model. Different logical models express the relationships between logical entities in different ways. A hierarchical model uses a "tree structure" to represent the relationships between different logical entities; a network model uses a "graph structure" to represent the relationships between different logical entities; and a relational model uses a "two-dimensional table" to represent the relationships between different logical entities.

[0161] In the solutions provided in the embodiments of the present application, the database logical model is used to represent the logical structure and relationships of the database's logical entities. Specifically, the database logical model includes the database's logical entities and indicates the relationships between them. Therefore, the logical model enables the identification of at least one logical entity and the relationships between the at least one logical entity.

[0162] In an embodiment of the present application, a logical model of the database may be pre-set. In this case, the logical entities of the database and the relationships between the logical entities may be determined through the logical model.

[0163] In addition, the database usually includes at least one physical table, which contains physical entities, and there are cross-references between some physical tables. In this case, the relationship between the at least one logical entity can also be determined based on the physical entities contained in the physical table with the cross-reference relationship.

[0164] In one feasible solution, a mapping relationship between physical entities and logical entities can be pre-set. For example, the logical entity corresponding to the four physical entities "smartphone," "computer," "router," and "switch" can be set to "electronic product." In this case, the relationship between the at least one logical entity can be determined through the following steps: first, a target physical entity included in a physical table with a cross-reference relationship is determined; based on the mapping relationship between the physical entity and the logical entity, the target logical entity corresponding to the target physical entity in the mapping relationship is determined; and then, the existence of a corresponding relationship between the target logical entities can be determined.

[0165] Furthermore, if the data in the database involves data related to financial accounting, accounting standards can be considered as a logical entity when defining the database's conceptual layer and added to the conceptual layer. Accounting standards are the basic principles that accountants must follow when performing their work and serve as the norms for accounting work.

[0166] Furthermore, in the conceptual layer, the logical entity of accounting standards is usually associated with the logical entities related to financial accounting in the conceptual layer.

[0167] Step S112: Determine the concept layer according to the at least one logical entity and the relationship between the at least one logical entity.

[0168] Furthermore, in the embodiment of the present application, different roles often have different query requirements. Therefore, in the conceptual layer, a role is added as a logical entity with query permissions for other logical entities.

[0169] For example, in order to clarify the concept layer determined by the solution provided by the embodiment of the present application, the embodiment of the present application also provides Figure 3(a) to Figure 3(d) .

[0170] FIG3(a) is a schematic diagram illustrating an example of cross-reference relationships between physical tables included in the database. The diagram illustrates a physical table for profit included in the database, wherein the physical entities in the physical table include sales, gross profit, operating profit, pre-tax profit, and net profit. Sales are correlated with the sales growth rate and gross profit margin in other physical tables, and the sales growth rate is correlated with the unit price growth rate and sales volume growth rate in other physical tables. Therefore, a cross-reference relationship exists between the physical table containing sales and the physical table containing the sales growth rate and gross profit margin, and the physical table containing sales also has a cross-reference relationship with the physical table containing the unit price growth rate and sales volume growth rate. Furthermore, gross profit is correlated with the expense rate in other physical tables, and the expense rate is correlated with sales expenses, administrative expenses, and other operating expenses in other physical tables. Therefore, a cross-reference relationship exists between the physical table containing gross profit and the physical table containing the expense rate, and the physical table containing gross profit also has a cross-reference relationship with the physical table containing sales expenses, administrative expenses, and other operating expenses.

[0171] In this case, it can be determined that the conceptual entity corresponding to the physical entity sales has a relationship with the conceptual entities corresponding to the two physical entities sales growth rate and gross profit margin, or that the three physical entities sales, sales growth rate, and gross profit margin correspond to the same conceptual entity. Furthermore, it can be determined that the conceptual entity corresponding to the physical entity gross profit has a relationship with the conceptual entity corresponding to the physical entity expense rate, or that the three physical entities gross profit and expense rate correspond to the same conceptual entity. It can also be determined that the conceptual entity corresponding to the physical entity gross profit has a relationship with the conceptual entities corresponding to the three physical entities sales expenses, administrative expenses, and other operating expenses, or that the four physical entities gross profit, sales expenses, administrative expenses, and other operating expenses correspond to the same conceptual entity.

[0172] FIG3( b ) is a schematic diagram of an example of the data query requirements of each role. According to FIG3( b ), it can be determined that different roles have different data query requirements.

[0173] In the example shown in Figure 3(b), the roles include frontline employees, business leaders, the company's owner, CEO, and senior executives. Frontline employees are typically oriented toward business details, primarily responsible for their own business, and focused on their own performance and business details. Business leaders are primarily oriented toward the production process, responsible for specific business operations, and focused on the business dashboard. Specifically, they focus on profit growth curves, sales funnels, business anomalies, and key performance indicators (KPIs) related to the employees in their department. The company's owner, CEO, and senior executives are primarily oriented toward production results, responsible for the company's long-term development, and focused on the strategic dashboard. Specifically, they focus on core indicators and the gap between the company's goals and current status. In other words, different roles have different focuses.

[0174] In this case, it can be determined that the company's boss, CEO, and senior executives have the highest query permissions and can query all data in the company's database, while business leaders have intermediate query permissions and can query content they are concerned about, as well as the performance and business details of front-line business employees. Front-line business employees have the lowest query permissions and can only query their own performance and business details.

[0175] FIG3( c ) is a schematic diagram of an example of a logical model of the database.

[0176] The logical model indicates that the logical entity "item" has relationships with the three logical entities "sales item", "date" and "sales area". Among them, the logical entity "sales item" corresponds to physical entities such as "item name", "category" and "subcategory", the logical entity "date" corresponds to physical entities such as "year-month-day", "week" and "holiday", and the logical entity "sales area" corresponds to physical entities including "store name", "city" and "country".

[0177] FIG3(d) is a schematic diagram of an example of a concept layer provided in an embodiment of the present application. This concept layer includes logical entities such as "business rules," "business processes," "management regulations," "business activities," "accounting," "accounting standards," "management accounting," "accounting plans," "allocation rules," "settlement rules," "physical table items," "solutions," "subject areas," "roles," "dimensions," and "employees." In FIG3(d), the lines between the logical entities indicate the relationships between them.

[0178] Step S113: Determine the at least one physical entity and the relationship between the at least one physical entity according to the physical model in the data model.

[0179] In the solution provided in the embodiments of the present application, a physical model of the database may be provided. The physical model of the database is used to characterize the relationships between the various physical entities of the database. That is, the physical model of the database includes the physical entities of the database, and the physical model can indicate the relationships between the various physical entities.

[0180] Therefore, in the above steps, at least one physical entity of the data and the relationship between the at least one physical entity can be determined through the physical model of the database.

[0181] In addition, the database often includes at least one physical table, which includes physical entities. Therefore, in the embodiment of the present application, it can also be determined that there is a relationship between the physical entities included in the same physical table.

[0182] Step S114: Determine the instance layer according to the at least one physical entity and the relationship between the at least one physical entity.

[0183] Furthermore, in the solution provided in the embodiment of the present application, query permissions of the physical entity corresponding to each role and other physical entities can also be set.

[0184] As can be seen from the example shown in Figure 3(b), different roles have different query requirements. In the solution provided in the embodiments of this application, different roles' data query requirements can be set. These requirements can be expressed in the form of a graph or table, for example, the table shown in Figure 3(b). Then, based on these requirements, query permissions for different roles to query data are added in the concept layer.

[0185] For example, a role is a frontline employee who is responsible for assembling a certain product. In this case, the frontline employee can be given query permissions for the product that he or she is responsible for distributing. In addition, in the instance layer, the physical entity of the frontline employee is connected to the product to indicate that the frontline employee can query relevant information about the product.

[0186] For example, in order to clarify the instance layer determined by the solution provided in the embodiment of the present application, the embodiment of the present application also provides Figures 4(a), 4(b) and 4(c).

[0187] Figure 4(a) is a schematic diagram of an example physical model, and Figure 4(b) shows an example physical table in a database. In the database examples corresponding to Figures 4(a) and 4(b), the physical entities in the database include: time, region, user, product, and sales.

[0188] In the example physical model shown in Figure 4(a), for the physical table "Goods Sales" in the database, the physical entities include time, region, user, product, and sales. The attributes of the time entity include year, month, and day; the attributes of the region entity include province, city, and county; the attributes of the user entity include user type, user name, and user ID; the attributes of the product entity include product type and product ID; and the attributes of the sales entity include payment ID and payment method. Furthermore, the physical entities of time, region, user, product, and sales have relationships.

[0189] Correspondingly, the physical table shown in Figure 4(b) also includes physical entities such as time, region, user, product, and sales. In this case, it can usually be determined that there is a relationship between the physical entities in the same physical table.

[0190] In addition, Figure 4(c) is a schematic diagram of an example of the instance layer provided in this application. This example indicates that the physical entity "XX employee" has query permission on the physical entity "XX product", and "XX employee" is the "XX role" in the enterprise, and the "XX role" can be a front-line business employee, business leader, boss, CEO, or senior executive, etc. In addition, this example also indicates that the queryable dimension of "XX product" includes the physical entity "profit and loss theme", and the "profit and loss theme" includes the indicator "sales", and "XX role" has query permission on the "profit and loss theme" of "XX product".

[0191] Steps S111 and S112 above provide a solution for determining the conceptual layer of a database, and steps S113 and S114 provide a solution for determining the instance layer of the database. Furthermore, in embodiments of the present application, the steps of determining the conceptual layer and the instance layer can be performed simultaneously, or the instance layer of the database can be determined first, followed by the conceptual layer of the database. This embodiment of the present application is not limited to this.

[0192] In the solution provided in the embodiment of the present application, an operation of determining the structured query language SQL statement corresponding to the query information is included according to the knowledge graph. Figure 5 As shown in the workflow diagram, determining the structured query language SQL statement corresponding to the query information based on the knowledge graph generally includes the following steps:

[0193] Step S121: Determine the query terms included in the query information.

[0194] The query information generally includes at least one query term. For example, if the query information is "income of Guangzhou office in last quarter", the query terms include: Guangzhou office, last quarter and income.

[0195] In this step, if the query information is a voice query information, the voice query information is converted into corresponding query text information, and then the query text information is processed to split the query text information into corresponding query terms, thereby obtaining the corresponding query terms. The process of splitting the query text information to obtain query terms can be called text segmentation processing.

[0196] Step S122: Determine the first logical entity corresponding to the query term in the concept layer.

[0197] The concept layer includes multiple logical entities, and the concept layer can indicate the relationship between the logical entities. In the embodiment of the present application, after obtaining the query term, the first logical entity corresponding to the query term can be determined by querying the concept layer.

[0198] For example, if the concept layer provided by the embodiment of the present application is as shown in FIG3(d), and the query term includes "income", the first logical entity corresponding to the query term may include accounting schemes, management accounting, and settlement rules.

[0199] Specifically, in a feasible implementation scheme provided in an embodiment of the present application, a mapping relationship is set between different query terms and logical entities. In this case, based on the mapping relationship and the query terms included in the query information, the target logical entity corresponding to the query terms can be determined, and then the target logical entity existing in the concept layer is determined to be the first logical entity.

[0200] In the above steps, the determined first logical entities include at least one. If the first logical entities include two or more, each first logical entity is generally a logical entity with a relationship in the concept layer, wherein the logical entity with a relationship refers to a logical entity connected in the concept layer.

[0201] Step S123: Determine first physical entities corresponding to the first logical entities and the query terms, and determine a query relationship between the first physical entities.

[0202] In the solution provided in the embodiments of the present application, a logical entity generally corresponds to at least one physical entity. Step S123 determines at least one physical entity corresponding to the first logical entity (i.e., the first physical entity). For example, if the first logical entity includes an accounting plan, management accounting, and settlement rules, the first physical entity generally includes: products, product sales, product material costs, product service costs, and product losses.

[0203] A logical entity often corresponds to one or more physical entities. Therefore, in the above steps, each first logical entity corresponds to at least one first physical entity.

[0204] In the solution provided in the embodiments of the present application, a mapping relationship between logical entities and physical entities may be provided. In this case, based on the first logical entity and the mapping relationship, the physical entities corresponding to the first logical entity may be determined. Then, among the physical entities corresponding to the first logical entity, the first physical entity corresponding to the query term may be determined. The first physical entity corresponding to the query term generally refers to a physical entity having the same meaning as the first physical entity.

[0205] In addition, in the embodiment of the present application, the query relationship generally refers to a logical relationship between physical entities, such as a logical relationship such as AND, OR, and NOT.

[0206] The query information often includes multiple query terms, some of which correspond to physical entities. In addition, other query terms in the query information can also represent the query relationship between physical entities. For example, in the query information "Revenue of Department A and Department B in 2019", "Department A", "Department B", and "2019" correspond to different physical entities respectively, and the query term "and" can represent the query relationship between "Department A" and "Department B". Therefore, in an embodiment of the present application, the query relationship between the first physical entities can also be determined.

[0207] Specifically, in an embodiment of the present application, a correspondence between each query term and the query relationship may be set. In this case, the query relationship between the first physical entities may be determined based on the correspondence.

[0208] Step S124: Determine the SQL field corresponding to the first physical entity, and determine a corresponding SQL statement based on the SQL field and the query relationship.

[0209] Each physical entity corresponds to an SQL field. In the solution provided in the embodiment of the present application, after determining the SQL field corresponding to the first physical entity, the SQL fields can be spliced ​​according to the query relationship between the first physical entities to obtain the corresponding SQL statement, which is the SQL statement corresponding to the query information.

[0210] In steps S121 to S124 of the embodiment of the present application, a solution is provided for determining an SQL statement corresponding to query information based on a knowledge graph. In this solution, the query information is split to determine the query terms included in the query information, and then the first logical entity corresponding to the query term is determined. Then, the first physical entity corresponding to the first logical entity is determined, and the SQL fields corresponding to the first physical entity are concatenated into a corresponding SQL statement, thereby obtaining the SQL statement corresponding to the query information.

[0211] Databases typically store a large amount of data, and therefore, a database often contains a large number of physical entities. Directly querying the physical entities corresponding to each query term often requires numerous queries, which consumes a significant amount of query time. In the solution provided in the embodiments of the present application, the first logical entity corresponding to the query term is first determined, and then the first physical entity corresponding to the first logical entity is determined. This narrows the scope of the first physical entities to be queried through the first logical entity, reduces the number of query operations required to determine the first physical entity corresponding to the query term, and increases the speed of determining the first physical entity. Furthermore, this improves the efficiency of determining the SQL statement.

[0212] Furthermore, the solution disclosed in the embodiments of the present application also includes the following operations:

[0213] The general knowledge corresponding to the database is determined.

[0214] The conventional knowledge includes at least one of the following: abbreviations of query terms, synonyms of the query terms, near-synonyms of the query terms, query information examples, and query triples.

[0215] In this case, in the embodiment of the present application, the following steps may also be included:

[0216] After determining the query terms included in the query information, the query terms are converted according to conventional knowledge corresponding to the database.

[0217] Accordingly, in the solution provided in the embodiment of the present application, determining the structured query language SQL statement corresponding to the query information includes the following operations:

[0218] The SQL statement corresponding to the query information is determined based on the converted query terms.

[0219] That is to say, in the solution provided in the embodiment of the present application, the general knowledge corresponding to the database will also be determined, and the acquired query terms will be converted according to the general knowledge, and the corresponding SQL statements will be determined based on the converted query terms, thereby improving the accuracy of determining the SQL statements.

[0220] The conventional knowledge includes at least one of the following: the abbreviation and full name of the query term, the synonyms of the query term, the antonyms of the query term, and query information examples.

[0221] When query personnel output query information, in some cases, they will output some relatively brief names, resulting in the query terms included in the query information being the abbreviations of the query terms. For example, "this quarter" and "current quarter" are the abbreviations of "this quarter" and "current quarter", and "this quarter" and "current quarter" are the full names of "this quarter" and "current quarter".

[0222] If the conventional knowledge includes the abbreviation and full name of the query term, and the query information contains the abbreviation of the query term, in order to improve the accuracy of determining the SQL statement of the query information, in an embodiment of the present application, the query term contained in the query information can be converted into the corresponding full name based on the conventional knowledge, so that the SQL statement corresponding to the query information can be subsequently determined based on the converted full name, thereby improving the accuracy of determining the SQL statement.

[0223] In addition, the same meaning can be expressed by different words. Accordingly, the same query intent can also be expressed by query information in different forms. The query information in different forms includes synonyms or near-synonyms of the query terms.

[0224] For example, the three query information "Completion rate of Project A in January 2020", "Achievement status of Project A in January 2020" and "Completion status of Project A in January 2020" indicate the same query intention, all indicating that the inquirer hopes to inquire about the completion status of Project A in January 2020. Among them, "completion rate", "achievement status" and "completion status" are synonyms or near-synonyms.

[0225] Or, in another example, "Beijing", "capital" and "imperial capital" are also synonyms.

[0226] However, the knowledge graph of the database often only contains physical entities corresponding to one of the meanings. In this case, in order to improve the accuracy of the SQL statement for determining the query information, in the conventional knowledge provided in the embodiment of the present application, if synonyms or near-synonyms of the query term are included, the query term can be converted according to the physical entity of the database. Typically, during the conversion process, the physical entities included in the physical table of the database are first determined. If the query term is a synonym for a physical entity included in the physical table, the query term can be converted into the physical entity based on the synonyms included in the conventional knowledge. The first logical entity and the first physical entity are determined in sequence based on the converted query term, and then the corresponding SQL statement is determined.

[0227] For example, the physical entity "completion rate" is included in the physical table of the database, and the query information includes the query term "completion status". According to the synonyms and / or near-synonyms of the query term contained in the conventional knowledge, it can be known that "completion status" and "completion rate" are synonyms. The query term "completion status" is converted into "completion rate", and then the SQL statement corresponding to the converted query term (i.e., "completion rate") is determined.

[0228] In addition, the same query intent can be expressed through query information in different forms. In an embodiment of the present application, at least one query information example can also be provided. In a query information example, at least two query information may be included, and the at least two query information represent the same query intent. Therefore, the SQL statements corresponding to the at least two query information included in a query information example are the same. In this case, if the query information obtained is one of the query information in the query information example, the query information can be converted into other query information in the query information example, and the corresponding SQL statement can be determined based on the converted query information.

[0229] For example, let's assume "XX" represents a certain indicator. A query might include three queries: "What is the forecast completion rate for XX this quarter?", "What is the forecast completion status for XX this quarter?", and "What is the forecast achievement status for XX this quarter?" These three queries represent the same query intent, and therefore correspond to the same SQL statement. After obtaining one query, the corresponding SQL statement can be determined based on the other two queries.

[0230] In addition, the conventional knowledge may also include triples of physical entity relationships in the database. The triples may be subject-predicate-object (SPO) triples. Such triples are typically used to represent relationships between entities. In the solution provided in the embodiments of the present application, the triples in the database may be used to represent relationships between different physical entities in the database, and typically one triple may represent one query intent.

[0231] For example, a triple is (this quarter, predicted completion rate, XX indicator), which is used to represent the query intent of "the predicted completion rate of XX indicator this quarter".

[0232] In the solution provided in the embodiment of the present application, at least one triple can be set and a SQL statement corresponding to the triple can be set. In this case, after obtaining the query information, the query information can be converted into a triple corresponding to the query information, and then the corresponding SQL statement can be determined through the converted triple.

[0233] Of course, the database may also include other forms of conventional knowledge, which is not limited in the embodiments of the present application. In addition, in the solution provided in the embodiments of the present application, the conventional knowledge corresponding to the database may be predetermined, and the conventional knowledge may be updated during the expansion or update of the database to meet the needs of data query.

[0234] Furthermore, when determining the conventional knowledge corresponding to the database, the professional field in which the database is located can also be determined, and the conventional knowledge corresponding to the domain knowledge and expert experience in the professional field can be determined. In this case, the conventional knowledge corresponding to the database can also be integrated with the domain knowledge and expert experience in the professional field in which the database is located.

[0235] Illustratively, in the solution provided in the embodiment of the present application, the abbreviation and full name of the query term can be determined based on the domain knowledge within the professional field, and the determined abbreviation of the query term can be used as the general knowledge corresponding to the database, so that the general knowledge can include the abbreviation and full name of the query term within the professional field.

[0236] In addition, the conventional knowledge corresponding to the database can be in various forms. For example, the conventional knowledge corresponding to the database can be in the form of a report, or the conventional knowledge corresponding to the database can be represented in the form of a causal graph, and the causal graph can be integrated with the knowledge graph. Alternatively, the conventional knowledge corresponding to the database can also be in other forms, which are not limited in the embodiments of the present application.

[0237] In existing deep learning solutions, the SQL statements corresponding to query information are determined using labeled data. Each labeled data point typically indicates the correspondence between a piece of query information and a SQL statement. In this case, determining the SQL statement corresponding to the query information using the labeled data often fails to take into account conventional knowledge about the database.

[0238] In addition, the slot filling method relies on syntax trees and dictionaries to determine key parameters in the query information, but syntax trees and dictionaries often cannot reflect the domain knowledge and expert experience of the database's professional field. Therefore, when determining SQL statements through the slot filling method, the general knowledge corresponding to the database cannot be taken into account.

[0239] For example, if the query information is "the forecast completion rate of XX in this quarter", and in the deep learning method, the set annotation data is the correspondence between "the forecast achievement status of XX in this quarter" and the SQL statement, then the SQL statement corresponding to the query information cannot be determined based on the annotation data.

[0240] In the solution provided in the embodiment of the present application, the query information can be converted according to the conventional knowledge corresponding to the database, and then the SQL statement can be determined according to the converted query information, that is, data query can be realized in combination with the conventional knowledge corresponding to the database.

[0241] The general knowledge corresponding to the database can be determined through the domain knowledge and expert experience of the professional field of the database. Therefore, when performing data query through the solution provided by the embodiment of the present application, the domain knowledge and expert experience of the professional field of the database can also be taken into account. Compared with the existing technology, the solution provided by the embodiment of the present application can improve the accuracy of determining SQL statements and further improve the accuracy of data query.

[0242] Furthermore, the solution provided in the embodiment of the present invention further includes the following steps:

[0243] If a first query term in the query terms corresponds to at least two physical entities, after determining the query terms included in the query information, determining relationships between the at least two physical entities and other query terms respectively;

[0244] According to the query authority of the inputter of the query information and / or the content contained in the database, a first target relationship that can be queried by the inputter is determined among the relationships.

[0245] When querying a database based on query information, a query term included in the query information may simultaneously correspond to at least two physical entities, i.e., a query term may have at least two meanings. In this embodiment of the present application, a query term corresponding to at least two physical entities is defined as a first query term. Furthermore, among the query terms corresponding to the query information, query terms other than the first query term may be defined as second query terms, i.e., the second query term corresponds to only one physical entity.

[0246] For example, if the query information is "Guangzhou office's revenue last quarter," the query information includes the query terms "Guangzhou office," "last quarter," and "revenue." In the database corresponding to this example, the query term "Guangzhou office" corresponds to two physical entities: Guangzhou office (department) and Guangzhou office (regional organization). Therefore, the query term "Guangzhou office" has two meanings and is the first query term. Furthermore, both the query terms "last quarter" and "revenue" correspond to one physical entity, and therefore, both are second query terms.

[0247] Then, in this example, relationships are established between the first query term and other query terms, including "Guangzhou Office (Department)" - "Last Quarter" - "Revenue," and "Guangzhou Office (Regional Organization)" - "Last Quarter" - "Revenue." If the query permission of the person inputting the query information indicates that the person can only query the revenue of the Guangzhou Office (Department) in the last quarter, then the first target relationship is the first relationship described above; alternatively, if the database does not contain the first relationship described above, then the first target relationship is the second relationship described above. The first target relationship is the relationship that the person inputting the query information can query.

[0248] In this case, in the embodiment of the present application, determining the SQL field corresponding to the first physical entity includes the following operations:

[0249] Determining the first physical entity indicated by the first target relationship as a first target physical entity;

[0250] The SQL field corresponding to the first target physical entity is determined, so as to determine the SQL statement corresponding to the query information according to the SQL field corresponding to the first target physical entity, thereby implementing a query on the database.

[0251] For example, if the first target relationship is "Guangzhou Office (Department)" - "Last Quarter" - "Revenue", then the first target physical entity is Guangzhou Office (Department), Last Quarter and Revenue. In this case, the corresponding SQL field is determined based on the first target physical entity, and then the SQL statement corresponding to the query information is determined by splicing the SQL fields.

[0252] If the first query term in the query terms corresponds to at least two physical entities, this indicates that the query information used to query the database is ambiguous. In order to determine the true query intent of the person entering the query information, the query information needs to be processed to disambiguate. Through the above embodiment, ambiguity can be eliminated based on the relationship between the at least two physical entities corresponding to the first query term and other query terms, as well as the query permissions of the person entering the query information and / or the content contained in the database. This allows data queries to be performed based on the true query intent of the person entering the query information, thereby improving the accuracy of data queries.

[0253] In addition, in the embodiments of the present application, other methods can be used to eliminate ambiguity in query information. Figure 6 As shown in the workflow diagram, the embodiment of the present application may further include the following steps:

[0254] Step S31: If the first query term in the query terms corresponds to at least two physical entities, after determining the query terms included in the query information, determine a first relationship set consisting of relationships between the at least two physical entities and other physical entities in the database.

[0255] The first relationship set includes the relationships between the at least two physical entities and other physical entities in the database. For example, if the query information is "Guangzhou Office's revenue last quarter", the query information includes the query terms "Guangzhou Office", "last quarter", and "revenue". In the database corresponding to this example, the query term "Guangzhou Office" corresponds to the two physical entities Guangzhou Office (Department) and Guangzhou Office (Regional Organization). Therefore, the query term "Guangzhou Office" has two meanings and is the first query term.

[0256] In addition, after determining the first query term, it is necessary to determine a first relationship set in the database for the at least two physical entities corresponding to the first query term based on the physical entities included in the database. In the database corresponding to this example, the subordinate of the physical entity "Guangzhou Office (Regional Organization)" is "Guangzhou Office (Department)", so the first relationship set may include the following relationships:

[0257] Relationship 1: "Guangzhou Office (Regional Organization)" - "Guangzhou Office (Department)" - "Net Sales Revenue" - "Revenue";

[0258] Relationship 2: "Guangzhou Office (Department)" - "Net Sales Revenue" - "Revenue".

[0259] Step S32: According to the query authority of the inputter of the query information, a second relationship set consisting of relationships that the inputter can query in the first relationship set is determined.

[0260] That is, the relationships included in the second relationship set are relationships that can be queried according to the query authority of the inputter.

[0261] Step S33: Determine the quantized length of at least one relation included in the second relation set.

[0262] Among them, the quantized length of a relationship usually refers to the value obtained after quantizing the length of the relationship. The quantized length of a relationship usually refers to the number of physical entities included in the relationship. For example, the quantized length of the above-mentioned relationship 1 is 4, and the quantized length of relationship 2 is 3.

[0263] Step S34: Determine a second target relationship according to the quantization length.

[0264] In one feasible implementation, the second target relation is the relation with the smallest length quantization length in the second relation set. For example, if the second relation set includes only the aforementioned relations 1 and 2, and the length quantization length of the aforementioned relation 2 is smaller than the length quantization length of relation 1, then the second target relation is relation 2.

[0265] Alternatively, in a feasible implementation method, if the weight information of a physical entity corresponding to the first query term is set, the product of the quantized length of the relationship corresponding to the physical entity and the weight can also be determined, and the product is compared with the quantized lengths of other relationships to determine the relationship corresponding to the minimum value as the second target relationship.

[0266] For example, the second relationship set is set to include relationship 1 and relationship 2, and the weight corresponding to the physical entity Guangzhou Office (regional organization) in relationship 1 is 0.6. Then the product of the length quantization length of relationship 1 and the weight is 0.6*4=2.4, and the length quantization length of relationship 2 is 3, that is, the product of the length quantization length of relationship 1 and the weight is less than the length quantization length of relationship 2, and relationship 1 is the second target relationship.

[0267] In addition, after determining the second target relationship, in the solution disclosed in the embodiment of the present application, determining the SQL field corresponding to the first physical entity may include the following steps:

[0268] Determining the first physical entity indicated by the second target relationship as the second target physical entity;

[0269] Determine the SQL field corresponding to the second target physical entity.

[0270] If the first query term in the query terms corresponds to at least two physical entities, through the above embodiment, the true query intention of the person who inputs the query information can be determined based on the first relationship set of the at least two physical entities corresponding to the first query term in the database, and ambiguity can be eliminated, and data query can be performed based on the true query intention of the person who inputs the query information, thereby improving the accuracy of the data query.

[0271] Furthermore, the solution disclosed in the embodiments of the present application may further include the following steps:

[0272] Determining a third correspondence between the historical query information and the historical query results based on the first correspondence between the historical query information and the historical SQL statements, and the second correspondence between the historical SQL statements and the historical query results;

[0273] If the current query information belongs to the historical query information, the query result corresponding to the current query information is determined according to the third corresponding relationship.

[0274] In actual applications, a query operator may query the database multiple times and determine a corresponding SQL statement during the query process, so as to determine the corresponding query result based on the SQL statement. In this case, the query information of the query operator when previously querying the database can be used as historical query information, and the SQL statement corresponding to the historical query information is the historical SQL statement. A first correspondence between the historical query information and the historical SQL statement can be determined.

[0275] In addition, when a query is performed using the historical SQL statement, a corresponding query result, i.e., the historical query result, is obtained. In this case, a second correspondence between the historical SQL statement and the historical query result can also be determined. Further, a third correspondence between the historical query information and the historical query result can be determined based on the first correspondence and the second correspondence.

[0276] In this case, if the current query information belongs to the historical query information, the query result corresponding to the current query information can be directly determined based on the third correspondence, thereby improving query efficiency. Furthermore, when determining the query result through this solution, there is no need to rely on the knowledge graph. Therefore, even if the device running the knowledge graph is in the process of cold start, the query result can still be obtained to meet the database query requirements.

[0277] The query information of this time belongs to the historical query information, which may include the following two situations:

[0278] In the first case, if the current query information is the same as the historical query information, then the current query information can be determined to belong to the historical query information. Alternatively, if the historical query information includes multiple pieces of information and the current query information is the same as one of the pieces of information, then the current query information can be determined to belong to the historical query information.

[0279] The second situation: If the solution provided in the embodiment of the present application is provided with conventional knowledge of the database, the current query information is converted according to the conventional knowledge. If the current query information meets the first situation mentioned above after the conversion, that is, the current query information is the same as a historical query information after the conversion, then it is determined that the current query information belongs to the historical query information.

[0280] For example, if the current query information is: "The sales volume of model A mobile phones in this quarter", and the historical query information includes: "The sales volume of model A mobile phones in the current quarter", after converting the current query information through conventional knowledge, it can be known that the current query information is the same as the historical query information after conversion, then it can be determined that the current query information belongs to the historical query information.

[0281] The query results determined by the SQL statement include one or more. If the query results include multiple results, in the embodiment of the present application, the display order of the query results can be determined by the display rules of the query results, and the query results can be displayed in sequence according to the display order. In this case, the solution disclosed in the embodiment of the present application can also include the following steps:

[0282] Determining display rules for the query results;

[0283] After determining the query result corresponding to the SQL statement in the database, the query result is displayed according to the display rule.

[0284] The display rules are usually used to indicate the sorting order of each data contained in the database. Through this solution, the query results can be displayed according to the order indicated by the display rules, meeting the query result viewing needs of the query personnel.

[0285] For example, a database includes sales of various models of mobile phones in different time periods, and the display rules are used to indicate the priority of each model. In this case, if the query information is "sales of model A and model B mobile phones in 2019", and the display rules indicate that model A has a higher priority than model B, then in the displayed query results, the sales of model A mobile phone will be ranked before the sales of model B mobile phone.

[0286] In the solution provided in the embodiment of the present application, the display rules can be pre-set. In addition, during the application of the database, the query personnel can adjust them according to their own needs to make the display effect of the query results meet their own needs.

[0287] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0288] Corresponding to the above method embodiment, the present application embodiment discloses a data query device, see Figure 7 As shown in the structural diagram, the data query device includes: a graph determination module 100, a statement determination module 200 and a first query module 300.

[0289] The graph determination module 100 is used to determine a knowledge graph of a database to be queried, wherein the knowledge graph is used to indicate the relationship between entities in a data model of the database;

[0290] The statement determination module 200 is used to determine the structured query language SQL statement corresponding to the query information based on the knowledge graph, and the query information includes: query text information and / or query voice information;

[0291] The first query module 300 is used to determine the query result corresponding to the SQL statement in the database.

[0292] When the data query device provided in the embodiment of the present application queries a database, the graph determination module 100 first determines the knowledge graph of the database to be queried, and then the statement determination module 200 determines the SQL statement corresponding to the query information based on the knowledge graph, and then the first query module 300 determines the query result corresponding to the SQL statement in the database to realize the database query.

[0293] Compared with the prior art, the solution provided by the embodiment of the present application does not need to rely on labeled data, syntax trees and dictionaries, and even if the amount of data stored in the database and the type of data increase, the knowledge graph of the database can still reflect the relationship between the entities of the database. That is, even if the scale of the database expands, the SQL statement corresponding to the query information can still be determined through the knowledge graph, and further based on the SQL statement, the corresponding query result in the database can be determined, thereby solving the problem that the SQL statement cannot be determined by the prior art, resulting in the inability to query the required data from the database.

[0294] In addition, the data query device provided in the embodiment of the present application realizes the query of the database through the knowledge graph. In the actual data query process, the data query device provided in the embodiment of the present application can be combined with the data query device applicable in the prior art.

[0295] If the data query device used in prior art applications can determine the query result corresponding to the query information, then both the data query device provided by the embodiments of the present application and the data query device used in prior art applications can determine the query result corresponding to the query information and display it to the querying person. However, if the data query device used in prior art applications cannot determine the query result corresponding to the query information, the device provided in the embodiments of the present application can be used to perform data query, thereby avoiding the problem of being unable to obtain query results.

[0296] For example, the embodiments of the present application provide Figure 8 , Figure 8 This is a schematic diagram combining an existing data query device with the query device provided by an embodiment of the present application. In the example corresponding to this schematic diagram, the data query device used in the prior art includes: a deep learning device and a slot-filling device. The deep learning device applies prior art deep learning technology to perform data queries, and the slot-filling device applies prior art slot-filling technology to perform data queries. Furthermore, both the deep learning device and the slot-filling device, along with the data query device of the present application, can obtain query information and perform data queries.

[0297] Since the deep learning device performs data queries using annotated data, if the annotated data set by the deep learning device does not contain the correspondence between the query information of this query and the SQL statement, the query result cannot be obtained. In addition, the slot filling device determines the query result using the syntax tree and dictionary. If the syntax tree and dictionary cannot meet the requirements of this data query, the slot filling device cannot obtain the query result. In this case, the query result can also be determined by the data query device of the present application, thereby avoiding the problem of being unable to query.

[0298] In the solution provided in the embodiment of the present application, the knowledge graph includes: a concept layer and an instance layer;

[0299] The data model includes: a logical model and a physical model;

[0300] The entities in the data model of the database include: logical entities in the logical model and physical entities in the physical model;

[0301] The concept layer is used to indicate the relationship between at least one logical entity in the logical model;

[0302] The instance layer is used to indicate the relationship between at least one physical entity in the physical model.

[0303] The graph determination module is used to determine the at least one logical entity and the relationship between the at least one logical entity based on the logical model in the data model, determine the conceptual layer based on the at least one logical entity and the relationship between the at least one logical entity, determine the at least one physical entity and the relationship between the at least one physical entity based on the physical model in the data model, and determine the instance layer based on the at least one physical entity and the relationship between the at least one physical entity.

[0304] Through the graph determination module, a knowledge graph including a concept layer and an instance layer can be determined, so that based on the knowledge graph, the relationship between the logical entities of the database and the relationship between the physical entities of the database can be determined.

[0305] Among them, in the solution provided in the embodiment of the present application, the statement determination module is used to determine the query terms included in the query information; determine the first logical entity corresponding to the query terms in the conceptual layer, determine the first physical entity corresponding to the first logical entity and the query terms, and determine the query relationship between the first physical entities, determine the SQL field corresponding to the first physical entity, and determine the corresponding SQL statement based on the SQL field and the query relationship.

[0306] That is to say, the statement determination module can determine the SQL statement corresponding to the query information based on the knowledge graph, so as to query the database through the SQL statement.

[0307] Furthermore, the data query device provided in the embodiment of the present application further includes:

[0308] A general knowledge determination module, configured to determine the general knowledge corresponding to the database;

[0309] The conventional knowledge includes at least one of the following: the abbreviation and full name of the query term, the synonyms of the query term, the antonyms of the query term, and query information examples.

[0310] In this case, the apparatus provided in the embodiment of the present application further includes:

[0311] a conversion module, configured to convert the query terms included in the query information according to conventional knowledge corresponding to the database after determining the query terms included in the query information;

[0312] The statement determination module is specifically used to determine the SQL statement corresponding to the query information according to the converted query terms.

[0313] The general knowledge corresponding to the database can be determined through the domain knowledge and expert experience of the professional field of the database. Therefore, when performing data query through the solution provided by the embodiment of the present application, the domain knowledge and expert experience of the professional field of the database can also be taken into account. Compared with the existing technology, the solution provided by the embodiment of the present application can improve the accuracy of determining SQL statements and further improve the accuracy of data query.

[0314] Furthermore, the device provided in the embodiment of the present application further includes:

[0315] a first relationship determination module;

[0316] If a first query term in the query terms corresponds to at least two physical entities, the first relationship determination module is configured to, after determining the query terms included in the query information, determine the relationships between the at least two physical entities and other query terms, and determine, based on the query authority of the inputter of the query information and / or the content contained in the database, a first target relationship that the inputter can query among the relationships;

[0317] The statement determination module is specifically configured to determine that the first physical entity indicated by the first target relationship is a first target physical entity; and determine an SQL field corresponding to the first target physical entity.

[0318] Through the above-mentioned device, the corresponding SQL field can be determined based on the first target relationship, so that ambiguity can be eliminated according to the relationship between at least two physical entities corresponding to the first query term and other query terms, which facilitates the determination of the true query intention of the person who inputs the query information and improves the accuracy of data query.

[0319] Furthermore, the device provided in the embodiment of the present application further includes:

[0320] a second relationship determination module;

[0321] If a first query term in the query terms corresponds to at least two physical entities, the second relationship determination module is configured to, after determining the query terms included in the query information, determine a first relationship set consisting of relationships between the at least two physical entities and other physical entities in the database; determine, based on the query authority of a user inputting the query information, a second relationship set consisting of relationships that the user can query in the first relationship set; determine a quantized length of at least one relationship included in the second relationship set; and determine a second target relationship based on the quantized length;

[0322] The statement determination module is specifically configured to determine that the first physical entity indicated by the second target relationship is the second target physical entity; and determine an SQL field corresponding to the second target physical entity.

[0323] Through the above device, ambiguity can be eliminated based on the first relationship set of at least two physical entities corresponding to the first query term in the database, thereby effectively improving the accuracy of database query.

[0324] Furthermore, the device provided in the embodiment of the present application further includes:

[0325] The second query module is used to determine the third correspondence between the historical query information and the historical query results based on the first correspondence between the historical query information and the historical SQL statements, and the second correspondence between the historical SQL statements and the historical query results. If the current query information belongs to the historical query information, the query result corresponding to the current query information is determined according to the third correspondence.

[0326] In this case, if the current query information belongs to the historical query information, the query result corresponding to the current query information can be directly determined based on the third correspondence, thereby improving query efficiency. Furthermore, when determining the query result through this solution, there is no need to rely on the knowledge graph. Therefore, even if the device running the knowledge graph is in the process of cold start, the query result can still be obtained to meet the database query requirements.

[0327] Furthermore, the device provided in the embodiment of the present application further includes:

[0328] The rule determination module is used to determine a display rule for the query result, and after determining the query result corresponding to the SQL statement in the database, display the query result according to the display rule.

[0329] Through the above device, the query results can be displayed according to the order indicated by the display rules, meeting the query result viewing needs of the inquirer.

[0330] Correspondingly, the embodiment of the present application also provides a terminal device. Figure 9 As shown in the structural diagram, the terminal device includes: a processor 1101 and a memory, wherein the memory stores a computer program, and when the processor executes the computer program stored in the memory, it realizes Figure 1 and Figure 2 All or part of the steps in the corresponding embodiments.

[0331] Furthermore, the terminal device may further include: a transceiver 1102 and a bus 1103 , and the memory includes a random access memory 1104 and a read-only memory 1105 .

[0332] The processor is coupled to the transceiver, random access memory, and read-only memory through a bus. When the terminal device needs to be operated, it is started by the basic input and output system fixed in the read-only memory or the bootloader in the embedded system to guide the device into normal operation. After the device enters the normal operation state, the application program and the operating system are run in the random access memory, so that the terminal device can execute Figure 1 and Figure 2 All or part of the steps in the corresponding embodiments.

[0333] The device of the embodiment of the present invention may correspond to the above Figure 7 The data query device in the corresponding embodiment, and the processor in the device can implement Figure 7 For the sake of brevity, the functions of the devices in the corresponding embodiments and / or the various steps and methods implemented are not described in detail here.

[0334] In a specific implementation, the embodiment of the present application further provides a computer-readable storage medium, which includes instructions. The computer-readable storage medium set in any device can implement the following when it is run on a computer: Figure 1 and Figure 2 The computer-readable storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0335] In addition, another embodiment of the present application further provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to implement the following operations: Figure 1 and Figure 2 All or part of the steps in the corresponding embodiments.

[0336] It will be appreciated by those skilled in the art that the various illustrative logical blocks and steps listed in the embodiments of the present application may be implemented by electronic hardware, computer software, or a combination of both. Whether such functionality is implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the described functionality for each specific application, but such implementation should not be construed as exceeding the scope of protection of the embodiments of the present application.

[0337] The various illustrative logic units and circuits described in the embodiments of the present application can be implemented or operated by a design of a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof. The general-purpose processor can be a microprocessor, alternatively, the general-purpose processor can also be any traditional processor, processor, microprocessor or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration to implement.

[0338] The steps of the methods or algorithms described in the embodiments of the present application can be directly embedded in hardware, software units executed by a processor, or a combination of the two. The software units can be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. For example, the storage medium can be connected to the processor so that the processor can read information from the storage medium and write information to the storage medium. Alternatively, the storage medium can be integrated into the processor. The processor and storage medium can be provided in an ASIC, which can be provided in a UE. Alternatively, the processor and storage medium can be provided in different components within the UE.

[0339] It should be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0340] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0341] The various sections of this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the device and system embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant portions, refer to the descriptions of the method embodiments.

[0342] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.

[0343] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus a necessary general-purpose hardware platform. Based on this understanding, the technical solutions in the embodiments of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention or certain portions of the embodiments.

[0344] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the embodiment of ..., since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.

[0345] The above-described embodiments of the present invention do not limit the protection scope of the present invention.

Claims

1. A data query method, characterized in that: include: Determine a knowledge graph of a database to be queried, the knowledge graph being used to indicate relationships between entities in a data model of the database, the data model comprising a logical model and a physical model, and the entities in the data model of the database comprising logical entities in the logical model and physical entities in the physical model; Determining, based on the knowledge graph, a structured query language SQL statement corresponding to query information, wherein the query information includes: query text information and / or query voice information; Determine the query result corresponding to the SQL statement in the database; The step of determining the structured query language SQL statement corresponding to the query information based on the knowledge graph includes: Determining query terms included in the query information by performing text segmentation processing on the query text information corresponding to the query information; Determining, in the knowledge graph, a first logical entity corresponding to the query term included in the query information through a mapping relationship between different query terms and the logical entities; Determining, through the first logical entities and the mapping relationship between the logical entities and the physical entities, first physical entities corresponding to the first logical entities and the query terms, and determining a query relationship between the first physical entities; The SQL field corresponding to the first physical entity is determined through the correspondence between the physical entity and the SQL field, and the SQL field corresponding to the first physical entity is spliced ​​through the query relationship to determine the corresponding SQL statement.

2. The method according to claim 1, characterized in that The knowledge graph includes: a concept layer and an instance layer; The concept layer is used to indicate the relationship between at least one logical entity in the logical model; The instance layer is used to indicate the relationship between at least one physical entity in the physical model.

3. The method according to claim 2, characterized in that Determining the knowledge graph of the database to be queried includes: Determining, according to a logical model in the data model, the at least one logical entity and a relationship between the at least one logical entity; determining the concept layer according to the at least one logical entity and the relationship between the at least one logical entity; determining, according to the physical model in the data model, the at least one physical entity and the relationship between the at least one physical entity; The instance layer is determined according to the at least one physical entity and the relationship between the at least one physical entity.

4. The method according to claim 1, wherein Also includes: determining conventional knowledge corresponding to the database; The conventional knowledge includes at least one of the abbreviation and full name of the query term, synonyms of the query term, near-synonyms of the query term, and query information examples.

5. The method according to claim 4, characterized in that Also includes: After determining the query terms included in the query information, converting the query terms according to conventional knowledge corresponding to the database; The step of determining the structured query language SQL statement corresponding to the query information includes: The SQL statement corresponding to the query information is determined based on the converted query terms.

6. The method according to claim 1, characterized in that Also includes: If a first query term in the query terms corresponds to at least two physical entities, after determining the query terms included in the query information, determining relationships between the at least two physical entities and other query terms respectively; Determining, according to the query authority of the inputter of the query information and / or the content contained in the database, a first target relationship among the relationships that the inputter can query; The determining the SQL field corresponding to the first physical entity includes: Determining the first physical entity indicated by the first target relationship as a first target physical entity; Determine the SQL field corresponding to the first target physical entity.

7. The method according to claim 1, characterized in that Also includes: If a first query term in the query terms corresponds to at least two physical entities, after determining the query terms included in the query information, determining a first relationship set consisting of relationships between the at least two physical entities and other physical entities in the database; determining, according to the query authority of the inputter of the query information, a second relationship set consisting of relationships that the inputter can query in the first relationship set; determining a quantized length of at least one relation included in the second relation set; determining a second target relationship according to the quantized length; The determining the SQL field corresponding to the first physical entity includes: Determining the first physical entity indicated by the second target relationship as the second target physical entity; Determine the SQL field corresponding to the second target physical entity.

8. The method according to any one of claims 1 to 7, characterized in that Also includes: Determining a third correspondence between the historical query information and the historical query results based on the first correspondence between the historical query information and the historical SQL statements, and the second correspondence between the historical SQL statements and the historical query results; If the current query information belongs to the historical query information, the query result corresponding to the current query information is determined according to the third corresponding relationship.

9. The method according to any one of claims 1 to 7, characterized in that Also includes: Determining display rules for the query results; After determining the query result corresponding to the SQL statement in the database, the query result is displayed according to the display rule.

10. A data query device, characterized in that: include: A graph determination module is configured to determine a knowledge graph of a database to be queried, wherein the knowledge graph is configured to indicate relationships between entities in a data model of the database, wherein the data model includes a logical model and a physical model, and the entities in the data model of the database include logical entities in the logical model and physical entities in the physical model; A statement determination module is used to determine a structured query language SQL statement corresponding to the query information based on the knowledge graph, wherein the query information includes: query text information and / or query voice information; A first query module is used to determine the query result corresponding to the SQL statement in the database; The statement determination module is used to determine the query terms included in the query information by performing text segmentation processing on the query text information corresponding to the query information; determine the first logical entity corresponding to the query terms included in the query information in the knowledge graph through the mapping relationship between different query terms and the logical entities; determine the first physical entity corresponding to the first logical entity and the query terms, and determine the query relationship between the first physical entities through the first logical entity and the mapping relationship between the logical entity and the physical entity; determine the SQL field corresponding to the first physical entity through the corresponding relationship between the physical entity and the SQL field, splice the SQL fields corresponding to the first physical entity through the query relationship, and determine the corresponding SQL statement.

11. The device according to claim 10, characterized in that The knowledge graph includes: a concept layer and an instance layer; The concept layer is used to indicate the relationship between at least one logical entity in the logical model; The instance layer is used to indicate the relationship between at least one physical entity in the physical model.

12. The device according to claim 11, characterized in that The graph determination module is used to determine the at least one logical entity and the relationship between the at least one logical entity based on the logical model in the data model, determine the conceptual layer based on the at least one logical entity and the relationship between the at least one logical entity, determine the at least one physical entity and the relationship between the at least one physical entity based on the physical model in the data model, and determine the instance layer based on the at least one physical entity and the relationship between the at least one physical entity.

13. The device according to claim 10, characterized in that Also includes: A general knowledge determination module, configured to determine the general knowledge corresponding to the database; The conventional knowledge includes at least one of the abbreviation and full name of the query term, synonyms of the query term, near-synonyms of the query term, and query information examples.

14. The device according to claim 13, characterized in that Also includes: a conversion module, configured to convert the query terms included in the query information according to conventional knowledge corresponding to the database after determining the query terms included in the query information; The statement determination module is specifically used to determine the SQL statement corresponding to the query information according to the converted query terms.

15. The device according to claim 10, characterized in that Also includes: a first relationship determination module; If a first query term in the query terms corresponds to at least two physical entities, the first relationship determination module is configured to, after determining the query terms included in the query information, determine the relationships between the at least two physical entities and other query terms, and determine, based on the query authority of the inputter of the query information and / or the content contained in the database, a first target relationship that the inputter can query among the relationships; The statement determination module is specifically configured to determine that the first physical entity indicated by the first target relationship is a first target physical entity; and determine an SQL field corresponding to the first target physical entity.

16. The device according to claim 10, characterized in that Also includes: a second relationship determination module; If a first query term in the query terms corresponds to at least two physical entities, the second relationship determination module is configured to, after determining the query terms included in the query information, determine a first relationship set consisting of relationships between the at least two physical entities and other physical entities in the database; determine, based on the query authority of a user inputting the query information, a second relationship set consisting of relationships that the user can query in the first relationship set; determine a quantized length of at least one relationship included in the second relationship set; and determine a second target relationship based on the quantized length; The statement determination module is specifically configured to determine that the first physical entity indicated by the second target relationship is the second target physical entity; and determine an SQL field corresponding to the second target physical entity.

17. The device according to any one of claims 10 to 16, characterized in that Also includes: The second query module is used to determine the third correspondence between the historical query information and the historical query results based on the first correspondence between the historical query information and the historical SQL statements, and the second correspondence between the historical SQL statements and the historical query results. If the current query information belongs to the historical query information, the query result corresponding to the current query information is determined according to the third correspondence.

18. The device according to any one of claims 10 to 16, characterized in that Also includes: The rule determination module is used to determine a display rule for the query result, and after determining the query result corresponding to the SQL statement in the database, display the query result according to the display rule.

19. A terminal device, characterized in that: The terminal device includes a processor and a memory, wherein a computer program is stored in the memory, and the processor executes the computer program stored in the memory, so that the terminal device performs the method according to any one of claims 1 to 9.

20. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store instructions, and when the instructions are executed on a computer or a processor, the computer or the processor implements the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Database searching method based on knowledge graph

    CN104866593A

  • Domain knowledge graph based on semantic triangle and query method

    CN106874261A

  • Data query method, device and system

    CN109885665A