Data query method and related device

By constructing a knowledge graph and a statement transformation model, natural language queries are converted into database queries, solving the problems of query difficulty and cost for non-technical personnel and enabling fast and automatic database query and visualization result generation.

CN120873146APending Publication Date: 2025-10-31AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511051259.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-29
Publication Date
2025-10-31

AI Technical Summary

Technical Problem

In existing technologies, users need a database expertise to query wide tables, and the query response is slow, which increases the difficulty of use for non-technical personnel and the cost of one-time development.

Method used

By constructing knowledge graphs and vectors, a statement transformation model is used to convert natural language queries into statements that conform to database query formats. The model is then used to automatically generate visualizations of the query results using configuration information, reducing the difficulty of use and development costs for non-technical personnel.

Benefits of technology

It enables database queries without requiring a database expertise background, improves query response speed, reduces development costs, and automatically generates visual results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120873146A_ABST
    Figure CN120873146A_ABST
Patent Text Reader

Abstract

The invention provides a data query method and a related device. The data query method comprises the steps of obtaining a first query statement input by a user and a to-be-queried database table for the first query statement; obtaining a first knowledge graph of the to-be-queried database table; generating a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table; the first query statement, the first vector and the second vector are input into a statement conversion model, a second query statement output by the statement conversion model is obtained, the second query statement meets the query statement format requirement of the to-be-queried database table, and the second query statement is used for indicating the utilization of the database table having the incidence relation with the to-be-queried database table. Querying a specific field in the database table to be queried; reading data from the specific field by using the second query statement to obtain a query result; inputting the query result into a configuration information generation model to obtain configuration information; and drawing a visual result of the query result by utilizing the configuration information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of big data service technology, and in particular to a data query method and related apparatus. Background Technology

[0002] Wide tables are a database table design approach where measures (such as sales volume and quantity) and dimensions (such as product name, company type, and region) are combined into a single table. This reduces the need for joins between tables by increasing the number of columns. A wide table typically contains a large number of fields. Currently, when users query a wide table, it is necessary to first associate the wide table with a dictionary table to interpret the meaning of the fields. Furthermore, technical personnel with database expertise are required to write query statements conforming to the wide table query format, such as SQL (Structured Query Language) statements. This increases the difficulty for non-technical users, incurs one-time development costs, and causes query response delays due to the complexity of the query statements. Summary of the Invention

[0003] In view of the above problems, this application provides a data query method and related apparatus to reduce the difficulty of use for non-technical personnel, the one-time development cost, and improve query response. The specific solution is as follows:

[0004] The first aspect of this application provides a data query method, including:

[0005] Obtain the first query statement input by the user and the database table to be queried for the first query statement, wherein the format of the first query statement is natural language format;

[0006] Obtain the first knowledge graph of the database table to be queried, which is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried;

[0007] Generate a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table;

[0008] The first query statement, the first vector, and the second vector are input into the statement conversion model to obtain the second query statement output by the statement conversion model. The second query statement conforms to the query statement format requirements of the database table to be queried, and the second query statement is used to instruct the use of database tables that have a relationship with the database table to be queried to query a specific field in the database table to be queried. The statement conversion model is trained using the historical first query statement, the historical vectors of the knowledge graph of multiple database tables corresponding to the historical first query statement, and the historical second query statement, so that the statement conversion model has the function of parsing the relationship between different database tables and the meaning of the fields in the database tables, and using the relationship and the meaning of the fields to convert the format of the query statement.

[0009] Using the second query statement, data is read from a specific field of the database table to be queried in order to obtain the query results;

[0010] The query results are input into the configuration information generation model to obtain the configuration information output by the configuration information generation model. The configuration information generation model is trained with the configuration information of historical query results and historical visualization results, so that the configuration information generation model has the function of setting matching configuration information for the historical query results.

[0011] Using the configuration information, a visualization of the query results is generated.

[0012] In one possible implementation, the method further includes:

[0013] Using the field nodes in the first knowledge graph, search for knowledge graphs containing the field nodes and having the same meaning as the field nodes from all existing database tables. The searched knowledge graph is a knowledge graph associated with the first knowledge graph. The meaning of the field nodes is explained by the dictionary table connected to specific nodes in the first knowledge graph.

[0014] The process of generating the first vector of the first knowledge graph and the second vector of the knowledge graph of the existing database table includes: generating the first vector of the first knowledge graph and the second vector of the knowledge graph associated with the first knowledge graph through a preset vector generation model.

[0015] In one possible implementation, the method further includes, before inputting the first query statement, the first vector, and the second vector into the statement transformation model:

[0016] The words in the first query statement are rewritten using synonyms and / or semantically equivalents to convert them into standard words used in the database table.

[0017] In one possible implementation, obtaining the first knowledge graph of the database table to be queried, wherein the first knowledge graph is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried, includes:

[0018] If the first knowledge graph of the database table to be queried exists in the existing knowledge graph set, then perform the step of generating the first vector of the first knowledge graph and the second vector of the knowledge graph of the existing database table.

[0019] If the existing knowledge graph set does not contain a first knowledge graph of the database table to be queried, the first knowledge graph is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried. The first knowledge graph includes table nodes, field nodes, and business concept nodes. The business concept nodes are connected to the dictionary table corresponding to the database table to be queried, so as to use the dictionary table corresponding to the database table to interpret the meaning of the field nodes. The first knowledge graph records table information descriptions, which are an overview of the business meaning of the database table to be queried.

[0020] In one possible implementation, the statement transformation model is trained using the historical first query statement, the historical vectors of the knowledge graph of multiple database tables corresponding to the historical first query statement, and the historical second query statement to obtain the following:

[0021] The first historical query statement and the second historical query statement are converted to standard formats respectively. The conversion of the first historical query statement to standard formats includes rewriting the words in the first historical query statement with synonyms and / or semantic equivalences to convert the words in the first historical query statement into standard words used by the database table. The conversion of the second historical query statement to standard formats includes performing equivalent exchanges on the second historical query statement.

[0022] By using a preset vector generation model, historical vectors of the knowledge graph of multiple database tables corresponding to the second historical query statement are generated.

[0023] Using the historical vector and the first historical query statement converted to a standard format as input to the statement conversion model, the query statement output by the statement conversion model is obtained;

[0024] The loss value is calculated using the query statement and the historical second query statement converted to standard format.

[0025] The model parameters of the statement transformation model are adjusted using the loss value.

[0026] In one possible implementation, before training the configuration information generation model using the configuration information of the historical visualization results, the configuration information of the historical visualization results is adjusted so that the configuration information of the historical visualization results meets the preset visualization format requirements of the historical visualization results.

[0027] A second aspect of this application provides a data query device, comprising:

[0028] The acquisition unit is used to acquire a first query statement input by the user and a database table to be queried for the first query statement, wherein the first query statement is in natural language format, and to acquire a first knowledge graph of the database table to be queried, wherein the first knowledge graph is constructed based on the database table to be queried and a dictionary table corresponding to the database table to be queried.

[0029] The first generation unit is used to generate a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table.

[0030] The conversion unit is used to input the first query statement, the first vector, and the second vector into the statement conversion model to obtain the second query statement output by the statement conversion model. The second query statement conforms to the query statement format requirements of the database table to be queried, and the second query statement is used to instruct to use a database table that has a relationship with the database table to be queried to query a specific field in the database table to be queried. The statement conversion model is trained with the historical first query statement, the historical vectors of the knowledge graph of multiple database tables corresponding to the historical first query statement, and the historical second query statement, so that the statement conversion model has the function of parsing the relationship between different database tables and the meaning of the fields in the database tables, and using the relationship and the meaning of the fields to convert the format of the query statement.

[0031] The query unit is used to read data from a specific field of the database table to be queried using the second query statement to obtain query results;

[0032] The second generation unit is used to input the query result into the configuration information generation model to obtain the configuration information output by the configuration information generation model. The configuration information generation model is trained with the configuration information of historical query results and historical visualization results, so that the configuration information generation model has the function of setting matching configuration information for the historical query results.

[0033] A drawing unit is used to draw a visualization of the query results using the configuration information.

[0034] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the data query method described in the first aspect or any implementation thereof.

[0035] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:

[0036] The memory is used to store computer programs;

[0037] The processor is used to execute the computer program so that the electronic device can implement the data query method of the first aspect or any implementation thereof.

[0038] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to perform the data query method described in the first aspect or any implementation thereof.

[0039] By utilizing the above technical solutions, the data query method and related apparatus provided in this application, Attached Figure Description

[0040] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0041] Figure 1 A flowchart of a data query method provided in this application;

[0042] Figure 2 A schematic diagram illustrating a data query method provided in this application;

[0043] Figure 3 A schematic diagram of the structure of a data query device provided in this application;

[0044] Figure 4 A schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation

[0045] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.

[0046] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0047] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements but may include other elements not explicitly listed or inherent to such processes, methods, systems, products, or apparatus.

[0048] Please see Figure 1 This illustrates an optional flow of a data query method provided in an embodiment of this application, which may include the following steps:

[0049] S101. Obtain the first query statement input by the user and the database table to be queried for the first query statement. The format of the first query statement is natural language format.

[0050] In this embodiment, the user is a non-technical person without a database background. When the user queries any database table, the user inputs a first query statement in natural language format. For example, the user's first query statement is "Please compare the differences in sales of precious metals and bonds between elderly customers who visited the store and those who did not in July." This first query statement describes the user's query needs in natural language. However, the database table cannot recognize what the query needs are. Therefore, after obtaining the first query statement, the following steps are performed to convert the first query statement into a second query statement, resulting in a second query statement that can be recognized by the database table.

[0051] The database table targeted by the first query statement can be specified by the user. For example, the user can specify the database table to be queried during the input of the first query statement, indicating which database table the first query will use. The user could include the database table in the first query statement, such as "Please compare the sales figures for precious metals and bonds by elderly customers who visited and did not visit stores in July in the marketing situation table." Here, the marketing situation table is the database table to be queried, and "Compare the sales figures for precious metals and bonds by elderly customers who visited and did not visit stores in July" is the query requirement.

[0052] In one possible implementation, the target database table for the first query statement is determined by analyzing the first query statement. For example, by analyzing the first query statement to determine the query requirement, the query requirement is compared with an overview of existing database tables (such as table names). The existing database tables whose overview matches the query requirement are then identified as the target database tables for the first query statement. Taking the example of "Please compare the sales figures for precious metals and bonds by elderly customers who visited stores and those who did not in July," the query requirement is to query the sales figures for precious metals and bonds, specifically comparing the sales figures for elderly customers who visited stores and those who did not in July. The existing database tables include a fund table, a mobile banking activity table, a precious metals sales table, and a bond sales table. Therefore, the target database tables for the first query are the precious metals sales table and the bond sales table.

[0053] In this embodiment, the database table to be queried and the existing database table can adopt a wide table design. This embodiment does not limit the design form of the database table.

[0054] S102. Obtain the first knowledge graph of the database table to be queried. The first knowledge graph is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried.

[0055] The first knowledge graph can include table nodes, field nodes, and business concept nodes. Business concept nodes connect to the dictionary table corresponding to the database table being queried, allowing the dictionary table to explain the meaning of the field nodes. The first knowledge graph records table information descriptions, which are summaries of the business meaning of the database table being queried. Table information descriptions can be attributes of table nodes. For example, for the mobile banking new customer table, the table information description could include marketing opportunities, third-party agreements, and card binding information for newly registered mobile banking users in the past month. For the precious metals sales table, the table information description could include the total sales amount of gold, platinum, and silver by user and channel.

[0056] The knowledge graph is structured as follows: Table nodes represent the database tables corresponding to the first knowledge graph. Table nodes can be named after the database table, such as a fund table or a mobile banking activity table. Field nodes are constructed from the fields in the database table, representing the fields contained within it. Business concept nodes represent the business meaning of the database table, such as whether it's a fund classification table or a transaction classification table. Business concept nodes also connect to dictionary tables, which record the meaning of the identifiers stored in each field of the database table (referred to as the field meaning). The meaning of fields in the dictionary table is described using natural language, injecting semantics (meaning or interpretation) into the fields so that they can be located through the dictionary table. For example, if an age range in a database table is stored as A, B, C, D, E, the corresponding dictionary table is {(Age A: 0-18 years old), (Age B: 18-30 years old), (Age C: 30-45 years old), (Age D: 45-60 years old), (Age E: 60+ years old, marked as elderly customers)}. The dictionary table explains that age A refers to those aged 0 to 18.

[0057] Furthermore, the same field in different database tables has the same meaning in the dictionary table, which is used to determine the relationship between the database tables. For example, if two database tables both have a User ID (Identitydocument) field and the same meaning in the dictionary table, then the two database tables are determined to be related through that field, meaning that the two database tables have a relationship.

[0058] In this embodiment, the database table to be queried and the dictionary table are corresponding. After obtaining the database table to be queried for the first query statement, the dictionary table of the database table to be queried can be obtained. Then, using the name of the database table to be queried as the table node and the names of each field in the database table to be queried as the field node, the business concept node is determined by analyzing the content of the database table to be queried (such as the name and business-related fields), and the dictionary table is connected to the business concept node, thereby generating the first knowledge graph of the database table to be queried. The table information description can be determined based on the business concept node, the name of the database table to be queried, and the business-related fields in the table, which will not be elaborated here.

[0059] In some examples, the database table to be queried may be an existing database table for which a first knowledge graph has already been constructed. One possible approach to obtaining the first knowledge graph of the database table to be queried is to search the existing knowledge graph set for a first knowledge graph of the database table to be queried. If the existing knowledge graph set contains a first knowledge graph of the database table to be queried, that first knowledge graph is used directly, and step S103 is executed. If the existing knowledge graph set does not contain a first knowledge graph of the database table to be queried, a first knowledge graph is constructed based on the database table to be queried and its corresponding dictionary table. The construction process and the composition of the first knowledge graph are described above and will not be detailed here. After constructing the first knowledge graph of the database table to be queried, it is stored in the existing knowledge graph set to enrich the first knowledge graph in the existing set. Furthermore, in scenarios where the existing knowledge graph set contains a first knowledge graph of the database table to be queried, the construction process of the first knowledge graph can be reduced, improving processing efficiency.

[0060] S103. Generate a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table. In one possible implementation, the first vector of the first knowledge graph and the second vector of the knowledge graph of the existing database table are generated through a preset vector generation model. For example, the preset vector generation model can be, but is not limited to, a graph neural network model, such as GraphSAGE, TransE, etc.

[0061] In one possible implementation, the field nodes in the first knowledge graph are used to search for knowledge graphs containing field nodes with the same meaning as the field nodes from the knowledge graphs of all existing database tables. The searched knowledge graphs are those associated with the first knowledge graph, and the meaning of the field nodes is explained by a dictionary table connected to specific nodes (such as business concept nodes) in the first knowledge graph. Correspondingly, generating the first vector of the first knowledge graph and the second vector of the knowledge graphs of the existing database tables can include: generating the first vector of the first knowledge graph through a preset vector generation model, and the second vector of the knowledge graph associated with the first knowledge graph. Thus, by finding knowledge graphs associated with the first knowledge graph through the field nodes in the first knowledge graph and filtering out knowledge graphs unrelated to the first knowledge graph, the preset vector generation model can process only the first knowledge graph and the knowledge graphs associated with the first knowledge graph, reducing the amount of data processed by the preset vector generation model and the number of second vectors, thereby improving processing efficiency.

[0062] S104. Input the first query statement, the first vector, and the second vector into the statement transformation model to obtain the second query statement output by the statement transformation model.

[0063] The second query statement conforms to the query statement format requirements of the database table to be queried. For example, if the database table can be queried using SQL, then the second query statement is an SQL statement, automatically generated by the statement transformation model to form the SQL statement for the first query statement. The second query statement generated by the statement transformation model also instructs the use of database tables that are related to the database table to be queried to query specific fields within that table. In other words, the second query statement not only conforms to the query statement format requirements but also indicates the query scope, which is the specific fields determined from the database table to be queried using database tables that are related to that table.

[0064] In this embodiment, the statement conversion model is trained using a historical first query statement, historical vectors from the knowledge graph of multiple database tables corresponding to the historical first query statement, and a historical second query statement. This enables the statement conversion model to parse the relationships between different database tables and the meaning of fields in the database tables, and to perform format conversion of the query statement using the relationships and the meaning of the fields. After inputting the first query statement, the first vector, and the second vector, the statement conversion model can determine the query scope of the first query statement based on the first query statement, the first vector, and the second vector, that is, the database tables with relationships and the fields in the database tables. Then, based on the query scope of the first query statement, the statement conversion model can perform format conversion on the first query statement to obtain a second query statement that can be used by the database tables.

[0065] The training process of the sentence conversion model is shown in 1) to 5) below:

[0066] 1) Perform standard format conversion on the first and second historical query statements respectively. The standard format conversion of the first historical query statement includes rewriting the words in the first historical query statement with synonyms and / or semantic equivalence to convert the words in the first historical query statement into standard words used by the database table. The standard format conversion of the second historical query statement includes performing equivalent exchange on the second historical query statement.

[0067] For example, synonym rewriting could be changing "sales revenue" to "revenue," and semantic equivalence could be mapping "three-piece set" to "card binding rate, third-party signing rate, and marketability rate." If the first historical query indicates a query for "three-piece set," then the first historical query was querying "card binding rate, third-party signing rate, and marketability rate." Equivalent exchange could be adjusting the order in the second historical query, such as changing the GROUP BY order.

[0068] After obtaining the first and second historical query statements, you can also clean them. For example, you can filter out invalid first and second historical query statements. If the query result of the second historical query statement is an error, then filter out the second historical query statement and the corresponding first historical query statement.

[0069] 2) Generate historical vectors for the knowledge graphs of multiple database tables corresponding to the historical second query statement using a preset vector generation model. The knowledge graphs of the multiple database tables corresponding to the historical second query statement can be the knowledge graphs of the database tables used during the query process. In this embodiment, the preset vector generation model can be, but is not limited to, a graph neural network model, such as GraphSAGE, TransE, etc.

[0070] 3) Using the historical vector and the first historical query statement after standard format conversion as input to the statement conversion model, the query statement output by the statement conversion model is obtained.

[0071] 4) Calculate the loss value using the historical second query statement converted from the original query statement to the standard format. This can be done using a loss function, which may include, but is not limited to, the mean squared error loss function and the cross-entropy loss function.

[0072] 5) Adjust the model parameters of the sentence conversion model using the loss value. Training the sentence conversion model can be stopped once the preset number of training iterations is met, or when the loss value stops decreasing.

[0073] Before using the statement transformation model to transform the first query statement, the words in the first query statement can be rewritten using synonyms and / or semantically equivalents to convert the words in the first query statement into standard words used in the database table, making it easier for the statement transformation model to recognize them.

[0074] S105. Using the second query statement, data is read from a specific field of the database table to be queried in order to obtain the query results.

[0075] S106. Input the query results into the configuration information generation model to obtain the configuration information output by the configuration information generation model.

[0076] The configuration information generation model is trained using configuration information from historical query results and historical visualization results, enabling it to set matching configuration information for historical query results. Because the configuration information generation model has this capability, it can generate matching configuration information for query results after they are input into it.

[0077] In some examples, before training the configuration information generation model using configuration information from historical visualizations, the configuration information of the historical visualizations is adjusted to ensure it meets the preset visualization format requirements of the historical visualizations. For example, the color theme in the configuration information may be switched. Furthermore, before training the configuration information generation model, the configuration information from historical visualizations can be cleaned, such as filtering out unreasonable configuration information. Unreasonable information could be configuration information that is unusable in historical visualizations, such as using a pie chart for a time series.

[0078] S107. Using the configuration information, draw a visualization of the query results.

[0079] In some examples, the visualization of query results can be achieved using ECharts technology. In this case, the configuration information generation model can output ECharts configuration information to generate corresponding charts.

[0080] As can be seen from the above technical solution, the data query method provided in this application embodiment achieves understanding of the database table and its fields by constructing a knowledge graph for the database table. The statement conversion model uses vectors from multiple knowledge graphs to perform semantic parsing of the first query statement, and automatically generates a second query statement that can be recognized / used by the database table. After obtaining the query result using the second query statement, the configuration information generation model automatically matches the corresponding configuration information to the query result, and uses the configuration information to generate a visual result of the query result, forming a closed-loop solution of "database table understanding - semantic parsing - intelligent query - visual result output". Furthermore, the conversion from the first query statement in natural language format to the second query statement conforming to the query statement format requirements of the database table is achieved through the unique function of the statement conversion model. This unique function is to parse the relationships between different database tables and the meaning of fields in the database table, and use the relationships and the meaning of fields to perform query statement format conversion. This reduces the difficulty of use for non-technical personnel and the development cost per line, and eliminates the need to wait for technical personnel to write query statements, thus improving query response. Furthermore, the second query statement instructs the use of database tables that are related to the database table to be queried to query specific fields in the database table to be queried, so that the database table can be directly queried using the second query statement, thus shortening the response cycle.

[0081] In summary, the data query method provided in this application includes two stages: preliminary preparation and application scenario usage, such as... Figure 2 As shown, the preliminary work may include generating a knowledge graph of database tables, generating a statement transformation model, and generating a configuration information generation model. Figure 2 The metadata enhancement and adaptive representation of the database tables utilize knowledge graphs and connected dictionary tables to understand the database tables. Multimodal joint training instructs the generation of statement transformation models and configuration information models using historical information. The historical information can be standardized and adjusted before model generation; please refer to the above for details. Figure 1 As shown.

[0082] The application scenario usage phase involves the use of knowledge graphs, statement transformation models, and configuration information generation models. After obtaining the natural query language (i.e., the first query statement) and the database table to be queried, it utilizes... Figure 2 Steps 1 to 6 in the process obtain the query results of the first query statement from the database table to be queried.

[0083] Step 1: Construct the first knowledge graph of the database table to be queried using the database table to be queried and its dictionary table.

[0084] Step 2: Generate the first vector of the first knowledge graph and the second vector of the knowledge graph of the existing database table.

[0085] Step 3: The statement transformation model uses the first and second vectors to transform the first query statement into the second query statement.

[0086] Step 4: Use the second query statement to perform a table join query. The join table can be the database table to be queried, the database tables related to the database table to be queried, and the dictionary tables of each database table, so as to determine the location of the field indicated by the second query statement through these tables.

[0087] Step 5: Generate configuration information for the query results from the configuration information generation model.

[0088] Step 6: Draw the ECharts of the query results.

[0089] The example illustrates this with two wide tables in the database. The two wide tables have corresponding dictionary tables. One wide table is the customer information table (50 fields, with the key fields being user ID and user age range, stored as A, B, C, D, E), corresponding to the dictionary table {(Age A: 0-18 years old), (Age B: 18-30), (Age C: 30-45), (Age D: 45-60), (Age E: 60+, indicating elderly customers)} {(User ID: a unique identifier for the entire bank)}. The other wide table is the marketing situation table (80 fields, with key fields being: user ID, transaction time, product type (01, 02, 03), sales amount (value), whether in-store (0, 1)), corresponding to the dictionary table {(Product type 01: precious metals), (Product type 02: bonds), (Product type 03: wealth management)} {(Whether in-store 0: non-in-store sales), (Whether in-store 1: in-store sales)} {(User ID: a unique identifier for the entire bank)}.

[0090] At this time, a person without a background in NoSQL technology introduced the marketing situation table and entered "Please compare the differences in the sales amounts of precious metals and bonds for elderly customers who visited the store and those who did not visit the store in July". Using the above data query method, a pseudo-SQL (an optional method for the second query statement) can be generated. Pseudo-SQL: select count(sales amount), whether visited the store, product type from (select sales amount, whether visited the store, product type from the marketing situation table left join the user table on marketing situation table.ID = user table.ID) where date > 20250701 and date <2025073>1 and product type in (01, 02) group By whether visited the store, product type. When querying the marketing situation table using the pseudo-SQL, first use the dictionary table of the customer information table to determine the elderly customers, that is, the user IDs of users with age E, and then filter out the user IDs of users with age E in the marketing situation table. Then use "{(product type 01: precious metals), (product type 02: bonds), (product type 03: wealth management)}{(whether visited the store 0: off-site sales), (whether visited the store 1: in-store sales)}" in the dictionary table of the marketing situation table to divide those who visited the store to purchase precious metals and bonds, and those who did not visit the store to purchase precious metals and bonds from these user IDs, and then read the data to obtain the query result. Subsequently, the configuration information generation model can generate the configuration information of a bar chart, and use the configuration information to generate a bar chart of the query result for comparison.

[0091] The above introduced a data query method provided by an embodiment of the present application. Next, an apparatus for executing the above data query method will be introduced. Please refer to Figure 3 , which shows an optional structure of the data query apparatus provided by an embodiment of the present application, and may include: an acquisition unit 10, a first generation unit 20, a conversion unit 30, a query unit 40, a second generation unit 50, and a drawing unit 60.

[0092] The acquisition unit 10 is configured to acquire a first query statement input by a user and a database table to be queried targeted by the first query statement. The format of the first query statement is in a natural language format, and is also configured to acquire a first knowledge graph of the database table to be queried, and the first knowledge graph is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried.

[0093] In one possible implementation, the acquisition unit 10 searches the existing knowledge graph set for a first knowledge graph of the database table to be queried. If the existing knowledge graph set contains a first knowledge graph of the database table to be queried, the first generation unit 20 is triggered to generate a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table. If the existing knowledge graph set does not contain a first knowledge graph of the database table to be queried, the acquisition unit 10 constructs a first knowledge graph based on the database table to be queried and the dictionary table corresponding to the database table to be queried. The first knowledge graph includes table nodes, field nodes, and business concept nodes. The business concept nodes are connected to the dictionary table corresponding to the database table to be queried, so as to use the dictionary table corresponding to the database table to interpret the meaning of the field nodes. The first knowledge graph records table information descriptions, which are an overview of the business meaning of the database table to be queried.

[0094] The first generation unit 20 is used to generate a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table.

[0095] In one possible implementation, the data query device further includes a search unit, used to search for knowledge graphs containing field nodes and whose meanings are the same as those of the field nodes from the knowledge graphs of all existing database tables, using field nodes in the first knowledge graph. The searched knowledge graph is associated with the first knowledge graph, and the meaning of the field nodes is interpreted by a dictionary table connected to specific nodes in the first knowledge graph. The corresponding first generation unit 20 is used to generate a first vector of the first knowledge graph and a second vector of the knowledge graph associated with the first knowledge graph through a preset vector generation model.

[0096] The conversion unit 30 is used to input the first query statement, the first vector, and the second vector into the statement conversion model to obtain the second query statement output by the statement conversion model. The second query statement conforms to the query statement format requirements of the database table to be queried, and the second query statement is used to instruct to query a specific field in the database table to be queried using a database table that has a relationship with the database table to be queried. The statement conversion model is trained using the historical first query statement, the historical vectors of the knowledge graph of multiple database tables corresponding to the historical first query statement, and the historical second query statement, so that the statement conversion model has the function of parsing the relationship between different database tables and the meaning of the fields in the database table, and using the relationship and the meaning of the fields to convert the format of the query statement.

[0097] In one possible implementation, before inputting the first query statement, the first vector, and the second vector into the statement conversion model, the conversion unit 30 performs synonym rewriting and / or semantic equivalence on the words in the first query statement to convert the words in the first query statement into standard words used by the database table.

[0098] The training process of the statement conversion model includes: performing standard format conversion on the first and second historical query statements respectively. The standard format conversion of the first historical query statement includes paraphrasing and / or semantic equivalence of the words in the first historical query statement to convert the words in the first historical query statement into standard words used by the database tables. The standard format conversion of the second historical query statement includes equivalent exchange. A preset vector generation model is used to generate historical vectors for the knowledge graph of multiple database tables corresponding to the second historical query statement. The historical vectors and the standard format converted first historical query statement are used as input to the statement conversion model to obtain the output query statement. The loss value is calculated using the query statement and the standard format converted second historical query statement. The model parameters of the statement conversion model are adjusted using the loss value.

[0099] The query unit 40 is used to read data from a specific field of the database table to be queried using a second query statement in order to obtain the query result.

[0100] The second generation unit 50 is used to input the query results into the configuration information generation model to obtain the configuration information output by the configuration information generation model. The configuration information generation model is trained using the configuration information of historical query results and historical visualization results, enabling the configuration information generation model to set matching configuration information for historical query results. In one possible implementation, before training the configuration information generation model using the configuration information of historical visualization results, the second generation unit 50 adjusts the configuration information of the historical visualization results to ensure that the configuration information of the historical visualization results meets the preset visualization format requirements of the historical visualization results.

[0101] The drawing unit 60 is used to draw a visualization of the query results using the configuration information.

[0102] For detailed descriptions of each unit in the above data query device, please refer to the Method Embodiments section, which will not be repeated here.

[0103] This application also provides an electronic device in its embodiments. (See reference...) Figure 4 The diagram illustrates a structural schematic suitable for implementing the electronic device in the embodiments of this application. The electronic device in the embodiments of this application may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 4 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0104] like Figure 4As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. When the electronic device is powered on, the RAM 403 also stores various programs and data required for the operation of the electronic device. The processing unit 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404. The processing unit 401 can be the processor of the electronic device, and the ROM 402, RAM 403, and storage device 408 can be the memory of the electronic device, which stores computer programs; the processor executes the computer programs to enable the electronic device to implement any of the data query methods provided in the embodiments of this application.

[0105] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 408 including, for example, memory cards, hard drives, etc.; and communication devices 409. Communication device 409 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.

[0106] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the data query methods provided in this application.

[0107] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the data query methods provided in this application.

[0108] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0109] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0110] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0111] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A data query method, characterized in that, include: Obtain the first query statement input by the user and the database table to be queried for the first query statement, wherein the format of the first query statement is natural language format; Obtain the first knowledge graph of the database table to be queried, which is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried; Generate a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table; The first query statement, the first vector, and the second vector are input into the statement conversion model to obtain the second query statement output by the statement conversion model. The second query statement conforms to the query statement format requirements of the database table to be queried, and the second query statement is used to instruct the use of database tables that have a relationship with the database table to be queried to query a specific field in the database table to be queried. The statement conversion model is trained using the historical first query statement, the historical vectors of the knowledge graph of multiple database tables corresponding to the historical first query statement, and the historical second query statement, so that the statement conversion model has the function of parsing the relationship between different database tables and the meaning of the fields in the database tables, and using the relationship and the meaning of the fields to convert the format of the query statement. Using the second query statement, data is read from a specific field of the database table to be queried in order to obtain the query results; The query results are input into the configuration information generation model to obtain the configuration information output by the configuration information generation model. The configuration information generation model is trained with the configuration information of historical query results and historical visualization results, so that the configuration information generation model has the function of setting matching configuration information for the historical query results. Using the configuration information, a visualization of the query results is generated.

2. The method according to claim 1, characterized in that, The method further includes: Using the field nodes in the first knowledge graph, search for knowledge graphs containing the field nodes and having the same meaning as the field nodes from all existing database tables. The searched knowledge graph is a knowledge graph associated with the first knowledge graph. The meaning of the field nodes is explained by the dictionary table connected to specific nodes in the first knowledge graph. The process of generating the first vector of the first knowledge graph and the second vector of the knowledge graph of the existing database table includes: generating the first vector of the first knowledge graph and the second vector of the knowledge graph associated with the first knowledge graph through a preset vector generation model.

3. The method according to claim 1, characterized in that, Before inputting the first query statement, the first vector, and the second vector into the statement transformation model, the method further includes: The words in the first query statement are rewritten using synonyms and / or semantically equivalents to convert them into standard words used in the database table.

4. The method according to claim 1, characterized in that, The step of obtaining the first knowledge graph of the database table to be queried, wherein the first knowledge graph is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried, includes: If the first knowledge graph of the database table to be queried exists in the existing knowledge graph set, then perform the step of generating the first vector of the first knowledge graph and the second vector of the knowledge graph of the existing database table. If the existing knowledge graph set does not contain a first knowledge graph of the database table to be queried, the first knowledge graph is constructed based on the database table to be queried and the dictionary table corresponding to the database table to be queried. The first knowledge graph includes table nodes, field nodes, and business concept nodes. The business concept nodes are connected to the dictionary table corresponding to the database table to be queried, so as to use the dictionary table corresponding to the database table to interpret the meaning of the field nodes. The first knowledge graph records table information descriptions, which are an overview of the business meaning of the database table to be queried.

5. The method according to any one of claims 1 to 4, characterized in that, The statement transformation model is trained using the first historical query statement, the historical vectors of the knowledge graph of multiple database tables corresponding to the first historical query statement, and the second historical query statement, resulting in the following: The first historical query statement and the second historical query statement are converted to standard formats respectively. The conversion of the first historical query statement to standard formats includes rewriting the words in the first historical query statement with synonyms and / or semantic equivalences to convert the words in the first historical query statement into standard words used by the database table. The conversion of the second historical query statement to standard formats includes performing equivalent exchanges on the second historical query statement. By using a preset vector generation model, historical vectors of the knowledge graph of multiple database tables corresponding to the second historical query statement are generated. Using the historical vector and the first historical query statement converted to a standard format as input to the statement conversion model, the query statement output by the statement conversion model is obtained; The loss value is calculated using the query statement and the historical second query statement converted to standard format. The model parameters of the statement transformation model are adjusted using the loss value.

6. The method according to claim 5, characterized in that, Before training the configuration information generation model using the configuration information of the historical visualization results, the configuration information of the historical visualization results is adjusted so that the configuration information of the historical visualization results meets the preset visualization format requirements of the historical visualization results.

7. A data query device, characterized in that, include: The acquisition unit is used to acquire a first query statement input by the user and a database table to be queried for the first query statement, wherein the first query statement is in natural language format, and to acquire a first knowledge graph of the database table to be queried, wherein the first knowledge graph is constructed based on the database table to be queried and a dictionary table corresponding to the database table to be queried. The first generation unit is used to generate a first vector of the first knowledge graph and a second vector of the knowledge graph of the existing database table. The conversion unit is used to input the first query statement, the first vector, and the second vector into the statement conversion model to obtain the second query statement output by the statement conversion model. The second query statement conforms to the query statement format requirements of the database table to be queried, and the second query statement is used to instruct to use a database table that has a relationship with the database table to be queried to query a specific field in the database table to be queried. The statement conversion model is trained with the historical first query statement, the historical vectors of the knowledge graph of multiple database tables corresponding to the historical first query statement, and the historical second query statement, so that the statement conversion model has the function of parsing the relationship between different database tables and the meaning of the fields in the database tables, and using the relationship and the meaning of the fields to convert the format of the query statement. The query unit is used to read data from a specific field of the database table to be queried using the second query statement to obtain query results; The second generation unit is used to input the query result into the configuration information generation model to obtain the configuration information output by the configuration information generation model. The configuration information generation model is trained with the configuration information of historical query results and historical visualization results, so that the configuration information generation model has the function of setting matching configuration information for the historical query results. A drawing unit is used to draw a visualization of the query results using the configuration information.

8. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the data query method as described in any one of claims 1 to 6.

9. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the data query method as described in any one of claims 1 to 6.

10. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the data query method as described in any one of claims 1 to 6.