Database query statement generation method and system, storage medium and program product

By extracting graphical and textual information from the structure diagram of a medical database, mapping it to structural information, and combining it with data query requests to generate SQL statements, the problems of incorrect table names and incorrect relationships in medical databases were solved, improving the executability and accuracy of queries.

CN121996680APending Publication Date: 2026-05-08CHONGQING YIHONG TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING YIHONG TECHNOLOGY CO LTD
Filing Date
2026-01-26
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

In medical databases, due to inconsistent naming of data tables and fields and the complexity of multi-level relationships, existing SQL statements generated based on artificial intelligence models are prone to errors such as incorrect table names, non-existent fields, and incorrect relationships between tables, resulting in inaccurate query results or inability to execute.

Method used

By obtaining the database structure diagram, extracting graphics and text, mapping entity nodes to data tables and fields, constructing structural information, and combining it with data query requests, inputting it into an artificial intelligence model, and generating database query statements that conform to the constraints of the structural information.

Benefits of technology

It improves the executability and accuracy of generated database queries on the target database, reduces table name errors and table relationship errors, and ensures the accuracy of query results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121996680A_ABST
    Figure CN121996680A_ABST
Patent Text Reader

Abstract

The invention provides a generation method of database query statements based on graphics. The generation method comprises the steps of obtaining a data query request for a target database; obtaining a database structure chart used for representing a target database structure, and performing graph extraction processing and character extraction processing on the database structure chart to obtain an extraction result, 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 an association relationship between the entity nodes; mapping the entity name into a data table name, mapping the entity attribute name into a field name, and mapping an association relationship between the entity nodes into an association relationship between data tables to obtain structure information of the target database; according to the data query request and the structure information, constructing a cue word at least comprising the data query request and the structure information; and inputting the cue word into an artificial intelligence model to obtain a database query statement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to a method, system, storage medium, and program product for generating graphical database query statements. Background Technology

[0002] Databases are widely used for storing and managing structured data. In practical applications, Structured Query Language (SQL) is typically used to perform operations such as querying, updating, and statistical analysis of the data. Based on this, existing technologies have developed solutions that utilize artificial intelligence models to automatically generate SQL based on user-input query requests.

[0003] However, in practical applications in the medical field, data in medical databases often originates from multiple business systems, such as electronic medical record systems, laboratory information systems, image archiving and communication systems, and pathology systems, covering various types of business data during patient diagnosis and treatment. In such databases, the number of tables and fields is typically large, and the naming conventions for table and field names are inconsistent. The same medical concept may exist in multiple tables and field representations within the database, making it difficult to uniquely determine the corresponding table and field names based on query semantics. In this situation, existing solutions for generating SQL based on artificial intelligence models are prone to problems such as incorrect table names and non-existent fields when selecting tables and fields according to query requests, resulting in the generated SQL statements failing to execute correctly on the target database.

[0004] Furthermore, in medical settings, a single patient may have multiple visits, examinations, treatments, and follow-up records. This data is typically stored across multiple tables, and these tables require multi-level associations based on patient identifiers, visit identifiers, and other join conditions. Due to the complexity of this data dispersion and association, existing AI-based SQL generation solutions sometimes use incorrect join conditions or paths when performing multi-table joins. This can lead to generated SQL statements failing to execute correctly on the target database, or executing but producing inaccurate results that fail to satisfy data query requests. Summary of the Invention

[0005] The embodiments of this disclosure provide a method, system, storage medium, and program product for generating graphical database query statements, which can improve the executability and query accuracy of the generated database query statements on the target database.

[0006] This disclosure provides a graphical database query statement generation method, comprising: obtaining a data query request for a target database; obtaining a database structure diagram representing the structure of the target database, and performing graphical extraction and text extraction processing on the database structure diagram to obtain extraction results, wherein the extraction results include at least entity nodes in the database structure diagram, entity names and entity attribute names corresponding to the entity nodes, and the relationships between the entity nodes; mapping the entity names to table names, mapping the entity attribute names to field names, and mapping the relationships between entity nodes to relationships between table names to obtain the structure information of the target database; constructing prompt words that include at least the data query request and the structure information based on the data query request and the structure information; and inputting the prompt words into an artificial intelligence model to obtain a database query statement that conforms to the constraints of the structure information and corresponds to the data query request.

[0007] In embodiments of this disclosure, the structural information constraints include at least one of the following: the database query statement uses the name and / or field name of the data table contained in the structural information; the database query statement uses connection conditions and / or connection paths between the data tables determined at least based on the association relationships between the data tables.

[0008] In embodiments of this disclosure, the database structure diagram is subjected to graphic extraction processing and text extraction processing to obtain extraction results, including: performing text extraction processing on the database structure diagram to obtain text objects, wherein the text objects include text content and a first position information of the text content in the database structure diagram; performing graphic extraction processing on the database structure diagram to obtain graphic objects, wherein the graphic objects include graphic shapes and a second position information of the graphic shapes in the database structure diagram; determining the graphic objects that satisfy a first preset shape feature and a second preset shape feature as entity nodes and entity node connecting lines, respectively; determining the positional correspondence between the text content and entity nodes and entity node connecting lines, and determining the connection correspondence between entity node connecting lines and entity nodes, based on the spatial relationship represented by the first position information of the text objects and the second position information of the entity nodes and entity node connecting lines; and determining the entity name, entity attribute name, and association relationship between entity nodes according to the positional correspondence and the connection correspondence to obtain the extraction results.

[0009] In embodiments of this disclosure, determining the entity name, entity attribute name, and association between entity nodes based on the positional correspondence and the connection correspondence to obtain the extraction result includes: determining the text content located in a first preset area of ​​the entity node as the entity name and the text content located in a second preset area of ​​the entity node as the entity attribute name based on the positional correspondence between the text content and the entity node; and determining the association between entity nodes based on the positional correspondence between the text content and the entity node connection line, and the connection correspondence between the entity node connection line and the entity node.

[0010] In embodiments of this disclosure, the generation method further includes: before inputting the prompt word into the artificial intelligence model, performing prompt word enhancement processing on the prompt word, the prompt word enhancement processing including: performing terminology standardization processing on the prompt word according to the target domain standard terminology library corresponding to the target database, so as to generate the prompt word represented using preset standard terms.

[0011] In embodiments of this disclosure, the generation method further includes: before inputting the prompt word into the artificial intelligence model, performing prompt word enhancement processing on the prompt word, the prompt word enhancement processing including: identifying the data query intent based on the data query request in the prompt word; and optimizing the missing and / or semantically ambiguous information in the data query request based on the data query intent, the structural information of the target database, and preset rules, wherein the information includes at least information related to at least one of the data table, field, filtering conditions, aggregation method, and sorting method.

[0012] In this embodiment of the disclosure, the target database is a medical database.

[0013] This disclosure provides a graphical database query statement generation system, comprising: an acquisition module for acquiring a data query request for a target database; acquiring a database structure diagram representing the structure of the target database, and performing graphical and text extraction processing on the database structure diagram to obtain extraction results, wherein the extraction results include at least entity nodes in the database structure diagram, entity names and entity attribute names corresponding to the entity nodes, and the relationships between the entity nodes; mapping the entity names to table names, mapping the entity attribute names to field names, and mapping the relationships between entity nodes to relationships between table names to obtain the structure information of the target database; constructing prompt words that include at least the data query request and the structure information based on the data query request and the structure information; and a generation module for inputting the prompt words into an artificial intelligence model to obtain a database query statement that conforms to the constraints of the structure information and corresponds to the data query request.

[0014] In embodiments of this disclosure, the structural information constraints include at least one of the following: the database query statement uses the name and / or field name of the data table contained in the structural information; the database query statement uses connection conditions and / or connection paths between the data tables determined at least based on the association relationships between the data tables.

[0015] Embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the graphical database query statement generation method described in any of the preceding claims.

[0016] Embodiments of this disclosure provide a computer program product including computer execution instructions that, when executed by a processor, implement the graphical database query statement generation method as described in any of the preceding claims.

[0017] The method, system, storage medium, and program products for generating graphical database query statements provided in this disclosure can improve the executability and query accuracy of the generated database query statements on the target database. Attached Figure Description

[0018] Figure 1 This is a flowchart of a method for generating graphical database query statements according to one or more embodiments of the present disclosure.

[0019] Figure 2 A flowchart of step S102 provided according to one or more embodiments of the present disclosure is shown.

[0020] Figure 3 This is a schematic diagram of a database structure provided according to one or more embodiments of this disclosure.

[0021] Figure 4 This is a structural block diagram of a graphical database query statement generation system provided according to one or more embodiments of the present disclosure. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this specification clearer, the following detailed description is provided in conjunction with specific embodiments and the accompanying drawings.

[0023] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this disclosure should have the ordinary meaning understood by one of ordinary skill in the art to which this disclosure pertains. The terms "first," "second," and similar words used in the examples of this disclosure do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0024] To address issues such as incorrect table names, missing fields, and incorrect inter-table relationships that easily occur when generating database query statements (e.g., SQL) based on artificial intelligence models in the medical field, embodiments of this disclosure provide a graphical method for generating database query statements. The method includes: obtaining a data query request for a target database; obtaining a database structure diagram representing the structure of the target database, and performing graphical and text extraction processing on the database structure diagram to obtain extraction results, wherein the extraction results at least include entity nodes in the database structure diagram, entity names and entity attribute names corresponding to the entity nodes, and the relationships between the entity nodes; mapping the entity names to table names, mapping the entity attribute names to field names, and mapping the relationships between entity nodes to relationships between data tables to obtain the structural information of the target database; constructing prompt words that at least include the data query request and the structural information based on the data query request and the structural information; and inputting the prompt words into an artificial intelligence model to obtain a database query statement that conforms to the constraints of the structural information and corresponds to the data query request.

[0025] According to embodiments of this disclosure, the prompts input to the artificial intelligence model include not only the data query request but also target database structure information extracted from the database structure diagram. This structure information defines the names of the data tables, field names, and relationships between the data tables that the artificial intelligence model can reference. Based on this constraint, the artificial intelligence model can select data tables and fields matching the query request when generating database query statements, according to the structure information. In scenarios involving multi-table queries, it can also construct corresponding multi-table join conditions and / or join paths within the scope of relationships indicated by the database structure diagram. This reduces problems such as incorrect table names, non-existent fields, and incorrect or missing relationships between tables, improving the executability and accuracy of the generated database query statements on the target database.

[0026] Figure 1 This is a flowchart illustrating a method for generating database query statements according to one or more embodiments of this disclosure. Figure 1 As shown, and by way of example rather than limitation, the method for generating the database query statement may include the following steps S101 to S105.

[0027] Step S101: Obtain a data query request for the target database.

[0028] Step S102: Obtain a database structure diagram representing the target database structure, and perform graphic extraction and text extraction processing on the database structure diagram to obtain extraction results, wherein the extraction results include at least the entity nodes in the database structure diagram, the entity names and entity attribute names corresponding to the entity nodes, and the association relationships between the entity nodes;

[0029] Step S103: Map the entity name to the data table name, map the entity attribute name to the field name, and map the association between the entity nodes to the association between the data tables to obtain the structure information of the target database;

[0030] Step S104: Based on the data query request and the structural information, construct prompt words that include at least the data query request and the structural information.

[0031] Step S105: Input the prompt word into the artificial intelligence model to obtain a database query statement that conforms to the structural information constraints and corresponds to the data query request.

[0032] The data query request can be an instruction to perform a specific retrieval and analysis operation on the target database. This instruction may include, but is not limited to, the query object, filtering conditions, time range, and output requirements. For example, the data query request could be "query the proportion of patients diagnosed with advanced lung adenocarcinoma in 2021 who received PD-1 inhibitor treatment"; another example is "screen the list of patients with specific EGFR mutation sites who received targeted therapy within 6 months of diagnosis and their first treatment date"; yet another example is "calculate the overall survival rate / progression-free survival rate of patients with different TNM stages within a certain time interval and output the results grouped by treatment regimen." It should be noted that the data query request is not limited to the above natural language form; it can also be expressed using structured parameters, keyword combinations, voice commands, etc., as long as the query intent is clearly represented.

[0033] For the target database of the data query request, the target database can be a medical database, such as an oncology clinical business database, an oncology disease database, or an oncology clinical research database; of course, the target database can also be a database in other fields, and this disclosure does not limit it. In the embodiments of this disclosure, for any target database, its overall structure can be characterized by its structural information (e.g., schema information). This structural information includes, but is not limited to, the data tables contained in the database, the fields contained in each data table, and the relationships between the data tables. A data table can be understood as a table structure unit used to store similar business data, such as, but not limited to, patient tables, consultation tables, diagnosis tables, treatment tables, laboratory examination tables, pathology tables, imaging tables, and follow-up tables; a field can be understood as a data item / column in a data table, used to describe the attributes or identification information of a business object, such as, but not limited to, patient identifier, consultation identifier, diagnostic information, treatment method, laboratory test items, pathology type, medication information, and follow-up time; the relationships between data tables can be understood as the correspondence between different data tables based on associated fields and their association types. For example, the association between the patient table and the consultation table can be realized based on the patient identifier, and it can be represented as a 1:N cardinal type where "one patient corresponds to multiple consultations"; the association between the consultation table and the diagnosis table / treatment table / lab examination table, etc., can be realized based on the consultation identifier, and it can be represented as a 1:N cardinal type where "one consultation corresponds to multiple diagnosis / multiple treatment records".

[0034] In some embodiments of this disclosure, the structural information of the target database can be obtained first, and this structural information can be input into the artificial intelligence model as constraint information. Based on this, when generating database query statements, the artificial intelligence model can select data tables and fields that match the data query request according to the structural information, and in the case of multi-table queries, construct corresponding multi-table join conditions and / or join paths within the scope of the association relationships indicated by the structural information. This reduces problems such as incorrect table names, non-existent fields, and incorrect or missing inter-table relationships, improving the executability and query accuracy of the generated database query statements on the target database.

[0035] The following explains how to obtain the structural information of the target database.

[0036] As an example and not a limitation, the structural information of the target database can be obtained from a database structure diagram used to represent the structure of the target database. This database structure diagram (as an example and not a limitation, it could also be an entity relationship diagram) is a structured diagram used to describe entities in the database and their relationships. The database structure diagram can include entity nodes, entity names and entity attribute names corresponding to the entity nodes, and the relationships between entity nodes. Entity nodes can correspond to data tables in the database, entity attributes can correspond to fields in the data tables, and the relationships between entity nodes can correspond to the relationships between data tables. In this embodiment of the disclosure, the entity nodes, entity names and entity attribute names corresponding to the entity nodes, and the relationships between entity nodes can be obtained by parsing the database structure diagram. Then, entity names are mapped to data table names, entity attribute names are mapped to field names, and the relationships between entity nodes are mapped to the relationships between data tables, thereby obtaining the structural information of the target database.

[0037] The following is given for Figure 3 This example illustrates how to parse a database structure diagram to obtain target database structure information. For instance... Figure 3As shown, the database structure diagram is first processed by image extraction and text extraction to obtain the extraction results containing entity nodes, entity names, entity attributes and relationships between entity nodes; three entity nodes are identified, with entity names of pathology, patient and treatment, and are mapped to the pathology table, patient table and treatment table in the target database, respectively. Furthermore, the entity node pathology contains entity attributes such as patient_id (Integer), tumor_type (varchar(50)) and tnm_stage (varchar(100)), which correspond to the patient_id, tumor_type and tnm_stage fields in the pathology table; the entity node patient contains entity attributes such as id (Integer), diagnosis_date (Date) and cancer_species (varchar(100)), which correspond to the id, diagnosis_date and cancer_species fields in the patient table; the entity node treatment contains entity attributes such as patient_id (Integer) and drug_type (varchar(50)), which correspond to the patient_id and drug_type fields in the treatment table. Furthermore, the association between pathology and patient is labeled n:1, representing multiple pathology records corresponding to the same patient record, which corresponds to the association between the pathology table and the patient table; the association between patient and treatment is labeled 1:n, representing the same patient corresponding to multiple treatment records, which corresponds to the association between the patient table and the treatment table. Therefore, by parsing the database structure diagram, entity names can be mapped to table names, entity attribute names to field names, and the associations between entity nodes can be mapped to the associations between table names, thus obtaining the structural information of the target database.

[0038] In one or more embodiments, the exemplary implementation of step S102 (i.e., performing graphic extraction and text extraction processing on the database structure diagram to obtain extraction results including entity nodes, entity names and entity attribute names corresponding to the entity nodes, and the relationships between entity nodes) is described below. Figure 2 A flowchart of step S102 provided according to one or more embodiments of the present disclosure is shown, as follows: Figure 2 As shown, step S102 may include S1021 to S1024.

[0039] S1021: Perform text extraction processing on the database structure diagram to obtain a text object, wherein the text object includes text content and the first position information of the text content in the database structure diagram.

[0040] In step S1021, text extraction processing (e.g., OCR-based processing) can be performed on the database structure diagram to extract text content from the diagram and determine the first location information corresponding to the text content. The text content may include, but is not limited to: entity names, entity attribute names, field type information, and text labels representing the relationships between entity nodes. Figure 3 For example, the text content may include entity names "patient", "pathology", and "treatment", entity attribute names "id", "diagnosis_date", "cancer_species", "patient_id", "tumor_type", "tnm_stage", and "drug_type", field type information "Integer", "Date", "varchar(50)", and "varchar(100)", and text labels indicating the relationship between entity nodes such as "1:n" and "n:1". Furthermore, the first location information can be used to characterize the spatial location of the text content in the database structure diagram. Optionally, the first location information may be represented in any one or more of the following forms: the coordinates of the bounding rectangle of the text area, the coordinates of the center point of the text area, the coordinates of the polygon corner points of the text area (e.g., four-point coordinates), etc.

[0041] In some embodiments, the text extraction process may include text detection and text recognition: the text detection is used to locate at least one text region in the database structure graph and output the geometric coordinates of the text region in the database structure graph as the first position information; the text recognition is used to decode the characters of the text region to obtain the text content corresponding to the text region. Based on the first position information and the text content, a text object corresponding to the text region can be generated. In this embodiment, by obtaining a text object that simultaneously includes text content and first position information, support can be provided for subsequently determining the entity nodes corresponding to the text content and the connection lines between the entity nodes corresponding to the text content.

[0042] In other embodiments, a preset dictionary can be introduced during the text recognition process to improve the accuracy of text recognition. This preset dictionary includes, but is not limited to, a set of entity names, a set of entity attribute names, and a set of characters representing the relationships between entity nodes. Optionally, during the decoding stage of text recognition, candidate recognition results can be constrained and decoded or reordered based on the preset dictionary; alternatively, after obtaining the initial recognition results, low-confidence text can be corrected based on the preset dictionary to improve the accuracy of text recognition.

[0043] S1022: Perform graphic extraction processing on the database structure diagram to obtain graphic objects, wherein the graphic objects include graphic shapes and second position information of the graphic shapes in the database structure diagram; and determine the graphic objects that satisfy the first preset shape features and the second preset shape features as entity nodes and entity node connection lines, respectively.

[0044] In step S1022, the database structure diagram can be processed by graphical extraction to detect the shape of the graphic and obtain the second position information of the graphic shape in the database structure diagram. The graphic shape may include container shapes representing entities and line shapes representing the connection relationships between entity nodes. The container shapes include, but are not limited to, rectangles, rounded rectangles, closed polygons, and ellipses; the line shapes include, but are not limited to, straight line segments, polyline segments, curved segments, arrowed line segments, and dashed line segments. Figure 3 As shown, rectangular containers representing entities and arrowed line segments representing connection relationships can be detected in the database structure diagram.

[0045] In this embodiment, to distinguish between entity nodes and their connecting lines in the database structure graph, shape features for discrimination can be preset. For example, a first preset feature can be set based on the container shape of the entity node. This first preset feature characterizes the degree of matching between the graphic object and the entity node's container shape, including but not limited to: polygon similarity features, contour fitting error features, closure features, area features, perimeter features, and aspect ratio features, or one or more of these. For instance, when the detected graphic object has a closed contour, and the fitting error between its contour and the preset container shape is less than a first threshold, and / or its area satisfies a similarity constraint with the preset container area (e.g., the area difference is less than a second threshold or the area ratio falls within a preset range), and / or its aspect ratio is within a preset aspect ratio range, the graphic object can be determined as an entity node (e.g., ...). Figure 3 The rectangular shape in the image can be identified as a physical node.

[0046] Furthermore, a second preset feature can be set based on the line shape of the entity node connecting lines. This second preset feature characterizes whether a graphic object possesses the shape attribute of a connecting line, including but not limited to: one or more of the following: non-closed slender shape features and aspect ratio features. For example, when the detected graphic object is a non-closed structure and the aspect ratio of its bounding rectangle is greater than a preset threshold, the graphic object can be identified as an entity node connecting line (e.g., ...). Figure 3 Line segments with arrows in the middle can be identified as entity node connecting lines.

[0047] Furthermore, the second location information is used to characterize the spatial position of the graphic shape in the database structure diagram. Optionally, the representation of the second location information can be differentiated according to the type of graphic object: when the graphic object is a container shape corresponding to an entity node, the second location information can be represented by the coordinates of the circumscribed rectangle, the coordinates of the center point, and the coordinates of the polygon boundary; when the graphic object is a line shape corresponding to a connecting line of an entity node, the second location information can be represented by the coordinates of the line endpoints, the line direction information, etc.

[0048] In this embodiment, by acquiring a graphic object that includes both graphic shape and second position information, it is possible to provide support for subsequently determining the entity nodes corresponding to the text content and determining the association relationships between entity nodes.

[0049] S1023: Based on the spatial relationship represented by the first position information of the text object, the second position information of the entity node and the entity node connecting line, determine the positional correspondence between the text content and the entity node and the entity node connecting line, and determine the connection correspondence between the entity node connecting line and the entity node.

[0050] S1024: Based on the positional correspondence and the connection correspondence, determine the entity name, the entity attribute name, and the association between the entity nodes to obtain the extraction result. For example, based on the positional correspondence between text content and entity nodes, determine the text content located in the first preset area of ​​the entity node as the entity name, and determine the text content located in the second preset area of ​​the entity node as the entity attribute name; determine the association between entity nodes based on the positional correspondence between text content and entity node connection lines, and the connection correspondence between entity node connection lines and entity nodes.

[0051] In steps S1023 and S1024, the positional correspondence between the text content and the entity node can be determined based on the spatial relationship represented by the first positional information of the text object and the second positional information of the entity node, and the entity name and entity attribute name associated with the entity node can be determined based on the positional correspondence.

[0052] Typically, the positional correspondence between an entity node and its associated entity name and attribute name is as follows: the entity name and attribute name are located within the boundary of the corresponding entity node, or within a preset neighborhood of the boundary. As an example, based on the first positional information of the text object and the second positional information of the entity node, the overlap ratio and shortest distance between the text bounding box and the entity node bounding box can be calculated to determine the positional correspondence between the text content and the entity node; then, the text content that satisfies the above-mentioned typical positional correspondence is determined as the entity name and attribute name of the entity node.

[0053] Optionally, the boundary range of an entity node or its preset neighborhood range can be further divided into a first preset region and a second preset region. The text content located in the first preset region of the entity node is determined as the entity name, and the text content located in the second preset region of the entity node is determined as the entity attribute name, thereby further determining the attribution relationship between the text content and the entity node.

[0054] In steps S1023 and S1024, the positional correspondence between the text content and the entity node connection line can be determined based on the spatial relationship represented by the first positional information of the text object and the second positional information of the entity node connection line, and the text label associated with the entity node connection line can be determined based on the positional correspondence.

[0055] Typically, the positional correspondence between an entity node connector and its associated text label is such that the text label is located near the corresponding entity node connector. As an example, based on the first positional information of the text object and the second positional information of the entity node connector, the positional correspondence between the text object and the entity node connector can be determined by calculating whether the shortest distance from the center point of the text bounding box to the connector is less than a preset distance threshold. Then, the text content that satisfies the typical positional correspondence is identified as the text label associated with the entity relationship connector.

[0056] In steps S1023 and S1024, the connection correspondence between the entity node connection line and the entity node can be determined based on the second position information of the entity node and the second position information of the entity node connection line (i.e., determining which entity nodes each connection line connects to). Then, based on the connection correspondence and the text labels associated with the entity node connection line, the association relationship between entity nodes can be determined.

[0057] Typically, the entity nodes connected by entity node connectors are such that the endpoints of the connectors are located within the boundary of the corresponding entity node. As an example, based on the second position information of the entity node and the second position information of the entity node connector, the shortest distance from the endpoint of the connector to the boundary of the entity node's bounding box can be calculated to determine whether it is less than a preset threshold, thus establishing the connection relationship between the entity node connector and the entity node. Then, based on this connection relationship and the text labels associated with the entity node connectors, the association relationship between the entity nodes is determined.

[0058] by Figure 3 For example, in this database structure diagram, rectangles are used to represent entity nodes, and lines are used to represent the connecting lines between entity nodes. Text labels are set near the connecting lines to indicate the relationships. Specifically, the diagram includes 3 entity nodes. The container of each entity node contains the corresponding text content. The text at the top of the container (which can be regarded as the first preset area of ​​the entity node) is used to represent the entity name (e.g., "pathology", "patient", "treatment"). The text in the remaining area inside the container (which can be regarded as the second preset area) is used to represent the entity attribute name of the entity (e.g., "patient_id Integer", "tumor_type varchar(50)", "tnm_stage varchar(100)", "idInteger", "diagnosis_date Date", "cancer_species varchar(100)", "drug_type varchar(50)", etc.). In addition, entity nodes are connected by entity node connection lines: the connection line between pathology and patient has the text label "n:1" to represent the relationship between the two entity nodes; the connection line between patient and treatment has the text label "1:n" to represent the relationship between the two entity nodes.

[0059] In one or more embodiments, before step S102 (i.e., performing graphic extraction and text extraction processing on the database structure diagram to obtain extraction results including entity nodes, entity names and entity attribute names corresponding to entity nodes, and the relationships between entity nodes), a preprocessing step of the database structure diagram may be included to eliminate noise and enhance the contrast between text and graphic outlines, thereby improving the accuracy of subsequent text extraction and graphic extraction.

[0060] For example, preprocessing may include: first, loading the image and performing format normalization; optionally, scaling the image proportionally according to the target resolution (e.g., 300 DPI), using cubic interpolation during scaling; then, converting the image to grayscale and applying noise reduction using filtering methods (e.g., 3×3 Gaussian filtering); next, performing adaptive threshold binarization (e.g., adaptive Gaussian thresholding) on ​​the grayscale image; optionally, inverting the binary image to make text the foreground; further, optionally, detecting straight lines based on Hough transform and calculating the average angle of near-horizontal lines, rotating the image to complete tilt correction. Finally, a binarized image and its corresponding grayscale image are output for subsequent recognition processing.

[0061] In one or more embodiments, after obtaining the structure information of the database, prompt words that include at least the data query request and the structure information can be constructed based on the data query request and the structure information. The prompt words are then input into an artificial intelligence model to obtain a database query statement that conforms to the constraints of the structure information and corresponds to the data query request.

[0062] The artificial intelligence model can be a natural language processing model based on deep learning, such as a generative model or a model based on the Transformer architecture.

[0063] As an example, Table 1 is an example diagram of the structural information obtained from the database structure diagram of the target database according to the embodiments of this disclosure. As shown in Table 1, the target database includes at least three data tables: patient, pathology, and treatment. The patient table contains the fields id, diagnosis_date, and cancer_species; the pathology table contains the fields patient_id, tumor_type, and tnm_stage; and the treatment table contains the fields patient_id and drug_type. The relationships between the data tables include: a connection between patient.id and pathology.patient_id with a cardinality of 1:N; and a connection between patient.id and treatment.patient_id with a cardinality of 1:N.

[0064] Table 1

[0065]

[0066]

[0067] In some embodiments of this disclosure, prompt words that include at least the data query request and structural information can be constructed based on the data query request and structural information. Table 2 is an example chart of prompt words provided according to one or more embodiments of this disclosure, which at least includes target database structural information (table names, field names, and inter-table relationships) and data query request content (e.g., querying the proportion of patients diagnosed with advanced lung adenocarcinoma in 2021 who received PD-1 inhibitor treatment), and may further include generation constraints, such as requiring strict use of table names and field names defined in the structural information, and meeting the requirements of tumor terminology standardization, etc.

[0068] Table 2

[0069]

[0070]

[0071] After the aforementioned prompts are input into the AI ​​model, the AI ​​model can output a database query statement that satisfies the structural information constraints and corresponds to the data query request. The structural information constraints may include at least one of the following: the database query statement uses the names of the data tables and / or field names contained in the structural information; the database query statement uses join conditions and / or join paths between data tables determined at least based on the relationships between the data tables.

[0072] Table 3 is an example diagram of database query statements generated based on an artificial intelligence model according to one or more embodiments of this disclosure. Based on the inter-table relationships indicated by the structural information, the connection path for multi-table queries is determined to be with the patient table as the connection hub table, establishing connections with the pathology and treatment tables via associated fields, thus forming patient→pathology and patient→treatment connection paths (since the structural information does not indicate a direct association between pathology and treatment, no direct connection is constructed between them). Under this connection path, the patient table is connected to the pathology table using the connection condition p.id = pa.patient_id to filter the set of patients diagnosed in 2021 with "lung adenocarcinoma" and stage "IV"; and the patient table is connected to the treatment table using the connection condition p.id = t.patient_id to associate treatment information. Further, the treatment ratio is calculated based on the ratio of the total number of patients meeting the conditions to the number of patients meeting t.drug_type = 'PD-1 inhibitor', thereby obtaining the query results.

[0073] Table 3

[0074]

[0075] In this embodiment, since the prompts input to the AI ​​model include not only the data query request but also target database structure information extracted from the database structure diagram, and this structure information is used to limit the table names, field names, and connection relationships between the AI ​​model, the AI ​​model can select the table and field matching the query request based on the structure information when generating the database query statement. This reduces problems such as incorrect table names and missing fields (for example, the generated database query statement does not include table names and field names other than those specified in the structure information). Furthermore, when multi-table queries are involved, the AI ​​model can construct corresponding multi-table join conditions and / or join paths within the join relationships indicated by the database structure diagram. For example, it can construct a join condition p.id = pa.patient_id using the associated field indicated by the structure information to connect the patient table and the pathology table, and construct a join condition p.id = t.patient_id to connect the patient table and the treatment table, thereby forming a join path (patient→pathology, patient→treatment) with the patient table as the hub. This reduces problems such as incorrect or missing table join relationships and improves the executability and accuracy of generated database queries on the target database.

[0076] In one or more embodiments, the method for generating the database query statement further includes: before inputting the prompt words into the artificial intelligence model, performing prompt word enhancement processing on the prompt words, the prompt word enhancement processing including: performing terminology standardization processing on the prompt words according to the target domain standard terminology library corresponding to the target database, so as to generate prompt words represented using preset standard terms.

[0077] For example, when the target domain is the medical field, the standard terminology database can include standard terms and synonym mappings such as disease names, staging / grading, test indicator names, generic drug names / drug categories, surgical and treatment plan names, etc. If the data query request contains non-standard or colloquial expressions, they can be mapped to standard terminology before being used to generate prompts. For example, "type 2 diabetes / T2DM" can be standardized to "type 2 diabetes"; "myocardial infarction / AMI / acute myocardial infarction" can be standardized to "acute myocardial infarction"; and "aspirin enteric-coated tablets / ASA / bay aspirin" can be standardized to "aspirin". Through terminology standardization, the bias in condition matching caused by synonyms, abbreviations, or colloquial expressions can be reduced, improving the consistency and accuracy of subsequent model-generated query statements.

[0078] In one or more embodiments, the method for generating the database query statement further includes: before inputting the prompt words into the artificial intelligence model, performing prompt word enhancement processing on the prompt words, the prompt word enhancement processing including: identifying the data query intent based on the data query request in the prompt words; and optimizing the missing and / or semantically ambiguous information in the data query request based on the data query intent, the structural information of the target database, and preset rules, wherein the information includes at least information related to at least one of the data table, field, filtering conditions, aggregation method, and sorting method.

[0079] For example, when the data query request is "to calculate the average length of stay for inpatients last year and sort the top ten by department", the query intent can be identified as "grouping aggregation + sorting + TopN". Further, by combining structural information, "length of stay" can be mapped to "discharge date - admission date" or the corresponding length of stay field, and "department" can be mapped to the department field in the outpatient / inpatient record table. Based on preset rules, the query is completed: "last year" is completed to a specific start and end date range; "average length of stay" is completed to the aggregation method AVG(length of stay); and "top ten" is completed to the sorting field and sorting direction (e.g., descending by average length of stay) and LIMIT10, thereby generating semantically clear enhancement prompts so that the model can generate an executable query statement. For another example, when the data query request is "to query the blood pressure value of the most recent follow-up visit", the query intent can be identified as "query of the most recent record". Under this intent, structural information and preset rules can be combined to complete the following: the sorting criteria (e.g., descending order by visit date) and value retrieval strategy (e.g., taking the first item) corresponding to "most recent"; the fields corresponding to "blood pressure value" (e.g., systolic pressure, diastolic pressure) and their combined expression; if the patient range is missing (e.g., no patient ID or population condition is specified), it can be completed according to preset rules to "current patient / specified patient set" or the patient screening conditions clearly stated in the prompt, so that the prompt clearly includes the required data table, fields, filtering conditions and sorting methods, reducing the ambiguity of the model-generated results.

[0080] In one or more embodiments, when constructing a prompt word that includes at least the data query request and the structural information based on the data query request and the structural information, the method further includes: identifying a data query intent based on the data query request; determining a candidate data table set and / or a candidate field set based on the data query intent and the structural information; extracting substructure information from the structural information based on the candidate data table set and / or the candidate field set, wherein the substructure information includes at least: the names of the data tables in the candidate data table set, the field names and / or field type information in the candidate field set, and the association relationships between the candidate data tables, wherein the association relationships include at least two associated data tables, associated field pairs, and cardinality type and / or relationship type; and constructing the prompt word based on the data query request and the substructure information.

[0081] In one or more embodiments, determining a candidate data table set and / or a candidate field set based on the data query intent and the structural information includes: extracting keywords and identifying entities from the data query request to obtain an intent keyword set, wherein the intent keyword set includes at least one of disease / staging / drug / testing indicators / time range / statistical caliber; performing synonym normalization and abbreviation expansion on the intent keyword set based on a target domain standard terminology library to obtain a standardized keyword set; performing name matching and similarity matching based on the data table name, field name, and / or field annotation information in the structural information to determine the data table that matches the standardized keyword set as a candidate data table set; filtering fields that match the standardized keyword set in the candidate data table set as a candidate field set; calculating a matching score for the candidate data table set and / or candidate field set, and selecting candidates with scores higher than a preset threshold and / or ranking in the top K as output.

[0082] In this embodiment, instead of inputting all structural information of the target database into the artificial intelligence model when constructing prompt words, the model filters candidate data table sets and / or candidate field sets related to the current query task from the structural information based on the data query intent. Furthermore, it extracts sub-structural information containing table names, field names and / or field type information, and the relationships between candidate data tables. This sub-structural information is then combined with the data query request to construct prompt words. This approach reduces the interference of prompt word length and irrelevant structural information on model reasoning, avoiding table / field misselection due to redundant structural information. Furthermore, it enables the artificial intelligence model to generate database query statements within a smaller structural constraint space, thereby improving the consistency between the generated database query statements and the target database structure, reducing the probability of problems such as incorrect table names, missing fields, and incorrect join conditions or paths, and further improving the executability and accuracy of the generated database query statements. This is particularly suitable for database scenarios in the medical field with a large number of tables, inconsistent field naming, and complex multi-table relationships.

[0083] As an example, the data query request is "to query the proportion of patients diagnosed with stage IV lung adenocarcinoma in 2021 who received PD-1 inhibitor treatment." In this embodiment, the data query request is first subjected to keyword extraction and entity recognition to obtain a set of intent keywords, such as "2021" (time range), "stage IV" (stage), "lung adenocarcinoma" (disease), "PD-1 inhibitor" (drug), and "proportion" (statistical definition). Subsequently, based on the target domain standard terminology library, the set of intent keywords is normalized for synonyms and expanded with abbreviations, standardizing "stage IV" to "TNM stage = stage IV" and normalizing "PD-1 inhibitor" to standard drug category terminology. Then, based on the data table names, field names, and / or field annotation information in the structure information, name matching and similarity matching are performed to determine the data tables that match the standardized keyword set as candidate data table sets. For example, the patient table is determined to provide patient identification, diagnosis time, and cancer type information; the pathology table is determined to provide TNM staging information; and the treatment table is determined to provide treatment / medication information. Fields that match the standardized keyword set are then selected from the candidate data table set as candidate field sets, such as patient.id, patient.diagnosis_date, patient.cancer_species, pathology.patient_id, pathology.tnm_stage, treatment.patient_id, and treatment.drug_type. Furthermore, based on the candidate data table set and the candidate field set, substructure information is extracted from the structure information. The substructure information includes at least the name of the candidate data table, the field name and / or field type information of the candidate fields, and the association between the candidate data tables. The association between the candidate data tables includes at least the association field pair between patient.id and pathology.patient_id with a cardinality of 1:N, and the association field pair between patient.id and treatment.patient_id with a cardinality of 1:N.Based on the data query request and the substructure information, prompt words are constructed and input into the artificial intelligence model. The artificial intelligence model then generates a database query statement within the scope of table names, field names, and relationships defined by the substructure information. For example, the patient table is used as the connection hub table to establish connections with the pathology table and the treatment table respectively. Constraints such as "diagnosis date belongs to 2021", "cancer type is lung adenocarcinoma", "TNM stage is IV", and "drug category is PD-1 inhibitor" are added to the query conditions. The treatment ratio is obtained by statistically calculating the total number of patients who meet the conditions and the number of patients who meet the conditions for PD-1 inhibitor treatment, thereby improving the executability and query accuracy of the generated database query statement.

[0084] In one or more embodiments, when inputting the prompt words into an artificial intelligence model to obtain a database query statement, the process includes: inputting the prompt words into the artificial intelligence model to generate at least two candidate database query statements; performing statement validation processing on each candidate database query statement and calculating a comprehensive score; and selecting the candidate database query statement with the highest comprehensive score as the output database query statement. Through these embodiments, the problem of unstable output SQL quality caused by the randomness of the results generated by the artificial intelligence model in a single instance can be avoided, thereby improving the executability and query accuracy of the output database query statement.

[0085] In one or more embodiments, after obtaining the database query statement, the generation method further includes: performing statement validation processing on the database query statement to obtain a validation result, wherein the statement validation processing includes at least syntax validation, table name and field name reference validation, and join condition and / or join path validation; when the validation result indicates that the database query statement does not meet the preset validation rules, constructing an error correction prompt word containing the validation result; and inputting the error correction prompt word into the artificial intelligence model to generate a corrected database query statement that meets the preset validation rules.

[0086] Through the embodiments of this disclosure, automated consistency verification and error location can be performed on the database query statement after it is generated, and the verification results can be fed back to the artificial intelligence model in the form of error correction prompts to trigger secondary generation or correction. This ensures that the output database query statement can meet the preset verification rules, reduce problems such as incorrect table names, non-existent fields, incorrect connection conditions, or connection paths that do not conform to structural information constraints, and further improve the executability and query accuracy on the target database.

[0087] As an example, the first database query generated by the AI ​​model based on the prompt words references the non-existent field "patient.patientID" and directly joins the pathology table and treatment table, causing the join path to violate structural information constraints. After performing statement validation on the first database query statement, the validation results indicate "field does not exist" and "join path is invalid". Based on this, an error correction prompt word containing the validation results is constructed and input into the AI ​​model. The AI ​​model outputs a corrected database query statement, correcting the field to "patient.id" and changing it to establish joins with the pathology table and treatment table respectively using the patient table as the hub, thereby satisfying the preset validation rules.

[0088] One embodiment of this disclosure also provides a database query statement generation system. Figure 4 This is a structural block diagram of a database query statement generation system provided according to one or more embodiments of this disclosure, such as... Figure 4 As shown, the generation system 400 includes:

[0089] Module 410 retrieves the data query request for the target database;

[0090] Obtain a database structure diagram representing the target database structure, and perform graphic extraction and text extraction processing on the database structure diagram to obtain extraction results, wherein the extraction results include at least the entity nodes in the database structure diagram, the entity names and entity attribute names corresponding to the entity nodes, and the association relationships between the entity nodes;

[0091] The entity name is mapped to the table name, the entity attribute name is mapped to the field name, and the relationship between the entity nodes is mapped to the relationship between the tables, so as to obtain the structural information of the target database.

[0092] Based on the data query request and the structural information, construct prompt words that at least include the data query request and the structural information; and

[0093] The generation module 420 inputs the prompt words into the artificial intelligence model to obtain a database query statement that conforms to the structural information constraints and corresponds to the data query request.

[0094] The structural information constraints include at least one of the following: the database query statement uses the name of the data table and / or field name contained in the structural information; the database query statement uses the connection conditions and / or connection paths between the data tables, determined at least based on the association relationships between the data tables.

[0095] In this embodiment of the disclosure, when performing graphic extraction and text extraction processing on the database structure diagram to obtain extraction results, the acquisition module 410 performs text extraction processing on the database structure diagram to obtain text objects, wherein the text objects include text content and a first position information of the text content in the database structure diagram; performs graphic extraction processing on the database structure diagram to obtain graphic objects, wherein the graphic objects include graphic shapes and a second position information of the graphic shapes in the database structure diagram; the graphic objects that satisfy the first preset shape features and the second preset shape features are respectively determined as entity nodes and entity node connecting lines; based on the spatial relationship represented by the first position information of the text objects, the second position information of the entity nodes and the entity node connecting lines, the positional correspondence between the text content and the entity nodes and the entity node connecting lines is determined, and the connection correspondence between the entity node connecting lines and the entity nodes is determined; according to the positional correspondence and the connection correspondence, the entity name, the entity attribute name, and the association relationship between the entity nodes are determined to obtain the extraction results.

[0096] In this embodiment of the disclosure, when determining the entity name, entity attribute name, and association relationship between the entity nodes based on the position correspondence and the connection correspondence to obtain the extraction result, the acquisition module 410 determines the text content located in the first preset area of ​​the entity node as the entity name and the text content located in the second preset area of ​​the entity node as the entity attribute name based on the position correspondence between the text content and the entity node; and determines the association relationship between the entity nodes based on the position correspondence between the text content and the entity node connection line, and the connection correspondence between the entity node connection line and the entity node.

[0097] In this embodiment of the disclosure, before the prompt word is input into the artificial intelligence model, the acquisition module 410 performs prompt word enhancement processing on the prompt word. The prompt word enhancement processing includes: performing terminology standardization processing on the prompt word according to the target domain standard terminology library corresponding to the target database, so as to generate the prompt word represented using preset standard terms.

[0098] In this embodiment of the disclosure, before the prompt word is input into the artificial intelligence model, the acquisition module 410 performs prompt word enhancement processing on the prompt word. The prompt word enhancement processing includes: identifying the data query intent based on the data query request in the prompt word; and optimizing the missing and / or semantically ambiguous information in the data query request based on the data query intent, the structural information of the target database, and preset rules. The information includes at least information related to at least one of the data table, field, filtering conditions, aggregation method, and sorting method.

[0099] It should be noted that this database query statement generation system can be used to execute any of the above database query statement generation methods, which will not be elaborated here.

[0100] One or more embodiments of this disclosure can also be implemented as a computer-readable storage medium. A computer-readable storage medium according to one or more embodiments of this disclosure stores computer-readable instructions that, when executed by a processor, cause the processor to perform a method for generating a database query statement according to embodiments of this disclosure, as described above with reference to the accompanying drawings. The computer-readable storage medium includes, but is not limited to, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), a hard disk, flash memory, etc.

[0101] According to one or more embodiments of this disclosure, a computer program product or computer program is also provided, which includes computer-readable instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer-readable instructions from the computer-readable storage medium, and the processor executes the computer-readable instructions, causing the computer device to perform the database query statement generation method described in the above one or more embodiments.

[0102] The program portion of a technology can be considered a “product” or “artifact” existing in the form of executable code and / or related data, which is engaged in or implemented through a computer-readable medium. Tangible, permanent storage media can include memory or storage used by any computer, processor, or similar device or related module, such as various semiconductor memories, tape drives, disk drives, or any similar device capable of providing storage functionality for software.

[0103] All software, or parts thereof, may sometimes communicate via networks, such as the Internet or other communication networks. Such communication can load software from one computer device or processor to another. Therefore, another medium capable of transmitting software elements can also be used as a physical connection between local devices, such as light waves, radio waves, electromagnetic waves, etc., propagated through cables, fiber optic cables, or air. Physical media used for carrier waves, such as cables, wireless connections, or fiber optic cables, can also be considered as media carrying software. In this context, unless limited to tangible "storage" media, the term "readable medium" for a computer or machine refers to the medium involved in the execution of any instructions by the processor.

[0104] This application uses specific terms to describe embodiments of the application. Terms such as "first / second embodiment," "an embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of the application. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, certain features, structures, or characteristics in one or more embodiments of the application can be appropriately combined.

[0105] Furthermore, those skilled in the art will understand that aspects of this application can be described and illustrated through several patentable types or situations, including any new and useful combination of processes, machines, products, or substances, or any new and useful improvements thereof. Accordingly, aspects of this application can be implemented entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. All of the above hardware or software may be referred to as a “data block,” “module,” “engine,” “unit,” “component,” or “system.” Furthermore, aspects of this application may manifest as a computer product located on one or more computer-readable media, the product including computer-readable program code.

[0106] Unless otherwise defined, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in a common dictionary shall be interpreted as having a meaning consistent with their meaning in the context of the relevant art, and not as being interpreted in an idealized or highly formalized sense, unless expressly defined herein.

[0107] The foregoing description is illustrative of the invention and should not be construed as limiting it. Although several exemplary embodiments of the invention have been described, those skilled in the art will readily understand that many modifications can be made to the exemplary embodiments without departing from the novel teachings and advantages of the invention. Therefore, all such modifications are intended to be included within the scope of the invention as defined in the claims. It should be understood that the foregoing description is illustrative of the invention and should not be construed as limiting it to the specific embodiments disclosed, and modifications to the disclosed embodiments and other embodiments are intended to be included within the scope of the appended claims. The invention is defined by the claims and their equivalents.

Claims

1. A method for generating database query statements based on a graphical representation, the method comprising: Obtain the data query request for the target database; Obtain a database structure diagram representing the target database structure, and perform graphic extraction and text extraction processing on the database structure diagram to obtain extraction results, wherein the extraction results include at least the entity nodes in the database structure diagram, the entity names and entity attribute names corresponding to the entity nodes, and the association relationships between the entity nodes; The entity name is mapped to the table name, the entity attribute name is mapped to the field name, and the relationship between the entity nodes is mapped to the relationship between the tables, so as to obtain the structural information of the target database. Based on the data query request and the structural information, construct prompt words that at least include the data query request and the structural information; and The prompt words are input into the artificial intelligence model to obtain a database query statement that conforms to the structural information constraints and corresponds to the data query request.

2. The method for generating graphical database query statements as described in claim 1, wherein, The structural information constraints include at least one of the following: The database query statement uses the name of the data table and / or field names contained in the structure information; The database query statement uses join conditions and / or join paths between the data tables, determined at least based on the relationships between the data tables.

3. The method for generating graphical database query statements as described in claim 1, wherein, The database structure diagram is subjected to graphic extraction and text extraction processing to obtain extraction results, including: The database structure diagram is subjected to text extraction processing to obtain a text object, wherein the text object includes text content and the first position information of the text content in the database structure diagram; The database structure diagram is subjected to graphic extraction processing to obtain a graphic object, wherein the graphic object includes a graphic shape and a second position information of the graphic shape in the database structure diagram; The graphic objects that satisfy the first preset shape feature and the second preset shape feature are respectively determined as entity nodes and entity node connecting lines; Based on the spatial relationship represented by the first position information of the text object, the second position information of the entity node and the entity node connecting line, the positional correspondence between the text content and the entity node and the entity node connecting line is determined, as well as the connection correspondence between the entity node connecting line and the entity node is determined. Based on the location correspondence and the connection correspondence, the association between the entity name, the entity attribute name, and the entity nodes is determined to obtain the extraction result.

4. The method for generating graphical database query statements as described in claim 3, wherein, Based on the location correspondence and the connection correspondence, the entity name, entity attribute name, and the association between the entity nodes are determined to obtain the extraction result, including: Based on the positional correspondence between the text content and the entity node, the text content located in the first preset area of ​​the entity node is determined as the entity name, and the text content located in the second preset area of ​​the entity node is determined as the entity attribute name; and The association relationship between the entity nodes is determined based on the positional correspondence between the text content and the connection line between the entity nodes, and the connection correspondence between the connection line between the entity nodes and the entity nodes.

5. The method for generating graphical database query statements as described in claim 1, wherein, The generation method further includes: performing prompt word enhancement processing on the prompt words before inputting them into the artificial intelligence model. The prompt word enhancement processing includes: Based on the target domain standard terminology library corresponding to the target database, the prompt words are subjected to terminology standardization processing to generate the prompt words represented using preset standard terms.

6. The method for generating graphical database query statements as described in claim 1, wherein, The generation method further includes: performing prompt word enhancement processing on the prompt words before inputting them into the artificial intelligence model. The prompt word enhancement processing includes: Based on the data query request in the prompt words, identify the data query intent; Based on the data query intent, the structural information of the target database, and preset rules, the missing and / or semantically ambiguous information in the data query request is optimized, wherein the information includes at least one of the following: data table, field, filtering condition, aggregation method, and sorting method.

7. The method for generating graphical database query statements as described in claim 1, wherein, The target database is a medical database.

8. A system for generating database query statements based on a graphical interface, the system comprising: The acquisition module retrieves data query requests for the target database. Obtain a database structure diagram representing the target database structure, and perform graphic extraction and text extraction processing on the database structure diagram to obtain extraction results, wherein the extraction results include at least the entity nodes in the database structure diagram, the entity names and entity attribute names corresponding to the entity nodes, and the association relationships between the entity nodes; The entity name is mapped to the table name, the entity attribute name is mapped to the field name, and the relationship between the entity nodes is mapped to the relationship between the tables, so as to obtain the structural information of the target database. Based on the data query request and the structural information, construct prompt words that at least include the data query request and the structural information; and The generation module inputs the prompt words into the artificial intelligence model to obtain a database query statement that conforms to the structural information constraints and corresponds to the data query request.

9. The system for generating graphical database query statements according to claim 8, wherein, The structural information constraints include at least one of the following: The database query statement uses the name of the data table and / or field names contained in the structure information; The database query statement uses join conditions and / or join paths between the data tables, determined at least based on the relationships between the data tables.

10. A computer-readable storage medium, wherein, The computer-readable storage medium stores computer-executable instructions, which, when executed by the processor, implement the method for generating graphical database query statements as described in any one of claims 1 to 7.

11. A computer program product comprising computer-executable instructions that, when executed by a processor, implement the method for generating a graphical database query statement as described in any one of claims 1 to 7.