Database table incidence relation determination method, system and equipment and storage medium

By parsing SQL statements and analyzing business code using a large language model within the ORM framework, explicit and implicit relationships between database tables are automatically identified. This solves the problem of high costs associated with manual analysis in existing technologies, and enables efficient and accurate determination of database table relationships.

CN121597728APending Publication Date: 2026-03-03永赢金融租赁有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511944137.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing technologies cannot effectively identify and deduce the relationships between database tables, resulting in high costs and low efficiency for manual analysis, and difficulty in maintaining the consistency of the data model, which affects the efficiency and reliability of database management.

Method used

By obtaining the table structure information and ORM framework configuration file of the target database, SQL statements are extracted, the SQL statements are parsed to generate the first relationship, and the business code is analyzed by combining service link tracing and large language model to generate the second relationship. Finally, the two are merged to determine the complete relationship between the database tables.

Benefits of technology

It improves the comprehensiveness and accuracy of identifying database table relationships, reduces initialization and maintenance costs, enhances database management efficiency, and reduces errors introduced by manual operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597728A_ABST
    Figure CN121597728A_ABST
Patent Text Reader

Abstract

The invention discloses a database table association relationship determination method, system and device and a storage medium. According to the scheme, table structure information of a target database and an associated ORM framework configuration file are obtained; extracting SQL statements in the configuration file and determining a first association relationship between the database tables; and tracking, positioning and calling a service code of the configuration file through the service link, and determining a second association relationship between the database tables based on the service code by utilizing the large language model. And finally, integrating the table structure information, the first association relationship and the second association relationship to determine a final database table association relationship. According to the scheme, the SQL semantics in the ORM framework are analyzed, and the context of the service code is deeply analyzed in combination with the large language model, so that comprehensive and accurate identification of explicit and potential association relationships among the database tables is realized, the maintenance cost is remarkably reduced, and the automation level and efficiency of database management are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database management and data processing technology, and in particular to a method, system, device and storage medium for determining database table relationships. Background Technology

[0002] As software systems continue to expand in scale and business logic becomes increasingly complex, the number and structure of tables in databases also continue to grow. Accurately determining the relationships between database tables becomes particularly crucial for ensuring system stability and improving development efficiency.

[0003] Currently, the industry commonly uses database modeling tools to reverse engineer databases to obtain table structure information. However, this method has significant limitations: it can only extract static structural information such as field names and data types of a single table, and cannot effectively identify and deduce the relationships between tables. This means that when dealing with existing systems, technicians must manually sift through a large amount of business code and logic, inferring table relationships from scratch. This is not only costly and inefficient in initialization, but also prone to errors due to misunderstandings or operational negligence. In collaborative development environments, this reliance on manual maintenance makes it even more difficult to maintain data model consistency, often leading to management chaos and directly impacting the efficiency of database management and the reliability of underlying data. Summary of the Invention

[0004] To address the aforementioned issues, this application provides a method, system, device, and storage medium for determining database table relationships, aiming to improve the automation and accuracy of database table relationship determination, reduce maintenance costs, and enhance database management efficiency.

[0005] The embodiments of this application disclose the following technical solutions:

[0006] The first aspect of this application provides a method for determining database table relationships, the method comprising:

[0007] Obtain the table structure information of the target database, as well as the ORM framework configuration file associated with the target database;

[0008] Extract the SQL statements from the ORM framework configuration file;

[0009] Based on the SQL statement, the first association relationship between the database tables in the target database is determined;

[0010] The business code that calls the ORM framework configuration file is located by tracing the service chain.

[0011] Using a large language model, a second association between the database tables is determined based on the business code;

[0012] Based on the table structure information, the first association relationship, and the second association relationship, the database table association relationship is determined.

[0013] In an optional implementation, determining the first association between database tables in the target database based on the SQL statement includes:

[0014] The SQL statement is parsed, and a first abstract syntax tree is generated based on the parsing results;

[0015] Based on the first abstract syntax tree, the first association relationship between the database tables in the target database is determined.

[0016] In an optional implementation, determining the second association between the database tables based on the business code using a large language model includes:

[0017] A large language model is used to perform semantic analysis on the context of the business code to generate a second abstract syntax tree;

[0018] Using a large language model, and based on the second abstract syntax tree, a second association relationship between the database tables is determined.

[0019] In an optional implementation, determining the second association between the database tables using a large language model based on the second abstract syntax tree includes:

[0020] The second abstract tree syntax tree is converted into an input representation that can be processed by the large language model;

[0021] The input representation is input into the large language model, and the large language model is used to perform business logic analysis on the input representation to determine the second association relationship between the database tables.

[0022] In an optional implementation, the table structure information includes the structure and field storage data of each database table in the target database; determining the database table relationship based on the table structure information, the first relationship, and the second relationship includes:

[0023] The first association and the second association are merged to obtain a set of database table associations;

[0024] Based on the structure of each database table and the characteristics of the data stored in its fields, the relationship type of each relationship in the database table relationship set is determined; the relationship type includes one-to-one relationship, one-to-many relationship, or many-to-one relationship.

[0025] The database table relationships are determined based on the set of database table relationships and the relationship types of each relationship in the set of database table relationships.

[0026] In an optional implementation, after determining the database table relationship based on the table structure information, the first relationship, and the second relationship, the database table relationship determination method further includes:

[0027] Determine whether structured information regarding database table relationships exists in the target database;

[0028] In the absence of the structured information, structured information about the database table relationships is generated based on the database table relationships.

[0029] If the structured information already exists, update the structured information based on the database table relationships.

[0030] Among the optional implementation methods, the methods for determining database table relationships also include:

[0031] In response to changes in the target database, the ORM framework configuration file, or the business code, the changed database table relationships are redefined.

[0032] By comparing the database table relationships before and after the change, version difference information is generated.

[0033] A second aspect of this application provides a system for determining database table relationships, the system comprising:

[0034] The data acquisition module is used to acquire the table structure information of the target database, as well as the ORM framework configuration file associated with the target database.

[0035] The statement extraction module is used to extract SQL statements from the ORM framework configuration file.

[0036] The first determining module is used to determine the first association relationship between database tables in the target database based on the SQL statement;

[0037] The code location module is used to locate the business code that calls the ORM framework configuration file by tracing the service chain.

[0038] The second determining module is used to determine the second association relationship between the database tables based on the business code using a large language model;

[0039] The third determining module is used to determine the database table association based on the table structure information, the first association relationship, and the second association relationship.

[0040] A third aspect of this application provides a device for determining database table relationships, the device comprising: a processor and a memory.

[0041] The memory is used to store program code and transmit the program code to the processor;

[0042] The processor is configured to execute, according to the instructions in the program code, the steps of the database table association determination method described in any implementation of the first aspect.

[0043] A fourth aspect of this application provides a computer-readable storage medium for storing program code for performing the steps of the database table association determination method described in any implementation of the first aspect.

[0044] Compared with the prior art, this application has the following beneficial effects:

[0045] In this application's technical solution, firstly, the table structure information of the target database and the ORM framework configuration file associated with the target database are obtained; secondly, the SQL statements in the ORM framework configuration file are extracted; thirdly, based on the SQL statements, the first association relationship between database tables in the target database is determined; next, the business code calling the ORM framework configuration file is located through service link tracing; then, based on the business code using a large language model, the second association relationship between the database tables is determined; finally, based on the table structure information, the first association relationship, and the second association relationship, the database table relationship is determined. It is evident that this application, by extracting and parsing the SQL statements in the ORM framework, can automatically identify explicit association relationships between tables in the database. Simultaneously, by combining service link tracing and a large language model to perform semantic analysis of the business code context, it can discover potential or implicit association relationships. This application integrates multi-source information, significantly improving the comprehensiveness and accuracy of association relationship identification, and effectively reducing errors caused by incomplete manual analysis or misunderstandings. The entire process does not require manual construction from scratch, greatly reducing the initialization and maintenance costs of the database table relationship model and improving database management efficiency. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 A flowchart illustrating a method for determining database table relationships provided in this application embodiment;

[0048] Figure 2 An ER diagram illustrating database table relationships is provided for an embodiment of this application;

[0049] Figure 3 This is a schematic diagram of the structure of a database table association determination system provided in an embodiment of this application. Detailed Implementation

[0050] As described earlier, the industry commonly uses database modeling tools to reverse engineer databases and obtain table structure information. However, this method has significant limitations: it can only extract static structural information such as field names and data types from a single table, and cannot effectively identify and deduce the relationships between tables. This means that when dealing with existing systems, technicians must manually sift through a large amount of business code and logic, inferring table relationships from scratch. This is not only costly and inefficient in initialization, but also prone to errors due to misunderstandings or operational oversights. In collaborative development environments, this reliance on manual maintenance makes it even more difficult to maintain data model consistency, often leading to management chaos and directly impacting the efficiency of database management and the reliability of underlying data.

[0051] To address the aforementioned problems, the inventors have proposed a method, system, device, and storage medium for determining database table relationships.

[0052] First, the table structure information of the target database and the ORM framework configuration file associated with the target database are obtained. Second, the SQL statements in the ORM framework configuration file are extracted. Third, based on the SQL statements, the first relationship between the database tables in the target database is determined. Next, the business code calling the ORM framework configuration file is located through service tracing. Then, using a large language model, the second relationship between the database tables is determined based on the business code. Finally, based on the table structure information, the first relationship, and the second relationship, the database table relationship is determined. It is evident that this application, by extracting and parsing the SQL statements in the ORM framework, can automatically identify explicit relationships between tables in the database. Simultaneously, by combining service tracing and a large language model to perform semantic analysis of the business code context, potential or implicit relationships are discovered. This application integrates multi-source information, significantly improving the comprehensiveness and accuracy of relationship identification, and effectively reducing errors caused by incomplete manual analysis or misunderstandings. The entire process does not require manual construction from scratch, greatly reducing the initialization and maintenance costs of the database table relationship model and improving database management efficiency.

[0053] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0054] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this application should have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms "first," "second," and similar terms used in the embodiments of this application 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 only used to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0055] See Figure 1 The figure is a flowchart of a method for determining database table relationships provided in an embodiment of this application. Figure 1 As shown, the method includes the following steps:

[0056] S101. Obtain the table structure information of the target database, as well as the ORM framework configuration file associated with the target database.

[0057] In this embodiment of the application, the target database refers to the database of the table relationships to be analyzed, which may include various types of databases such as MySQL, Oracle, and PostgreSQL.

[0058] Table structure information refers to the basic configuration information of each data table in the target database, including table name, field name, field data type, field length, primary key, foreign key, etc.

[0059] The Object-Relational Mapping (ORM) framework configuration file associated with the target database refers to the Extensible Markup Language (XML) format file used in the project to map database tables to program entity classes. This file contains Structured Query Language (SQL) statements and mapping rules related to database operations.

[0060] In one example implementation, a connection is established with the target database server to access the database's system tables or metadata information. This allows for the extraction of table structure information such as table names and field attributes, while simultaneously collecting the actual stored data for each field in the database. Additionally, file collection is completed by traversing file paths to search for all ORM framework XML configuration files corresponding to the target database within the project directory.

[0061] This application embodiment obtains basic data support through this step, providing a table structure foundation and SQL statement source for subsequent relationship analysis.

[0062] S102. Extract the SQL statements from the ORM framework configuration file.

[0063] SQL statements refer to the structured query language defined in the ORM framework configuration file for database operations, including statements of types such as query, insert, update, and delete, which contain key information such as join conditions between tables and field relationships.

[0064] In one example implementation, a file scanning analyzer based on Document Object Model (DOM) parsing can be built. This analyzer uses Java libraries such as DOM4J or JDOM to process ORM framework XML configuration files, parsing the XML file into a DOM tree structure. After removing unnecessary fields such as comments and formatting tags, it extracts all complete SQL statements from the file through node traversal and syntax matching, including those with conditional tags (such as...). <if>Compound SQL statements with tags.

[0065] This application embodiment accurately extracts the core statements related to database operations in the ORM framework through this step, providing a direct basis for subsequent analysis of explicit relationships between tables and avoiding interference from irrelevant information.

[0066] S103. Based on SQL statements, determine the first association between database tables in the target database.

[0067] In this embodiment of the application, the first association relationship refers to the explicit association relationship between tables directly parsed from the SQL statement in the ORM framework configuration file, that is, the association between tables explicitly reflected through the JOIN clause, association conditions, etc. in the SQL statement.

[0068] In one example implementation, an SQL parsing tool can be used to perform syntactic analysis on the extracted SQL statements, uncover table join rules, and determine explicit associations.

[0069] In one alternative implementation, step S103 includes:

[0070] S1031. Perform syntax parsing on the SQL statement and generate the first abstract syntax tree based on the parsing results.

[0071] In the embodiments of this application, the first abstract syntax tree refers to the tree-shaped data structure formed by decomposing the SQL statement according to the syntax rules, where each node corresponds to a syntax unit in the SQL statement (such as keyword, table name, field name, join condition, etc.), which can intuitively reflect the logical structure of the SQL statement.

[0072] In one example implementation, the jsqlparser open-source parsing library can be used to parse the extracted SQL statements. This parsing library supports multiple database dialects and can transform complex SQL statements into standardized abstract syntax trees, clearly presenting key information such as table names, related fields, and join methods in the SQL statements.

[0073] S1032. Based on the first abstract syntax tree, determine the first association relationship between database tables in the target database.

[0074] In one example implementation, the table names, related fields, and join conditions are extracted by traversing the nodes of the first abstract syntax tree. For example, from the syntax tree node corresponding to "left join mwcprs_right.rights r on ap.rights_no =r.rights_no", the related tables are identified as activity_prize and rights, and the related field is rights_no. At the same time, the identified relationship is vectorized to generate the preliminary relationship between the tables, that is, the first relationship.

[0075] This embodiment of the application can automatically identify the table relationships explicitly reflected in the SQL statement through this step, replacing the tedious process of manually sorting out the SQL logic and improving the efficiency and accuracy of relationship identification.

[0076] S104. Locate the business code that calls the ORM framework configuration file through service link tracing.

[0077] A service chain refers to the path through which a business request flows in the system, including the calling relationships between various service modules and code components.

[0078] The business code that calls the ORM framework configuration file refers to the Java business logic code in the project that performs database operations through the ORM framework configuration file, including service classes, methods, and code context.

[0079] In one example implementation, a service link tracing analyzer based on a large language model can be built. By monitoring the service call flow during system runtime through link tracing technology, and based on the identification information of the ORM framework configuration file, the business code module (such as activity service, rights service, etc.) that calls the configuration file can be located in reverse, and the corresponding Java code context and related dependency code can be obtained.

[0080] This application embodiment provides data support for uncovering table relationships hidden in business logic by associating ORM configuration files with business code through this step, thus overcoming the limitations of relying solely on SQL statements to identify relationships.

[0081] S105. Using a large language model, based on business code, determine the second association between database tables.

[0082] In this application embodiment, the second relationship refers to the potential relationship between tables that is hidden in the business code logic and is not directly reflected in the SQL statement. It can only be identified by analyzing the business logic context.

[0083] In this embodiment of the application, based on the business code, potential relationships between tables are mined through model semantic analysis to generate corresponding relationships.

[0084] In one alternative implementation, step S105 includes:

[0085] S1051. Utilize a large language model to perform semantic analysis on the context of business code and generate a second abstract syntax tree.

[0086] In the embodiments of this application, the second abstract syntax tree refers to the tree-shaped data structure formed by decomposing the business code according to the programming language syntax, which can reflect the logical flow of the business code, the data transmission relationship and the mapping relationship with the database table.

[0087] In one example implementation, the located business code is parsed, and the large language model is fine-tuned by combining specific prompt words with the abstract syntax tree analysis. The code features are extracted through semantic analysis, and the data processing logic and parameter passing relationships in the business code are transformed into a second abstract syntax tree.

[0088] S1052. Using a large language model and based on the second abstract syntax tree, determine the second association relationship between database tables.

[0089] In this embodiment of the application, based on the second abstract syntax tree, the potential relationships between tables, namely the second relationship, are mined through in-depth analysis of the business logic using a large language model.

[0090] Optionally, step S1052 includes:

[0091] Step 1: Convert the second abstract syntax tree into an input representation that can be processed by the large language model.

[0092] In one example implementation, the second abstract syntax tree can be linearized to transform the tree structure into an ordered text sequence while preserving the association markers between nodes. Combined with the dense vectors generated by Sentence-BERT, a composite input representation of text sequence and vectors is formed, which is suitable for the input requirements of large language models.

[0093] Step 2: Input the input representation into the large language model, and use the large language model to perform business logic analysis on the input representation to determine the second association relationship between the database tables.

[0094] In this embodiment of the application, the composite input represents the large language model after input fine-tuning. The model identifies the inter-table relationships not reflected in the SQL statement by analyzing the data generation, transmission and usage logic in the business code. For example, by analyzing the business logic of user award records, the potential relationship between the activity prize table and the user information table is discovered, and the corresponding relationship connection is generated.

[0095] This application embodiment uses this step to uncover the table relationships hidden in the business logic, making the identification of table relationships more comprehensive.

[0096] S106. Based on the table structure information, the first association relationship, and the second association relationship, determine the database table association relationships.

[0097] In this embodiment of the application, the database table relationship refers to the complete relationship between tables that is finally determined after integrating the basic information of the table structure, the explicit relationship of the SQL statement, and the implicit relationship of the business logic, including the associated table pairs, the associated fields, and the specific relationship types.

[0098] In an optional implementation, the table structure information includes the structure and field storage data of each database table in the target database, and step S106 includes:

[0099] S1061. Merge the first association relationship and the second association relationship to obtain the database table association relationship set.

[0100] In this embodiment of the application, the structure and field data storage of the database table refer to the field attributes of each data table (such as whether it is a primary key, unique constraint, etc.) and the actual numerical values ​​stored in the fields (such as whether there are duplicate values, numerical distribution, etc.).

[0101] In this embodiment of the application, the first association relationship and the second association relationship can be deduplicated and merged to eliminate conflicting association information and retain consistent and valid association relationships, forming a database table association relationship set containing all candidate association relationships.

[0102] S1062. Based on the structure of each database table and the characteristics of the data stored in the fields, determine the relationship type of each relationship in the database table relationship set.

[0103] In this embodiment of the application, the relationship type indicates the association pattern between tables, including one-to-one relationship, one-to-many relationship, or many-to-one relationship.

[0104] In one example implementation, the storage characteristics of the related fields and the table structure constraints can be analyzed. For example, if the rights_no field of table a is a unique primary key (without duplicate values), and the rights_no field of table b has multiple duplicate values, then the two tables are determined to have a one-to-many relationship. If the related fields of the two tables are all unique constraints and correspond one-to-one, then they are determined to have a one-to-one relationship, thereby clarifying the specific type of each related relationship.

[0105] S1063. Determine the database table relationships based on the database table relationship set and the relationship types of each relationship in the database table relationship set.

[0106] In this embodiment of the application, the set of association relationships is bound to the corresponding relationship types to form a complete data structure, which ultimately determines the complete database table association relationships of the target database.

[0107] This embodiment of the application achieves the fusion of multi-source association information through this step, ensuring the comprehensiveness of the final determined table association relationship, while clarifying the relationship type and providing a clear reference for database management.

[0108] This application's embodiments extract and parse SQL statements from the ORM framework, automatically identifying explicit relationships between tables in the database. Simultaneously, by combining service link tracing and a large language model to perform semantic analysis of the business code context, it discovers potential or implicit relationships. This application integrates multi-source information, significantly improving the comprehensiveness and accuracy of relationship identification, effectively reducing errors caused by incomplete manual analysis or misunderstandings. The entire process does not require manual construction from scratch, greatly reducing the initialization and maintenance costs of the database table relationship model and improving database management efficiency.

[0109] Optionally, in order to achieve structured management and visual presentation of table relationships, after step S106, the method for determining database table relationships further includes:

[0110] Determine if structured information regarding database table relationships exists in the target database. If no structured information exists, generate structured information regarding the database table relationships based on those relationships. If structured information already exists, update that structured information based on the database table relationships.

[0111] In this application embodiment, structured information refers to table relationship data stored in a standardized format, including Entity-Relationship Diagram (ER) files, JSON-formatted relationship description documents, etc., which can intuitively present the relationships and types between tables.

[0112] In one example implementation, if the target database is being analyzed for the first time and has no historical structured information, a basic ER diagram or JSON-formatted relationship description is generated based on the finally determined table relationships; if historical structured information already exists, the newly determined relationships are compared with the historical information, and the relationship lines in the ER diagram or the relationship data in the JSON document are updated to ensure that the structured information is consistent with the actual relationships.

[0113] Optionally, to improve the distinguishability and readability of relationships in the ER diagram, the first and second relationships can be presented in different colors to facilitate quick identification of explicit and potential relationships.

[0114] See Figure 2 , Figure 2 This is an ER diagram illustrating a database table relationship as provided in an embodiment of this application. Figure 2 As shown, Figure 2 It contains three entity tables: the rights and benefits information table (a), the customer rights and benefits table (b), and the inventory table (c).

[0115] The rights information table (a) contains fields such as rights_no (rights number, VARCHAR2(64)), rights_name (rights name, VARCHAR2(64)), and rights_desc (rights description, CLOB(32)), where "rights_no" is the primary key (with no duplicate values); the customer rights table (b) contains fields such as rights_no (rights number, VARCHAR2(64)), customer_id (customer primary key, VARCHAR2(64)), and trade_id (card ID, VARCHAR2(64)); the inventory table (c) contains fields such as rights_no (rights number, VARCHAR2(64)) and total_inventory (total inventory, INT(10)), and is accessed through... <fk>The `rights_no` option is marked as a foreign key.

[0116] The red lines represent the first relationships parsed from the SQL statements in the ORM configuration file, such as the relationship between the equity information table (a) and the inventory table (c) established through the rights_no field; the green lines represent the second relationships extracted from the business code, such as the relationship between the equity information table (a) and the customer equity table (b) established through the rights_no field.

[0117] Figure 2 Next to the connection lines are interactive buttons for "Keep," "Adjust Relationship," and "Abandon." Clicking the "Adjust Relationship" button will bring up options for "One-to-One," "One-to-Many," and "Many-to-One." For example, if a technician finds that the actual relationship between the rights information table (a) and the customer's rights table (b) should be "Many-to-One," they can modify the relationship type using this button. After adjustment, the connection line will turn black (representing a user-confirmed relationship). Simultaneously, the system will automatically update the relationship data and subsequently generated version difference documents, preserving the efficiency of automated parsing while allowing manual intervention to supplement the accuracy of relationships in special scenarios, further enhancing the flexibility of database table relationship management.

[0118] Optionally, to adapt to the needs of rapid project iteration and support version management and backtracking of relationships, the methods for determining database table relationships also include:

[0119] In response to changes in the target database, ORM framework configuration file, or business code, the system redefines the changed database table relationships. It compares the pre-change and post-change database table relationships to generate version difference information.

[0120] In this embodiment of the application, version difference information refers to a document that records changes in table relationships between different versions, including new relationships, deleted relationships, and changes in relationship types.

[0121] In this embodiment, the re-analysis process of the relationship can be triggered by listening to database structure changes, ORM configuration file modifications, and business code update events to determine the changed table relationships.

[0122] By comparing the relationship data before and after the change, vectorization analysis technology is used to identify the differences and generate a version difference comparison document. This document supports version rollback of the relationship, meeting the iterative maintenance needs of existing projects.

[0123] Based on the database table relationship determination method provided in the foregoing embodiments, this application also provides a database table relationship determination system. Figure 3 This is a schematic diagram illustrating the structure of a database table relationship determination system provided in an embodiment of this application. Figure 3 As shown, the database table relationship determination system includes: a data acquisition module 301, a statement extraction module 302, a first determination module 303, a code location module 304, a second determination module 305, and a third determination module 306.

[0124] The data acquisition module 301 is used to acquire the table structure information of the target database, as well as the ORM framework configuration file associated with the target database.

[0125] Statement extraction module 302 is used to extract SQL statements from the ORM framework configuration file;

[0126] The first determining module 303 is used to determine the first association relationship between database tables in the target database based on SQL statements;

[0127] Code locator module 304 is used to locate the business code that calls the ORM framework configuration file through service chain tracing;

[0128] The second determination module 305 is used to determine the second association relationship between database tables based on business code using a large language model;

[0129] The third determining module 306 is used to determine the database table relationships based on the table structure information, the first relationship, and the second relationship.

[0130] This embodiment of the application achieves automated and accurate determination of database table relationships through the coordinated operation of a data acquisition module 301, a statement extraction module 302, a first determination module 303, a code location module 304, a second determination module 305, and a third determination module 306. Each module has a clear division of labor and is closely integrated. It identifies explicit relationships by parsing SQL statements and mines potential relationships through semantic analysis of business code. By integrating information from multiple sources, it clarifies the relationship type, eliminating reliance on manual analysis. This significantly reduces the initial maintenance costs of existing projects and the manual input during iteration, effectively avoiding errors caused by manual operation. Simultaneously, it adapts to the needs of rapid project iteration, providing reliable system support for the efficient management of database table relationships.

[0131] In an optional implementation, the first determining module 303 includes a first generating unit and a first determining unit.

[0132] The first generation unit is used to parse the SQL statement and generate the first abstract syntax tree based on the parsing results.

[0133] The first determining unit is used to determine the first association relationship between database tables in the target database based on the first abstract syntax tree.

[0134] In an optional implementation, the second determining module 305 includes: a second generating unit and a second determining unit.

[0135] The second generation unit is used to perform semantic analysis on the context of the business code using a large language model to generate a second abstract syntax tree.

[0136] The second determining unit is used to determine the second association relationship between database tables based on the second abstract syntax tree using the large language model.

[0137] In the optional implementation, the second determining unit is specifically used for:

[0138] Transform the second abstract syntax tree into an input representation that can be processed by a large language model;

[0139] The input representation is fed into a large language model, which is then used to perform business logic analysis on the input representation to determine the second association between database tables.

[0140] In the optional implementation, the table structure information includes the structure and field storage data of each database table in the target database. The third determining module 306 is specifically used for:

[0141] By merging the first and second associations, a set of database table associations is obtained;

[0142] Based on the structure of each database table and the characteristics of the data stored in its fields, determine the relationship type of each relationship in the database table relationship set; the relationship type includes one-to-one relationship, one-to-many relationship, or many-to-one relationship.

[0143] The database table relationships are determined based on the set of database table relationships and the relationship types of each relationship in the set of database table relationships.

[0144] In the optional implementation, the database table relationship determination system also includes a judgment module, a structured information generation module, and a structured information update module.

[0145] The judgment module is used to determine whether structured information regarding database table relationships exists in the target database.

[0146] The structured information generation module is used to generate structured information about database table relationships based on the database table relationships when no structured information exists.

[0147] The structured information update module is used to update the structured information based on the database table relationships when the structured information already exists.

[0148] In the optional implementation, the database table relationship determination system also includes: a fourth determination module and a difference generation module.

[0149] The fourth determination module is used to respond to changes in the target database, ORM framework configuration file, or business code by calling the data acquisition module 301, statement extraction module 302, first determination module 303, code location module 304, second determination module 305, and third determination module 306 to re-determine the changed database table relationships.

[0150] The difference generation module is used to compare the database table relationships before and after the change, and generate version difference information.

[0151] Furthermore, this application embodiment also provides a database table association determination device, which includes a processor and a memory.

[0152] The memory is used to store program code and transmit the program code to the processor;

[0153] The processor is used to execute the steps of the database table association determination method described in any of the above method embodiments according to the instructions in the program code.

[0154] Furthermore, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the database table association determination method as described in any of the method embodiments.

[0155] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the system and device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments. The system and device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components indicated as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the solution in this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0156] The above description is merely one specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.< / fk> < / if>

Claims

1. A method for determining database table relationships, characterized in that, include: Obtain the table structure information of the target database, as well as the ORM framework configuration file associated with the target database; Extract the SQL statements from the ORM framework configuration file; Based on the SQL statement, the first association relationship between the database tables in the target database is determined; The business code that calls the ORM framework configuration file is located by tracing the service chain. Using a large language model, a second association between the database tables is determined based on the business code; Based on the table structure information, the first association relationship, and the second association relationship, the database table association relationship is determined.

2. The method according to claim 1, characterized in that, Determining the first association between database tables in the target database based on the SQL statement includes: The SQL statement is parsed, and a first abstract syntax tree is generated based on the parsing results; Based on the first abstract syntax tree, the first association relationship between the database tables in the target database is determined.

3. The method according to claim 1, characterized in that, The step of using a large language model to determine the second association between the database tables based on the business code includes: A large language model is used to perform semantic analysis on the context of the business code to generate a second abstract syntax tree; Using a large language model, and based on the second abstract syntax tree, a second association relationship between the database tables is determined.

4. The method according to claim 3, characterized in that, The step of using a large language model, based on the second abstract syntax tree, to determine the second association between the database tables includes: The second abstract tree syntax tree is converted into an input representation that can be processed by the large language model; The input representation is input into the large language model, and the large language model is used to perform business logic analysis on the input representation to determine the second association relationship between the database tables.

5. The method according to claim 1, characterized in that, The table structure information includes the structure and field storage data of each database table in the target database; determining the database table relationship based on the table structure information, the first relationship, and the second relationship includes: The first association and the second association are merged to obtain a set of database table associations; Based on the structure of each database table and the characteristics of the data stored in its fields, the relationship type of each relationship in the database table relationship set is determined; the relationship type includes one-to-one relationship, one-to-many relationship, or many-to-one relationship. The database table relationships are determined based on the set of database table relationships and the relationship types of each relationship in the set of database table relationships.

6. The method according to claim 1, characterized in that, After determining the database table relationships based on the table structure information, the first relationship, and the second relationship, the method further includes: Determine whether structured information regarding database table relationships exists in the target database; In the absence of the structured information, structured information about the database table relationships is generated based on the database table relationships. If the structured information already exists, update the structured information based on the database table relationships.

7. The method according to claim 1, characterized in that, The method further includes: In response to changes in the target database, the ORM framework configuration file, or the business code, the changed database table relationships are redefined. By comparing the database table relationships before and after the change, version difference information is generated.

8. A system for determining database table relationships, characterized in that, include: The data acquisition module is used to acquire the table structure information of the target database, as well as the ORM framework configuration file associated with the target database. The statement extraction module is used to extract SQL statements from the ORM framework configuration file. The first determining module is used to determine the first association relationship between database tables in the target database based on the SQL statement; The code location module is used to locate the business code that calls the ORM framework configuration file by tracing the service chain. The second determining module is used to determine the second association relationship between the database tables based on the business code using a large language model; The third determining module is used to determine the database table association based on the table structure information, the first association relationship, and the second association relationship.

9. A device for determining database table relationships, characterized in that, include: Processor and memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the steps of the database table association determination method according to any one of claims 1 to 7, based on the instructions in the program code.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code for performing the steps of the database table association determination method according to any one of claims 1 to 7.