Database information query method and device, equipment and storage medium

Through text reasoning and entity recognition technology, SQL query statements are generated in combination with coarse-grained and fine-grained information, the problem of incomplete and inaccurate SQL queries in traditional methods is solved, and more efficient database information query is achieved and user experience is improved.

CN119396857APending Publication Date: 2025-02-07CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411548752.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

Traditional database information query methods rely on BERT-based models, resulting in poor results in completeness, accuracy, consistency, etc., requiring a large amount of labeled data for training, which is time-consuming and labor-intensive, and slow processing speed, affecting users. Experience.

Method used

By obtaining the initial problem text uploaded by the user, performing text inference to obtain the inference problem text, entity recognition is used to determine the target table to be queried, obtaining the coarse and fine-grained information of the target table, and generating and combining SQL query statements based on this information, input into Database information query system to obtain query results.

Benefits of technology

The generated SQL query statements perform better in terms of completeness, accuracy and consistency, without the need for a large amount of labeled data training, which reduces training costs and time consumption, and improves query processing speed and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396857A_ABST
    Figure CN119396857A_ABST
Patent Text Reader

Abstract

The invention discloses a database information query method and device, equipment and a storage medium, and belongs to the technical field of artificial intelligence. The method comprises the steps of obtaining an initial problem text, and performing text reasoning to obtain a reasoning problem text; performing entity recognition on the reasoning problem text to determine a to-be-queried target table; information of a to-be-queried target table is obtained, and the information of the to-be-queried target table comprises coarse-grained information and fine-grained information; generating a first SQL query statement fragment based on the coarse-grained information, and generating a second SQL query statement fragment based on the fine-grained information; combining the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement; and inputting the SQL query statement into an information query system of a database to obtain an information query result. The invention further relates to the technical field of block chains, and the problem text is stored on a block chain node. Compared with a traditional scheme, the SQL query statement generated by the method is better in integrity, accuracy and consistency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to a database information query method, device, equipment and storage medium. Background Art

[0002] In today's data-driven era, enterprises and organizations are faced with a large amount of data stored in different databases. How to efficiently extract useful information from these databases has become an urgent need. Traditional database queries usually rely on users' understanding of the SQL language. However, many non-professional users find it difficult to master the SQL language, which leads to obstacles in obtaining information.

[0003] To solve this problem, the Text-to-SQL (Texl2SQL) task came into being. This task aims to convert questions asked by users in natural language into SQL queries so as to automatically retrieve relevant information in the database. This automation not only simplifies the data query process, but also enables ordinary users to obtain the required data more conveniently.

[0004] In the Text-to-SQL task, traditional methods mainly rely on BERT-based models, which are usually combined with named entity recognition (NER) technology to process users' natural language queries. Specifically, traditional methods first use NER models to identify key slots in queries, such as table names, column names, and conditions. Then, the system assembles the identified slot information to generate the corresponding SQL query statement. The entire process is controlled and verified by rules + judgment + type exhaustive method. However, users' questions usually cover rich information and diverse expressions. It is difficult for traditional BERT models to exhaust all possible query forms. This leads to the model often failing to accurately identify key slots when processing new or complex queries, thus affecting the completeness and accuracy of the generated SQL queries. When faced with complex table structures and nested relationships, the recognition effect of traditional methods is poor. These models often cannot effectively understand the complex relationships between data, resulting in the generated SQL queries failing to correctly reflect the user's intentions. In addition, traditional methods rely on slot recognition and usually require a large amount of labeled data for training, which not only increases the workload of data preparation, but also makes the model face challenges when adapting to new scenarios or new data, making system maintenance and updates more cumbersome. At the same time, in multi-round conversations or complex query scenarios, traditional methods have difficulty maintaining context consistency. User queries often rely on previous conversation content, and the BERT model lacks an effective context management mechanism, resulting in the generated SQL queries failing to accurately reflect the user's real needs. Due to the need for multi-step slot identification and SQL assembly, traditional methods are often slow in processing speed. When faced with a large number of concurrent queries, the system's response time may increase significantly, affecting the user experience. Summary of the invention

[0005] The purpose of the embodiments of the present application is to propose a database information query method, device, computer equipment and storage medium to solve the technical problem that the traditional database information query method mainly relies on a BERT-based model, resulting in poor results in the generated SQL queries in terms of completeness, accuracy, consistency, etc., and requires a large amount of labeled data for training, which is time-consuming and labor-intensive, and has a slow processing speed, affecting the user experience.

[0006] In order to solve the above technical problems, the present application provides a method for querying information in a database, which adopts the following technical solution:

[0007] A method for querying information in a database, comprising:

[0008] Obtain the initial question text uploaded by the user, and perform text reasoning on the initial question text to obtain the reasoned question text;

[0009] Perform entity recognition on the reasoning question text and determine the target table to be queried based on the entity recognition results;

[0010] Obtaining information of the target table to be queried, wherein the information of the target table to be queried includes coarse-grained information and fine-grained information, the coarse-grained information includes the table name and summary information, and the fine-grained information includes field information and business association logic;

[0011] Generate a first SQL query statement fragment based on the coarse-grained information, and generate a second SQL query statement fragment based on the fine-grained information;

[0012] Combining the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement;

[0013] Input the SQL query statement into the information query system of the database to obtain the information query result.

[0014] Furthermore, the steps of obtaining the initial question text uploaded by the user and performing text reasoning on the initial question text to obtain the reasoned question text specifically include:

[0015] Generate a question prompt template, send the question prompt template to the user end, and instruct the user to fill in the question prompt template to obtain an initial question text;

[0016] Use the pre-trained thinking reasoning model to perform text reasoning on the initial question text to obtain the reasoning question text.

[0017] Furthermore, the steps of using the pre-trained thinking reasoning model to perform text reasoning on the initial question text to obtain the reasoning question text specifically include:

[0018] Get the question prompt logic of the question prompt template;

[0019] In the thinking reasoning model, the initial question text is split into several sub-question texts based on the question prompt logic;

[0020] Identify the entities and entity relationships of each sub-question text, and obtain sub-question entities and sub-question entity relationships;

[0021] Retrieve a target entity that matches the sub-question entity from a preset entity library, and retrieve a target entity relationship that matches the target entity from a preset entity relationship library;

[0022] Generate reasoning question text based on sub-question entities, target entities, sub-question entity relations and target entity relations.

[0023] Furthermore, based on the sub-question entity, the target entity, the sub-question entity relationship and the target entity relationship, the step of generating the reasoning question text specifically includes:

[0024] Combine the sub-problem entity relations and the target entity relations to obtain an entity relation set;

[0025] Pairing the sub-question entities with the entity relations in the entity relation set, and performing vocabulary expansion to obtain the first reasoning question sub-text;

[0026] Pairing the target entity with the entity relations in the entity relation set and performing vocabulary expansion to obtain a second reasoning question subtext;

[0027] Based on the question prompt logic, the first reasoning question sub-text and the second reasoning question sub-text are combined to obtain the reasoning question text.

[0028] Furthermore, the step of performing entity recognition on the reasoning question text and determining the target table to be queried according to the entity recognition result specifically includes:

[0029] Performing text segmentation processing on the reasoning question text, and identifying the entity name of the reasoning question text according to the text segmentation result;

[0030] According to the database table naming rules, each entity name in the reasoning question text is traversed and queried;

[0031] Determine the naming rules of the target table names that match the entity names of the reasoning question text;

[0032] The data table corresponding to the target table naming rule is used to determine the target table to be queried corresponding to the reasoning question text.

[0033] Furthermore, the step of obtaining the information of the target table to be queried specifically includes:

[0034] Perform entity relationship recognition on the reasoning question text to obtain the entity relationship in the reasoning question text;

[0035] Determine the table name of the target table to be queried according to the entity name of the reasoning question text;

[0036] The summary information, field information and business association logic of the target table to be queried are determined based on the entity relationship of the reasoning question text.

[0037] Furthermore, the steps of generating a first SQL query statement fragment based on the coarse-grained information and generating a second SQL query statement fragment based on the fine-grained information specifically include:

[0038] Define a first data structure and a second data structure, wherein the first data structure is adapted to the data structure of the coarse-grained information, and the second data structure is adapted to the data structure of the fine-grained information;

[0039] Using a first data structure to store coarse-grained information, and using a second data structure to store fine-grained information;

[0040] After the information storage is completed, the first data structure is programmed using a pre-written coarse-grained SQL function to obtain a first SQL query statement fragment;

[0041] The second data structure is programmed using a pre-written fine-grained SQL function to obtain a second SQL query statement fragment.

[0042] In order to solve the above technical problems, the embodiment of the present application further provides a database information query device, which adopts the following technical solution:

[0043] A database information query device, comprising:

[0044] The text reasoning module is used to obtain the initial question text uploaded by the user and perform text reasoning on the initial question text to obtain the reasoned question text;

[0045] A target table determination module is used to perform entity recognition on the reasoning question text and determine the target table to be queried according to the entity recognition result;

[0046] A query information module is used to obtain information of a target table to be queried, wherein the information of the target table to be queried includes coarse-grained information and fine-grained information, the coarse-grained information includes a table name and summary information, and the fine-grained information includes field information and business association logic;

[0047] A statement generation module, used to generate a first SQL query statement fragment based on the coarse-grained information, and to generate a second SQL query statement fragment based on the fine-grained information;

[0048] A statement combining module, used for combining the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement;

[0049] The information query module is used to input SQL query statements into the information query system of the database to obtain information query results.

[0050] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0051] A computer device comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the database information query method as described in any one of the above when executing the computer-readable instructions.

[0052] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0053] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the database information query method as described in any one of the above.

[0054] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0055] The present application discloses a method, device, equipment and storage medium for information query of a database, and belongs to the field of artificial intelligence technology. The present application obtains an initial question text and performs text reasoning to obtain a reasoning question text; performs entity recognition on the reasoning question text to determine the target table to be queried; obtains information of the target table to be queried, wherein the information of the target table to be queried includes coarse-grained information and fine-grained information; generates a first SQL query statement fragment based on the coarse-grained information, and generates a second SQL query statement fragment based on the fine-grained information; combines the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement; inputs the SQL query statement into the information query system of the database to obtain an information query result. The present application also relates to the field of blockchain technology, and the question text is stored on the blockchain node. Compared with traditional solutions, the SQL query statements generated by the present application perform better in terms of completeness, accuracy and consistency. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0057] Figure 1 An exemplary system architecture diagram is shown in which the present application can be applied;

[0058] Figure 2 A flowchart showing an embodiment of a method for querying information in a database according to the present application is shown;

[0059] Figure 3 A schematic diagram showing the structure of an embodiment of a database information query device according to the present application;

[0060] Figure 4 A schematic structural diagram of an embodiment of a computer device according to the present application is shown. DETAILED DESCRIPTION

[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0062] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0063] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0064] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.

[0065] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0066] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.

[0067] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .

[0068] It should be noted that the database information query method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the database information query device is generally arranged in the server / terminal device.

[0069] It should be understood that Figure 1 The numbers of terminal devices, networks and servers in the embodiment are merely illustrative. The above system may have any number of terminal devices, networks and servers according to implementation requirements.

[0070] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for querying information in a database according to the present application. The method for querying information in a database comprises the following steps:

[0071] S201, obtaining an initial question text uploaded by a user, and performing text reasoning on the initial question text to obtain a reasoned question text.

[0072] Specifically, first, the system receives the initial question text uploaded by the user. These questions contain different requirements for querying the database, such as business data analysis, specific field query, etc. Since users ask questions in a variety of ways, there may be incomplete or ambiguous situations. The system needs to parse and reason about the questions through natural language processing (NLP) technology. The reasoning process includes steps such as grammatical parsing, context analysis, and semantic understanding to identify the user's real query needs. For example, if the user's question does not explicitly mention a specific table or field, the system can infer a reasonable reasoning question text based on background knowledge and context to ensure that the query is more accurate. Through text reasoning, the system can convert the user's natural language questions into a more precise and structured question form, improving the accuracy of entity recognition and SQL statement generation.

[0073] In a specific embodiment of the present application, text reasoning can be achieved by combining Chain of Thought (COT) and Retrieval Augmented Generation (RAG) technology, which can more effectively reason and rewrite the initial question text uploaded by the user. Specifically, the system will break down the problem into a series of logical steps, and through step-by-step reasoning, ensure that each step clearly expresses the user's true intention. For example, the question uploaded by the user is "I want to know what product had the highest sales last year?" At this time, the system first recognizes that the core of the query is "the product with the highest sales", and infers the required time range (last year), query content (sales) and target (product) in turn to form a chain of thought. In this process, COT can gradually refine the problem logic and ensure the accuracy of reasoning.

[0074] Next, the system uses RAG technology to further enrich the reasoning process by combining the retrieval module. RAG not only generates new text, but also retrieves relevant information from external databases or knowledge bases to supplement the incomplete information in the user's question. For example, RAG will retrieve information about the specific year referred to by "last year" and the sales-related tables in the database, making it more accurate when generating reasoning question text. Through the logical reasoning of COT and the retrieval supplement of RAG, a structured and clear question text is finally obtained, which is convenient for entity recognition and SQL generation operations.

[0075] S202, performing entity recognition on the reasoning question text, and determining a target table to be queried according to the entity recognition result.

[0076] Specifically, entity recognition is an important part of text understanding, which is used to identify key nouns or phrases from the reasoning question text, especially entities related to the database structure, such as table names, field names, or business terms. Through entity recognition technology in natural language processing, the system can automatically extract these entities and map them to actual tables or fields in the database. For example, in the question "query sales data" raised by the user, the system can recognize that "sales" is a key entity and map it to a database table or field related to sales. Based on these identified entities, the system can preliminarily determine the query target table, and may also determine multiple target tables based on multiple entity recognition results. At the same time, the system will further filter and associate the tables that may be involved based on the business logic relationship between the entities to ensure that the query covers all relevant data.

[0077] S203, obtaining information of the target table to be queried, wherein the information of the target table to be queried includes coarse-grained information and fine-grained information, the coarse-grained information includes the table name and summary information, and the fine-grained information includes field information and business association logic.

[0078] Specifically, once the target table to be queried is determined, the system will further obtain detailed information related to the table. This information is usually divided into two categories: coarse-grained information and fine-grained information. Coarse-grained information is the basic information of the table, usually including the table name, summary information and the main purpose of the table. This part of information can help the system confirm whether the overall direction of the table meets the user's query needs. At the same time, the system will also analyze the relationship between the table and other database tables, and preliminarily establish the association between the table and the business. Fine-grained information is more detailed, including field information and business logic in the table. For example, field information can describe the specific data items contained in the table, and business association logic describes the complex business associations between the inside and outside of the table, such as foreign key relationships, field constraints, etc. By obtaining these two types of information, the system can fully understand the structure and content of the target table, thereby laying the foundation for generating accurate SQL query statements and ensuring the integrity and relevance of data queries.

[0079] S204: Generate a first SQL query statement fragment based on the coarse-grained information, and generate a second SQL query statement fragment based on the fine-grained information.

[0080] Specifically, the generation of SQL query statements in this application is a phased process, including SQL query statement fragments corresponding to coarse-grained information and query statement fragments corresponding to fine-grained information. First, a preliminary SQL query statement fragment is generated based on coarse-grained information. Coarse-grained information, such as table names and summary information, can help the system build the basic framework of SQL statements. For example, the system can generate a basic SELECT statement based on the table name and preliminarily specify the target table for the query. This process is similar to building a basic skeleton for the SQL statement, but the accuracy of SQL is not high enough at this time. Next, a more detailed SQL query statement fragment is generated based on fine-grained information. The fine-grained information includes field information and business-related logic, which can add more constraints and specific query details to the SQL statement. For example, the system can specify the specific query field based on the field information, and add WHERE conditions, JOIN operations, etc. according to the business logic, so as to further refine the query. Through the SQL fragments generated by these two steps, the system can build a SQL query statement that is both structural and can accurately reflect user needs, ensuring that the results of the data query are accurate and complete.

[0081] S205: Combine the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement.

[0082] Specifically, first, the system uses the first SQL query fragment generated based on coarse-grained information as the basic framework of the SQL statement, such as SELECT, FROM and other basic structures have been determined. Then, the system adds the second SQL query fragment to the basic framework to refine the query conditions and logical operations. For example, the fragment based on fine-grained information can contain specific fields of the query, WHERE conditions, ORDER BY sorting, etc. At this time, the system will optimize and combine according to different business needs to ensure that the SQL statement can not only achieve complete data query, but also avoid redundant operations and improve query efficiency. At the same time, the system may also further verify and optimize the SQL statement to ensure that the statement syntax is correct and the logic is reasonable. For example, if there are related queries for multiple tables, the system will ensure that the JOIN operation is correct and the field matching is reasonable. In this step, the final generated SQL query statement can be directly used for database query to meet the user's specific data needs.

[0083] S206, inputting the SQL query statement into the information query system of the database to obtain the information query result.

[0084] Specifically, when the SQL query statement is generated, the system submits the statement to the database information query system for execution. The execution of SQL query is the core link of the interaction between the database and the system. The database engine will parse the request according to the SQL statement, read the data in the corresponding tables and fields, and apply relevant query conditions, sorting rules, aggregation functions and other operations. The speed and quality of the query results returned will depend on the complexity of the SQL statement, the scale and performance of the database. The system may also perform preliminary processing on the query results at this stage, such as formatting data or aggregating results, so as to better meet the user's display needs. If the query results are too large, the system may provide paging or filtering functions to help users browse and analyze data more conveniently. Finally, the system presents the queried information to the user in an intuitive way, completing the closed-loop process of the entire database information query. Through this method, users can efficiently and accurately obtain the required database information, greatly improving the query experience.

[0085] In the above embodiments, this application uses text reasoning and entity recognition technology, combined with coarse-grained and fine-grained information, to refine the process of generating SQL query statements. Coarse-grained information helps generate basic SQL query fragments, while fine-grained information further refines the query to ensure that the statement is more business-logically relevant. The SQL query statement generated in the end performs better in terms of completeness, accuracy, and consistency. At the same time, this application does not require a large amount of labeled data for model training, which reduces training costs and time consumption, and improves the query processing speed and improves the user experience.

[0086] Furthermore, the steps of obtaining the initial question text uploaded by the user and performing text reasoning on the initial question text to obtain the reasoned question text specifically include:

[0087] Generate a question prompt template, send the question prompt template to the user end, and instruct the user to fill in the question prompt template to obtain an initial question text;

[0088] Use the pre-trained thinking reasoning model to perform text reasoning on the initial question text to obtain the reasoning question text.

[0089] In this embodiment, the system first generates a question prompt template, which may contain structured prompts or question frameworks, such as common fields, time ranges, target data types, etc. for database queries, to help users express their query needs more clearly and accurately. By sending the template to the user end, the user can fill in the content related to their needs according to the prompts, thereby generating a more complete and standardized initial question text. Compared with free text input, template-based question prompts can reduce semantic ambiguity and ensure that the system can more easily parse the user's true intentions. Next, the system uses a pre-trained thinking reasoning model to conduct an in-depth analysis of the initial question text filled in by the user. The model is based on large-scale pre-training data and can supplement the missing information in the user input or infer its implicit intentions through logical reasoning, and finally generate a reasoning question text.

[0090] Through the above steps, the question prompt template simplifies the user input process, improves the completeness of the initial question text, and at the same time improves the accuracy of question reasoning with the help of the thinking reasoning model, making the final generated reasoning question text more accurate.

[0091] Furthermore, the steps of using the pre-trained thinking reasoning model to perform text reasoning on the initial question text to obtain the reasoning question text specifically include:

[0092] Get the question prompt logic of the question prompt template;

[0093] In the thinking reasoning model, the initial question text is split into several sub-question texts based on the question prompt logic;

[0094] Identify the entities and entity relationships of each sub-question text, and obtain sub-question entities and sub-question entity relationships;

[0095] Retrieve a target entity that matches the sub-question entity from a preset entity library, and retrieve a target entity relationship that matches the target entity from a preset entity relationship library;

[0096] Generate reasoning question text based on sub-question entities, target entities, sub-question entity relations and target entity relations.

[0097] In this embodiment, the system first obtains the prompt logic behind the question prompt template. This logic can help the system understand the user's overall query framework and expectations. The question prompt logic is designed based on specific fields, such as common problem types and field relationships in database queries. The question prompt logic guides the system on how to analyze and decompose the initial question text entered by the user. Based on this logic, the system uses a pre-trained thinking reasoning model to split the initial question text into multiple sub-question texts. The process of problem splitting is similar to breaking down complex query requirements into simple, manageable small problems, which is convenient for step-by-step reasoning and resolution. Next, the system identifies entities and entity relationships for each sub-question, extracts key components such as core nouns and verbs in the sub-questions, and the associations between entities. For example, the relationship between "product sales" and "time range" will be identified as "query conditions". Subsequently, the system retrieves target entities that match these sub-question entities from the preset entity library. For example, "product" may be mapped to the "commodity" table in the database. The system also retrieves the association relationship of the target entity from the entity relationship library to ensure that the business logic between the data is reasonable. Finally, based on the sub-question entities, target entities and their relations, the system generates a reasoning question text, which is more structured and conforms to the standard format of database queries.

[0098] Through the above steps, the accuracy and detail of question analysis are greatly improved through question splitting, entity matching and relationship retrieval. It can not only handle complex query requirements, but also generate reasoning question texts that are more in line with database logic through automatic completion and reasoning, ensuring query accuracy and completeness.

[0099] Furthermore, based on the sub-question entity, the target entity, the sub-question entity relationship and the target entity relationship, the step of generating the reasoning question text specifically includes:

[0100] Combine the sub-problem entity relations and the target entity relations to obtain an entity relation set;

[0101] Pairing the sub-question entities with the entity relations in the entity relation set, and performing vocabulary expansion to obtain the first reasoning question sub-text;

[0102] Pairing the target entity with the entity relations in the entity relation set and performing vocabulary expansion to obtain a second reasoning question subtext;

[0103] Based on the question prompt logic, the first reasoning question sub-text and the second reasoning question sub-text are combined to obtain the reasoning question text.

[0104] In this embodiment, the system first combines the sub-question entity relationship and the target entity relationship to form a complete entity relationship set, which summarizes all entities involved in the user's initial question text and their associations, such as the relationship between tables and fields and the corresponding business logic. In the next step, the system will pair the sub-question entity with the relationship in the entity relationship set, and generate a more detailed and complete first reasoning question sub-text through the vocabulary expansion technology in natural language processing (NLP). The vocabulary expansion can be achieved through synonym replacement, sentence changes, etc., so that the description of the sub-question is more in line with the language style of the database query. Similarly, the system performs the same pairing and expansion on the target entity and entity relationship to generate the second reasoning question sub-text. This step can ensure that the expression of the target entity is accurate and correct, while increasing the readability and rigor of the sentence. Finally, based on the question prompt logic mentioned above, the system combines the first reasoning question sub-text and the second reasoning question sub-text to generate the final reasoning question text, which not only reflects the user's query intention, but also integrates all relevant entities and relationships to form a structured and clear database query expression.

[0105] Through the above steps, the semantic accuracy and richness of the reasoning question text are ensured through the matching of entity relationships and vocabulary expansion. At the same time, through the combination of sub-texts, the reasoning question text is more consistent with the language and logical structure of the database query, which improves the integrity and execution efficiency of the final generated SQL query.

[0106] Furthermore, the step of performing entity recognition on the reasoning question text and determining the target table to be queried according to the entity recognition result specifically includes:

[0107] Performing text segmentation processing on the reasoning question text, and identifying the entity name of the reasoning question text according to the text segmentation result;

[0108] According to the database table naming rules, each entity name in the reasoning question text is traversed and queried;

[0109] Determine the naming rules of the target table names that match the entity names of the reasoning question text;

[0110] The data table corresponding to the target table naming rule is used to determine the target table to be queried corresponding to the reasoning question text.

[0111] In this embodiment, the system first performs word segmentation on the generated reasoning question text, the purpose of which is to break the entire text into multiple separate words or phrases, especially to identify the entity names therein, which usually refer to keywords related to the table name, field name or business logic in the database, such as "customer", "order" or "product". Through word segmentation, the system can extract these important entity words and match them with the table name naming rules in the database. The table name naming rules in the database may follow a specific format, such as "tb l_customer" represents the customer information table, and "tb l_order" represents the order table. The system will traverse each entity name in the reasoning question text according to these naming rules, compare them one by one, and determine which entity names are consistent with the table name naming rules in the database. During the matching process, the system not only performs direct string matching, but also uses fuzzy matching or synonym replacement and other technologies to ensure that even if the user's questioning method is slightly different from the database table name, the corresponding table name can still be found. Finally, the system determines the data table corresponding to the successfully matched table name naming rule as the target table to be queried in the reasoning question text. This process ensures that each entity in the reasoning question text has a clear database mapping, ensuring the accuracy and completeness of the query.

[0112] Through the above steps, through word segmentation processing and naming rule matching, the accurate association between the entity name in the reasoning question text and the database table name is achieved, ensuring that the user query requirements can be accurately mapped to the database structure, greatly improving the accuracy and efficiency of the query, and reducing the query failure problem caused by inconsistent table names.

[0113] Furthermore, the step of obtaining the information of the target table to be queried specifically includes:

[0114] Perform entity relationship recognition on the reasoning question text to obtain the entity relationship in the reasoning question text;

[0115] Determine the table name of the target table to be queried according to the entity name of the reasoning question text;

[0116] The summary information, field information and business association logic of the target table to be queried are determined based on the entity relationship of the reasoning question text.

[0117] In this embodiment, the system first conducts an in-depth analysis of the reasoning question text to identify the entity relationships in the text, that is, to determine the relationships between the various entities. This step is crucial because the entity relationship can reveal the logical background of the user's query, such as the relationship between "customer" and "order". After completing the entity relationship identification, the system uses the entity name in the reasoning question text to determine the table name of the corresponding target table to be queried based on the preset database structure and table name rules. This mapping not only ensures the consistency of the data. Next, the system further analyzes the entity relationship in the reasoning question text to obtain detailed information about the target table, including summary information, field information, and business association logic. The summary information can help the system understand the overall purpose of the target table, while the field information provides the definition of specific data items, and the business association logic describes the relationships and constraints between the fields in the table. Through these detailed information, the validity and accuracy of the generated SQL query statement are ensured.

[0118] Through the above steps, the precise match between the reasoning question text and the database structure is ensured through entity relationship recognition and target table information extraction, which greatly improves the query accuracy and execution efficiency.

[0119] Furthermore, the steps of generating a first SQL query statement fragment based on the coarse-grained information and generating a second SQL query statement fragment based on the fine-grained information specifically include:

[0120] Define a first data structure and a second data structure, wherein the first data structure is adapted to the data structure of the coarse-grained information, and the second data structure is adapted to the data structure of the fine-grained information;

[0121] Using a first data structure to store coarse-grained information, and using a second data structure to store fine-grained information;

[0122] After the information storage is completed, the first data structure is programmed using a pre-written coarse-grained SQL function to obtain a first SQL query statement fragment;

[0123] The second data structure is programmed using a pre-written fine-grained SQL function to obtain a second SQL query statement fragment.

[0124] In this embodiment, the system first defines data structures suitable for coarse-grained information and fine-grained information to ensure good scalability and compatibility of data during storage and processing. The first data structure contains basic data such as table name, summary information and related identifiers, while the second data structure is subdivided into more detailed data items such as specific field information, data type, business logic and association constraints. The system stores coarse-grained information and fine-grained information in these two structures respectively.

[0125] After completing the information storage, the system will call the pre-written SQL functions to perform data programming on the first data structure. These SQL functions can generate corresponding SQL query statement fragments based on the stored coarse-grained information, such as basic SELECT statements, which usually involve the selection of data tables and the setting of basic conditions. Subsequently, the system uses similar pre-written fine-grained SQL functions to program the second data structure to generate detailed SQL query fragments. These fragments will contain more complex query logic such as the selection of specific fields, WHERE conditions, ORDER BY and GROUP BY. Finally, the system generates coarse-grained and fine-grained SQL query fragments separately, and then obtains the final SQL query statement by combining the SQL statement fragments.

[0126] Through the above steps, the efficiency and accuracy of SQL query statement generation are improved through clear data structure definition and hierarchical storage, ensuring the flexibility and maintainability of complex queries, thereby significantly improving the overall performance of database operations.

[0127] In the above embodiments, the present application discloses a method for information query of a database, which belongs to the field of artificial intelligence technology. Compared with the traditional method that relies on the BERT model to generate SQL query statements, the present application uses text reasoning and entity recognition technology, combined with coarse-grained and fine-grained information, to refine the process of generating SQL query statements. Coarse-grained information helps to generate basic SQL query fragments, and fine-grained information further refines the query to ensure that the statement is more business-logically relevant. The final generated SQL query statement performs better in terms of completeness, accuracy and consistency. At the same time, the present application does not require a large amount of labeled data for model training, which reduces training costs and time consumption, and improves the query processing speed and improves the user experience. On the whole, the present application significantly optimizes the intelligence level of database information query through automated SQL generation and reasoning technology.

[0128] In this embodiment, the information query method of the database is executed on the electronic device (eg Figure 1 The server shown in the figure) can receive instructions or obtain data through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0129] It should be emphasized that in order to further ensure the privacy and security of the above question text information, the above question text information can also be stored in a blockchain node.

[0130] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0131] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0132] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0133] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0134] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0135] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a database information query device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0136] like Figure 3 As shown, the database information query device 300 described in this embodiment includes:

[0137] The text reasoning module 301 is used to obtain the initial question text uploaded by the user and perform text reasoning on the initial question text to obtain a reasoned question text;

[0138] The target table determination module 302 is used to perform entity recognition on the reasoning question text and determine the target table to be queried according to the entity recognition result;

[0139] The query information module 303 is used to obtain information of the target table to be queried, wherein the information of the target table to be queried includes coarse-grained information and fine-grained information, the coarse-grained information includes the table name and summary information, and the fine-grained information includes field information and business association logic;

[0140] A statement generation module 304, configured to generate a first SQL query statement fragment based on the coarse-grained information, and to generate a second SQL query statement fragment based on the fine-grained information;

[0141] A statement combining module 305, used for combining the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement;

[0142] The information query module 306 is used to input the SQL query statement into the information query system of the database to obtain the information query result.

[0143] Furthermore, the text reasoning module 301 is specifically used for:

[0144] Generate a question prompt template, send the question prompt template to the user end, and instruct the user to fill in the question prompt template to obtain an initial question text; use a pre-trained thinking reasoning model to perform text reasoning on the initial question text to obtain a reasoned question text.

[0145] Furthermore, the text reasoning module 301 is further used to:

[0146] Obtain the question prompt logic of the question prompt template; in the thinking reasoning model, split the initial question text based on the question prompt logic to obtain several sub-question texts; identify the entities and entity relationships of each sub-question text to obtain sub-question entities and sub-question entity relationships; retrieve the target entity that matches the sub-question entity from the preset entity library, and retrieve the target entity relationship that matches the target entity from the preset entity relationship library; generate the reasoning question text based on the sub-question entity, the target entity, the sub-question entity relationship and the target entity relationship.

[0147] Furthermore, the text reasoning module 301 is further used to:

[0148] Combine sub-question entity relations and target entity relations to obtain an entity relation set; pair sub-question entities with entity relations in the entity relation set, and perform vocabulary expansion to obtain a first reasoning question sub-text; pair target entities with entity relations in the entity relation set, and perform vocabulary expansion to obtain a second reasoning question sub-text; based on question prompt logic, combine the first reasoning question sub-text and the second reasoning question sub-text to obtain a reasoning question text.

[0149] Furthermore, the target table determination module 302 is specifically used for:

[0150] Perform text segmentation on the reasoning question text, and identify the entity name of the reasoning question text based on the text segmentation result; traverse and query each entity name in the reasoning question text according to the table name naming rule of the database; determine the target table name naming rule that matches the entity name of the reasoning question text; determine the target table to be queried corresponding to the reasoning question text from the data table corresponding to the target table name naming rule.

[0151] Furthermore, the query information module 303 is specifically used for:

[0152] Perform entity relationship recognition on the reasoning question text to obtain the entity relationship in the reasoning question text; determine the table name of the target table to be queried based on the entity name of the reasoning question text; determine the summary information, field information and business association logic of the target table to be queried based on the entity relationship of the reasoning question text.

[0153] Furthermore, the statement generation module 304 is specifically used for:

[0154] A first data structure and a second data structure are defined, wherein the first data structure is adapted to the data structure of coarse-grained information, and the second data structure is adapted to the data structure of fine-grained information; the first data structure is used to store coarse-grained information, and the second data structure is used to store fine-grained information; after completing the information storage, the first data structure is data-programmed using a pre-written coarse-grained SQL function to obtain a first SQL query statement fragment; the second data structure is data-programmed using a pre-written fine-grained SQL function to obtain a second SQL query statement fragment.

[0155] In the above embodiments, the present application discloses a database information query device, which belongs to the field of artificial intelligence technology. Compared with the traditional method that relies on the BERT model to generate SQL query statements, the present application uses text reasoning and entity recognition technology, combined with coarse-grained and fine-grained information, to refine the process of generating SQL query statements. Coarse-grained information helps to generate basic SQL query fragments, and fine-grained information further refines the query to ensure that the statement is more business-logically relevant. The final generated SQL query statement performs better in terms of completeness, accuracy and consistency. At the same time, the present application does not require a large amount of labeled data for model training, which reduces training costs and time consumption, and improves the query processing speed and improves the user experience. On the whole, the present application significantly optimizes the intelligence level of database information query through automated SQL generation and reasoning technology.

[0156] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0157] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 4 with a memory 41, a processor 42, and a network interface 43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0158] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0159] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the computer device 4. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the information query method of the database, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0160] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the information query method of the database.

[0161] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0162] In the above embodiments, the present application discloses a computer device, which belongs to the field of artificial intelligence technology. Compared with the traditional method that relies on the BERT model to generate SQL query statements, the present application uses text reasoning and entity recognition technology, combined with coarse-grained and fine-grained information, to refine the process of generating SQL query statements. Coarse-grained information helps to generate basic SQL query fragments, and fine-grained information further refines the query to ensure that the statement is more business-logically relevant. The final generated SQL query statement performs better in terms of completeness, accuracy and consistency. At the same time, the present application does not require a large amount of labeled data for model training, which reduces training costs and time consumption, and improves the query processing speed and improves the user experience. On the whole, the present application significantly optimizes the intelligence level of database information query through automated SQL generation and reasoning technology.

[0163] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the database information query method as described above.

[0164] In the above embodiments, the present application discloses a computer-readable storage medium, which belongs to the field of artificial intelligence technology. Compared with the traditional method that relies on the BERT model to generate SQL query statements, the present application uses text reasoning and entity recognition technology, combined with coarse-grained and fine-grained information, to refine the process of generating SQL query statements. Coarse-grained information helps to generate basic SQL query fragments, and fine-grained information further refines the query to ensure that the statement is more business-logically relevant. The final generated SQL query statement performs better in terms of completeness, accuracy and consistency. At the same time, the present application does not require a large amount of labeled data for model training, which reduces training costs and time consumption, and improves the query processing speed and improves the user experience. On the whole, the present application significantly optimizes the intelligence level of database information query through automated SQL generation and reasoning technology.

[0165] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0166] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0167] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A method for querying information in a database, characterized in that: include: Obtaining an initial question text uploaded by a user, and performing text reasoning on the initial question text to obtain a reasoned question text; Performing entity recognition on the reasoning question text, and determining a target table to be queried according to the entity recognition result; Acquire information of the target table to be queried, wherein the information of the target table to be queried includes coarse-grained information and fine-grained information, the coarse-grained information includes a table name and summary information, and the fine-grained information includes field information and business association logic; generating a first SQL query statement fragment based on the coarse-grained information, and generating a second SQL query statement fragment based on the fine-grained information; Combining the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement; The SQL query statement is input into the information query system of the database to obtain the information query result.

2. The method for querying information in a database according to claim 1, characterized in that: The step of obtaining the initial question text uploaded by the user and performing text reasoning on the initial question text to obtain the reasoned question text specifically includes: Generate a question prompt template, send the question prompt template to the user end, and instruct the user to fill in the question prompt template to obtain the initial question text; The initial question text is subjected to text reasoning using a pre-trained thinking reasoning model to obtain the reasoning question text.

3. The method for querying information in a database according to claim 2, characterized in that: The step of using the pre-trained thinking reasoning model to perform text reasoning on the initial question text to obtain the reasoning question text specifically includes: Obtain the question prompt logic of the question prompt template; In the thinking reasoning model, the initial question text is split into several sub-question texts based on the question prompt logic; Identify the entities and entity relationships of each of the sub-question texts to obtain sub-question entities and sub-question entity relationships; Retrieving a target entity matching the sub-question entity from a preset entity library, and retrieving a target entity relationship matching the target entity from a preset entity relationship library; The reasoning question text is generated based on the sub-question entity, the target entity, the sub-question entity relationship and the target entity relationship.

4. The method for querying information in a database according to claim 3, characterized in that: The step of generating the reasoning question text based on the sub-question entity, the target entity, the sub-question entity relationship and the target entity relationship specifically includes: Combining the sub-problem entity relationship and the target entity relationship to obtain an entity relationship set; Pairing the sub-question entity with the entity relationship in the entity relationship set, and performing vocabulary expansion to obtain a first reasoning question sub-text; Pairing the target entity with the entity relationship in the entity relationship set, and performing vocabulary expansion to obtain a second reasoning question subtext; Based on the question prompt logic, the first reasoning question sub-text and the second reasoning question sub-text are combined to obtain the reasoning question text.

5. The method for querying information in a database according to claim 1, characterized in that: The step of performing entity recognition on the reasoning question text and determining the target table to be queried according to the entity recognition result specifically includes: Performing text segmentation processing on the reasoning question text, and identifying entity names of the reasoning question text according to the text segmentation result; Performing a traversal query on each entity name in the reasoning question text according to the table name naming rule of the database; Determine a target table name naming rule that matches the entity name of the reasoning question text; The data table corresponding to the target table name naming rule is used to determine the target table to be queried corresponding to the reasoning question text.

6. The method for querying information in a database according to claim 5, characterized in that: The step of obtaining the information of the target table to be queried specifically includes: Performing entity relationship recognition on the reasoning question text to obtain entity relationships in the reasoning question text; Determine the table name of the target table to be queried according to the entity name of the reasoning question text; The summary information, field information and business association logic of the target table to be queried are determined according to the entity relationship of the reasoning question text.

7. The method for querying information in a database according to claim 1, characterized in that: The steps of generating a first SQL query statement fragment based on the coarse-grained information and generating a second SQL query statement fragment based on the fine-grained information specifically include: defining a first data structure and a second data structure, wherein the first data structure is adapted to the data structure of the coarse-grained information, and the second data structure is adapted to the data structure of the fine-grained information; Using the first data structure to store the coarse-grained information, and using the second data structure to store the fine-grained information; After the information storage is completed, the first data structure is programmed using a pre-written coarse-grained SQL function to obtain the first SQL query statement fragment; The second data structure is programmed using a pre-written fine-grained SQL function to obtain the second SQL query statement fragment.

8. A database information query device, characterized in that: include: A text reasoning module is used to obtain the initial question text uploaded by the user and perform text reasoning on the initial question text to obtain a reasoned question text; A target table determination module is used to perform entity recognition on the reasoning question text and determine the target table to be queried according to the entity recognition result; A query information module, used to obtain information of the target table to be queried, wherein the information of the target table to be queried includes coarse-grained information and fine-grained information, the coarse-grained information includes table name and summary information, and the fine-grained information includes field information and business association logic; A statement generation module, used to generate a first SQL query statement fragment based on the coarse-grained information, and to generate a second SQL query statement fragment based on the fine-grained information; A statement combining module, used for combining the first SQL query statement fragment and the second SQL query statement fragment to generate an SQL query statement; The information query module is used to input the SQL query statement into the information query system of the database to obtain the information query result.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the database information query method according to any one of claims 1 to 7 when executing the computer-readable instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the database information query method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Query statement processing method and device, vehicle and storage medium

    CN120804139A

  • Query statement processing method and device, vehicle, and storage medium

    CN120804139B

  • Database slow query statement intelligent analysis and optimization system based on artificial intelligence

    CN121029811A

  • Information retrieval method and device

    CN121365138A