CN-121996680-A - Database query statement generation method, system, storage medium and program product
Abstract
The invention provides a generation method of a database query statement based on graphics, which comprises the steps of obtaining a data query request aiming at a target database, obtaining a database structure diagram for representing a target database structure, carrying out graphic extraction processing and text extraction processing on the database structure diagram to obtain an extraction result, wherein the extraction result at least comprises entity nodes in the database structure diagram, entity names and entity attribute names corresponding to the entity nodes, and association relations between the entity nodes, mapping the entity names into data table names, mapping the entity attribute names into field names, mapping the association relations between the entity nodes into association relations between data tables, so as to obtain structure information of the target database, constructing prompt words at least comprising the data query request and the structure information according to the data query request and the structure information, and inputting the prompt words into an artificial intelligent model, so as to obtain the database query statement.
Inventors
- WANG PO
- CHEN XIAOMEI
- WU LEI
- HUANG WEN
Assignees
- 重庆壹弘科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260126
Claims (11)
- 1. A method for generating a database query statement based on patterning, the method comprising: Acquiring a data query request aiming at a target database; Obtaining a database structure diagram for representing the target database structure, and carrying out graphic extraction processing and text extraction processing on the database structure diagram to obtain an extraction result, wherein the extraction result at least comprises entity nodes in the database structure diagram, entity names and entity attribute names corresponding to the entity nodes, and association relations among the entity nodes; Mapping the entity names into data table names, mapping the entity attribute names into field names, and mapping the association relation between the entity nodes into association relation between data tables to obtain the structure information of the target database; constructing a prompt word at least comprising the data query request and the structure information according to the data query request and the structure information, and And inputting the prompt word into an artificial intelligent model to obtain a database query statement which accords with the structural information constraint and corresponds to the data query request.
- 2. The method of generating a graph-based database query statement of claim 1, wherein the structural information constraint comprises at least one of: the database query statement uses the names and/or field names of the data tables contained in the structure information; the database query statement uses connection conditions and/or connection paths between the data tables determined at least according to the association relationship between the data tables.
- 3. The method for generating a query sentence based on a graphic database according to claim 1, wherein performing a graphic extraction process and a text extraction process on the database structure diagram to obtain an extraction result comprises: performing word extraction processing on the database structure diagram to obtain a word object, wherein the word object comprises text content and first position information of the text content in the database structure diagram; performing graph extraction processing on the database structure graph to obtain a graph object, wherein the graph object comprises a graph shape and second position information of the graph shape in the database structure graph; determining the graphic objects meeting the first preset shape characteristic and the second preset shape characteristic as entity nodes and entity node connecting lines respectively; Determining a position corresponding relation between the text content and the entity node connecting line based on the first position information of the text object and the spatial relation represented by the second position information of the entity node and the entity node connecting line, and determining a connection corresponding relation between the entity node connecting line and the entity node; and determining the association relationship among the entity name, the entity attribute name and the entity node according to the position corresponding relationship and the connection corresponding relationship so as to obtain the extraction result.
- 4. The method for generating a query statement based on a graphical database according to claim 3, wherein determining the association between the entity name, the entity attribute name, and the entity node according to the position correspondence and the connection correspondence to obtain the extraction result comprises: Determining the text content in a first preset area of the entity node as the entity name and the text content in a second preset area of the entity node as the entity attribute name according to the position corresponding relation between the text content and the entity node, and And determining the association relation between the entity nodes according to the position correspondence relation between the text content and the entity node connecting lines and the connection correspondence relation between the entity node connecting lines and the entity nodes.
- 5. The method for generating a graph-based database query term as recited in claim 1, wherein the generating method further comprises performing a prompt enhancement process on the prompt before the prompt is input to the artificial intelligence model, The prompt word enhancement processing comprises the following steps: and carrying out term standardization processing on the prompt words according to the standard term library of the target field corresponding to the target database so as to generate the prompt words represented by the preset standard terms.
- 6. The method for generating a graph-based database query term as recited in claim 1, wherein the generating method further comprises performing a prompt enhancement process on the prompt before the prompt is input to the artificial intelligence model, The prompt word enhancement processing comprises the following steps: identifying a data query intention based on the data query request in the prompt word; Optimizing missing and/or semantically ambiguous information in the data query request based on the data query intention, the structural information of the target database and preset rules, wherein the information at least comprises information related to at least one of a data table, a field, a filtering condition, an aggregation mode and a sequencing mode.
- 7. The method for generating a query statement based on a graphical database as claimed in claim 1, wherein the target database is a medical domain database.
- 8. A system for generating a graphical-based database query statement, the system comprising: the acquisition module acquires a data query request aiming at a target database; Obtaining a database structure diagram for representing the target database structure, and carrying out graphic extraction processing and text extraction processing on the database structure diagram to obtain an extraction result, wherein the extraction result at least comprises entity nodes in the database structure diagram, entity names and entity attribute names corresponding to the entity nodes, and association relations among the entity nodes; Mapping the entity names into data table names, mapping the entity attribute names into field names, and mapping the association relation between the entity nodes into association relation between data tables to obtain the structure information of the target database; constructing a prompt word at least comprising the data query request and the structure information according to the data query request and the structure information, and And the generation module is used for inputting the prompt word into an artificial intelligent model to obtain a database query statement which accords with the structural information constraint and corresponds to the data query request.
- 9. The graphical-based database query statement generation system of claim 8, wherein the structural information constraint comprises at least one of: the database query statement uses the names and/or field names of the data tables contained in the structure information; the database query statement uses connection conditions and/or connection paths between the data tables determined at least according to the association relationship between the data tables.
- 10. A computer readable storage medium having stored therein computer executable instructions which, when executed by a processor, implement the method of generating a graphical-based database query statement as claimed in any one of claims 1 to 7.
- 11. A computer program product comprising computer-executable instructions which, when executed by a processor, implement a method of generating a graphical-based database query statement as claimed in any one of claims 1 to 7.
Description
Database query statement generation method, system, storage medium and program product Technical Field The present disclosure relates to a method, system, storage medium and program product for generating database query statement based on graphics. Background The database is widely used for storing and managing structured data, and in practical application, operations such as querying, updating, statistical analysis and the like on the data are generally realized through a structured query language (Structured Query Language, SQL). Based on this, a technical scheme of automatically generating SQL according to a query request input by a user by using an artificial intelligence model has appeared in the prior art. However, in practical applications in the medical field, data in the medical database often originate from multiple business systems, such as an electronic medical record system, a test information system, an image archiving and communication system, and a pathology system, and cover multiple types of business data in the patient diagnosis and treatment process. In such a database, the number of data tables and fields is usually large, the naming standards of table names and field names are not uniform, multiple tables and field expression modes may exist in the database for the same medical concept, and it is difficult to uniquely determine the corresponding table names and field names according to query semantics. Under the situation, when the table and the field are selected according to the query request, the conventional scheme for generating SQL based on the artificial intelligence model is easy to cause the problems of table name errors, field absence and the like, and further the generated SQL statement cannot be executed correctly on the target database. Further, in a medical scenario, the same patient may correspond to multiple visits, examinations, treatments, and follow-up records, related data are typically stored in multiple data tables in a scattered manner, and multiple levels of association between the data tables are established based on connection conditions such as patient identification, visit identification, and the like. Due to the influence of the data dispersion and the association complexity, when the conventional scheme for generating SQL based on the artificial intelligence model performs multi-table association, incorrect connection conditions or connection paths are sometimes adopted, so that the generated SQL statement cannot be executed correctly on a target database, or the query result is inaccurate although the SQL statement can be executed, and the data query request is difficult to meet. Disclosure of Invention The embodiment of the disclosure provides a method, a system, a storage medium and a program product for generating a database query statement based on graphics, which can improve the executable performance and the query accuracy of the generated database query statement on a target database. The embodiment of the disclosure provides a generation method of a database query statement based on graphics, which comprises the steps of obtaining a data query request aiming at a target database, obtaining a database structure diagram used for representing the target database structure, carrying out graphic extraction processing and text extraction processing on the database structure diagram to obtain an extraction result, wherein the extraction result at least comprises entity nodes, entity names and entity attribute names corresponding to the entity nodes and association relations among the entity nodes in the database structure diagram, mapping the entity names into data table names, mapping the entity attribute names into field names, mapping the association relations among the entity nodes into association relations among data tables to obtain structure information of the target database, constructing a prompt word at least comprising the data query request and the structure information according to the data query request and the structure information, and inputting the prompt word into a manual intelligent model to obtain the database query statement which accords with the structure information constraint and corresponds to the data query request. In an embodiment of the disclosure, the structure information constraint includes at least one of the database query statement using names and/or field names of the data tables contained in the structure information, and the database query statement using connection conditions and/or connection paths between the data tables determined at least according to association relationships between the data tables. In the embodiment of the disclosure, graphic extraction processing and text extraction processing are performed on the database structure diagram to obtain an extraction result, the method comprises the steps of performing text extraction processing on the database structure diagram to obtain a text object, wher