A Semantic Topology-Based E-commerce Database Schema Linking Method

CN122570545APending Publication Date: 2026-08-14UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-28
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

然而,该方法难以处理缺乏直观语义描述的中间关联表,导致生成的结构化查询语言(Structured Query Language,SQL)因缺失连接路径而无法正确执行,SQL生成准确率低

Benefits of technology

[0010]本发明实施例提供的技术方案,通过获取待查询文本,并将待查询文本与预先构建的数据库模式图输入至语义嵌入模型进行分析处理,以输出查询嵌入向量以及数据库模式图中每个节点对应的描述向量;为后续势能传播提供起点,根据查询嵌入向量和每个节点的描述向量,确定每个节点的第一势能向量;进一步的,基于每个节点的第一势能向量计算数据库模式图中每条边的阻力权重;最终,基于数据库模式图、数据库模式图中每条边的阻力权重以及第一势能向量,确定连通子图。本技术方案,解决现有方法中因无法召回缺乏直观语义描述的中间关联表导致生成的SQL缺少连接路径而无法执行的问题,实现提升SQL生成准确率以及数据库系统鲁棒性和效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122570545A_ABST
    Figure CN122570545A_ABST
Patent Text Reader

Abstract

This invention discloses a semantic topology-based method for linking e-commerce database schemas. The method includes: acquiring the text to be queried; inputting the text to be queried and a pre-constructed database schema graph into a semantic embedding model for analysis and processing, outputting a query embedding vector and a description vector corresponding to each node in the database schema graph; determining a first potential vector for each node based on the query embedding vector and the description vector of each node; calculating the resistance weight of each edge in the database schema graph based on the first potential vector of each node; and determining a connected subgraph based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential vector. The technical solution provided by this invention improves the accuracy and efficiency of database systems in complex scenarios such as e-commerce.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method for linking e-commerce database schemas based on semantic topology. Background Technology

[0002] As the digital transformation of the e-commerce industry deepens, pattern linking is gradually becoming a key step in user intent retrieval. Pattern linking retrieves target subgraphs related to user intent from the full database schema, enabling precise location of target tables within the database.

[0003] Currently, pattern linking methods typically map queries and table names to the same vector space using a semantic retrieval tool and calculate cosine similarity. However, this method struggles to handle intermediate linked tables that lack intuitive semantic descriptions, resulting in the generated Structured Query Language (SQL) failing to execute correctly due to missing join paths, leading to low SQL generation accuracy. Summary of the Invention

[0004] This invention provides a semantic topology-based e-commerce database schema linking method to improve the accuracy and efficiency of database systems in complex scenarios such as e-commerce.

[0005] In a first aspect, embodiments of the present invention provide a semantic topology-based e-commerce database schema linking method, comprising: Obtain the text to be queried; wherein, the text to be queried is used for pattern linking queries based on the database; The text to be queried and a pre-constructed database schema graph are input into a semantic embedding model for analysis and processing, so as to output a query embedding vector and a description vector corresponding to each node in the database schema graph; wherein, the nodes in the database schema graph represent database tables, and the edges represent the connection relationships between database tables. Based on the query embedding vector and the description vector of each node, determine the first potential vector of each node; calculate the resistance weight of each edge in the database pattern graph based on the first potential vector of each node; Based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential vector, a connected subgraph is determined; wherein the connected subgraph is composed of nodes associated with the text to be queried.

[0006] Secondly, embodiments of the present invention also provide an e-commerce database schema linking device based on semantic topology, the device comprising: The text acquisition module is used to acquire the text to be queried; wherein, the text to be queried is used for pattern linking query based on the database; The description vector output module is used to input the text to be queried and the pre-built database pattern graph into the semantic embedding model for analysis and processing, so as to output the query embedding vector and the description vector corresponding to each node in the database pattern graph; wherein, the nodes of the database pattern graph represent database tables, and the edges represent the connection relationship between database tables. The resistance weight calculation module is used to determine the first potential vector of each node based on the query embedding vector and the description vector of each node; and to calculate the resistance weight of each edge in the database pattern graph based on the first potential vector of each node. The connected subgraph determination module is used to determine a connected subgraph based on the database pattern graph, the resistance weight of each edge in the database pattern graph, and the first potential vector; wherein the connected subgraph is composed of nodes associated with the text to be queried.

[0007] Thirdly, embodiments of the present invention also provide an electronic device, comprising: At least one processor; and A memory that is communicatively connected to at least one processor; wherein, The memory stores a computer program that can be executed by at least one processor, such that the at least one processor can execute a semantic topology-based e-commerce database schema linking method as provided in any embodiment of the present invention.

[0008] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer instructions for causing a processor to execute a semantic topology-based e-commerce database schema linking method as provided in any embodiment of the present invention.

[0009] Fifthly, embodiments of the present invention also provide a computer program product, which includes a computer program that, when executed by a processor, implements a semantic topology-based e-commerce database schema linking method as described in any one of the embodiments of the present invention.

[0010] The technical solution provided by this invention obtains the text to be queried and inputs it along with a pre-constructed database schema graph into a semantic embedding model for analysis and processing. This outputs a query embedding vector and a description vector corresponding to each node in the database schema graph. This provides a starting point for subsequent potential energy propagation. Based on the query embedding vector and the description vector of each node, a first potential energy vector for each node is determined. Further, the resistance weight of each edge in the database schema graph is calculated based on the first potential energy vector of each node. Finally, based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential energy vector, a connected subgraph is determined. This technical solution solves the problem in existing methods where the generated SQL lacks connection paths and cannot be executed due to the inability to recall intermediate association tables that lack intuitive semantic descriptions. This improves the accuracy of SQL generation and the robustness and efficiency of the database system.

[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

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

[0013] Figure 1 A flowchart illustrating a semantic topology-based e-commerce database schema linking method provided in an embodiment of the present invention; Figure 2 A flowchart illustrating the resistance weight calculation process of a semantic topology-based e-commerce database schema linking method provided in this embodiment of the invention; Figure 3 A schematic diagram illustrating the generation of a connected subgraph in an e-commerce database schema linking method based on semantic topology, provided in an embodiment of the present invention. Figure 4 A schematic diagram of a semantic topology-based e-commerce database schema linking method provided in an embodiment of the present invention; Figure 5 An overall framework diagram of a semantic topology-based e-commerce database schema linking method provided in an embodiment of the present invention; Figure 6 A schematic diagram of the structure of an e-commerce database schema linking device based on semantic topology provided in an embodiment of the present invention; Figure 7A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. Detailed Implementation

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

[0015] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0016] Figure 1 This is a flowchart illustrating a semantic topology-based e-commerce database schema linking method provided in an embodiment of the present invention. This embodiment is applicable to schema linking generation scenarios for e-commerce databases. The method can be executed by a semantic topology-based e-commerce database schema linking device, which can be implemented in hardware and / or software and can be configured in a computing device. Figure 1 As shown, the method includes: S110. Obtain the text to be queried; wherein, the text to be queried is used for pattern linking query based on the database; In this embodiment, the text to be queried is text that can be input into the semantic embedding model. This text can be used for pattern linking queries based on a database. It should be noted that the text to be queried can be a query statement presented in natural language. For example, a user can enter "statistics on the product categories with the highest sales last month" to obtain a database table related to "the product categories with the highest sales last month".

[0017] A database can be understood as a system that organizes, stores, and manages data according to a certain data model. Optionally, the database can be a relational database, in which data can be stored in the form of two-dimensional tables, and the tables are linked through foreign keys. A foreign key can be understood as a field or combination of fields used to represent the connection between each table.

[0018] Schema-linked queries can be understood as a process of matching semantic entities in a natural language query with tables, columns, and relationships in a database schema. The schema can be the database's structural definition, such as tables, columns, primary key constraints, foreign key constraints, and indexes. Links establish a mapping relationship between concepts in the user-input query text and specific objects in the database schema.

[0019] The output of a schema-linked query can be a connected subgraph. This connected subgraph includes the database tables related to the queried text and the join paths between these tables. It's worth noting that the connected subgraph output by a schema-linked query can be used to guide the generation of SQL statements.

[0020] Specifically, to locate the target table in the database that the user needs to access, the user must input the query text in natural language. The query text serves as the core input for the system to understand the user's intent, triggering subsequent semantic parsing and pattern linking processes. Finally, the system outputs the corresponding query results to improve the accuracy of intent understanding.

[0021] S120. Input the text to be queried and the pre-built database schema graph into the semantic embedding model for analysis and processing, so as to output the query embedding vector and the description vector corresponding to each node in the database schema graph; wherein, the nodes in the database schema graph represent database tables, and the edges represent the connection relationship between database tables.

[0022] In this embodiment, the database schema diagram is represented using a graph structure. This data representation is used to describe the overall structure of the database. It should be noted that in the database schema, nodes represent database tables. Edges represent the connection between two nodes, i.e., tables. In relational databases, this connection is defined by foreign key constraints. For example, the `user_id` field in the `order` table references the `id` field in the `user` table, meaning that the corresponding node in the `order` table is connected to the corresponding node in the `user` table by an edge.

[0023] For example, consider an e-commerce database containing a user table T1, an order table T2, a product table T3, an order details table T4, and a log table T5. The database schema is parsed as an undirected graph. In this system, T1 and T2 are associated through user IDs, T2 and T4 through order IDs, T4 and T3 through product IDs, and T1 and T5 through user IDs. Therefore, the constructed node set is... The set of edges is determined by the foreign key relationship, and the set of edges is {(T1,T2), (T2,T4), (T4,T3), (T1,T5)}.

[0024] A semantic embedding model can be a machine learning model that converts text into fixed-length numerical vectors. Optionally, the data input to the semantic embedding model can be natural language text, and the output data after processing by the semantic embedding model is the embedding vector corresponding to the natural semantic text. This embedding vector represents the meaning of the text in the semantic space.

[0025] It should be noted that the semantic embedding model can be a pre-trained model that can be used directly. That is, using a pre-prepared semantic dataset, the sample data in the semantic dataset is input into the semantic embedding model to output embedding vectors. The backpropagation algorithm is then used to iteratively optimize the model based on the corresponding loss function to determine the semantic embedding model applied in this embodiment.

[0026] In this embodiment, the user-inputted query text can be fed into a semantic embedding model for analysis and processing, and then a query embedding vector corresponding to the query text can be output. The query embedding vector is a vector output by the semantic embedding model after encoding the query text; this vector represents the semantic features of the user's query.

[0027] Simultaneously, the pre-constructed database schema graph is input into the semantic embedding model for processing, outputting a description vector corresponding to each node in the database schema graph. The description vector can be a vector encoded by the semantic embedding model as the text description of each node in the database schema graph. Optionally, the text description of each node in the database schema graph may include table names, column names, and comments.

[0028] Specifically, to obtain tables semantically related to the text to be queried, the text to be queried and a pre-built database schema graph can be input into a semantic embedding model for processing. On one hand, features are extracted from the text to be queried, outputting a query embedding vector representing the user's query intent; on the other hand, each node in the database schema graph is encoded to obtain a description vector corresponding to that node. This description vector is used to represent the semantic information of the corresponding database table, mapping the text to be queried and the database schema graph to the same vector space, thus achieving semantic space unification.

[0029] It should be noted that, in order for the semantic embedding model to fully capture the business meaning and structural information of each database table, optionally, the node attributes of the nodes in the database schema diagram should at least include the table name, column name, and comments.

[0030] In this embodiment, node attributes can be metadata information attached to each node in the database schema diagram. This metadata information describes the structure and semantic characteristics of the database table corresponding to the node. Node attributes include at least the table name, column names, and comments. The table name is a unique identifier for each table in the database. This name represents the subject of the data stored in the table. The column name is the name of each field in the table. It can be understood that the column name is used to distinguish the business meaning of different fields in the same table, further refining the semantics of the table. Comments are additional textual descriptions of the table or column. Optionally, these descriptions can be added by developers to explain the business meaning of the table or column.

[0031] Specifically, the description vector is obtained by concatenating table names, column names, and comments into a text description and then inputting it into the semantic embedding model. The description vector output by the semantic embedding model integrates multi-dimensional textual information such as table names, column names, and comments, preserving semantic richness and making subsequent similarity calculations more accurate.

[0032] S130. Based on the query embedding vector and the description vector of each node, determine the first potential energy vector of each node; calculate the resistance weight of each edge in the database pattern graph based on the first potential energy vector of each node. In this embodiment, the first potential vector is the final importance measure that integrates semantic relevance and the topological structure of the database schema graph. It should be noted that the first potential vector is a numerical vector with a length equal to the number of nodes in the database schema graph. Each component of this numerical vector can characterize the importance of the corresponding node.

[0033] Resistance weight is an attribute of each edge in the database schema graph. This attribute represents the cost of traversing between two nodes. The smaller the resistance weight value, the more likely the corresponding edge is to be selected by the path planning algorithm. The benefit of calculating the resistance weight of each edge in the database schema graph is that it provides a data foundation for subsequently determining the set of minimum resistance paths connecting all nodes.

[0034] Specifically, to reflect the semantic matching degree between the table and the query, based on the query embedding vector output by the semantic embedding model and the description vector of each node, the first potential vector of each node in the database schema graph is calculated. This allows the importance of each node to diffuse along the topology through the potential energy propagation mechanism on the graph, thereby enabling implicit intermediate tables that lack semantics but are essential to the topology to obtain higher potential energy. Furthermore, the resistance weight of the edges between nodes is determined based on the first potential vector of each node, i.e.: ; in, For the edge The resistance weights, where i and j represent node indices. For nodes The first potential vector, For nodes The first potential vector, This is to smooth out the terms and prevent the denominator from being 0.

[0035] The resistance weights of the edges are constructed based on the above formula. See [link / reference] Figure 2 After obtaining the first potential energy vector, the first potential energy vector of adjacent nodes i and j is extracted, and the geometric mean is calculated and the reciprocal is taken to determine the edge resistance (resistance weight). This ensures that the edge connecting high potential energy nodes has low resistance and the edge connecting low potential energy nodes has high resistance, thus solving the problem of inaccurate SQL generation caused by the inability of existing methods to recall implicit intermediate tables.

[0036] To ensure that the initial semantic relevance propagates along the topology of the database schema graph, a first potential vector for each node can be determined based on the query embedding vector and the description vector of each node. The process of determining the first potential vector is further refined below. Optionally, determining the first potential vector for each node based on the query embedding vector and the description vector of each node includes: The similarity between the query embedding vector and the description vector of each node is calculated to obtain the second potential energy vector of each node. The second potential energy vector is then nonnegated and normalized to obtain the third potential energy vector of each node. A state transition matrix is ​​constructed based on the database pattern graph. The state transition matrix is ​​used to represent the probability of energy flowing from a node to its neighboring nodes. Using the third potential energy vector as the initial vector, the state transition matrix, the preset restart probability, and the preset iteration stopping rule are used for iterative updates until the preset iteration stopping rule is met, and the first potential energy vector is output.

[0037] In this embodiment, similarity calculation can be understood as a computational process that quantifies the degree of similarity between two vectors. Optionally, similarity calculation can use cosine similarity or dot product. That is, the similarity of the query embedding vector with the description vector of each node is calculated, and the obtained similarity value is used as the second potential vector of each node. The larger the second potential vector, the more relevant the table is to the query text input by the user.

[0038] The second potential vector can be a numerical value obtained after calculating the similarity of each node. This value is used to characterize the semantic matching degree between the table corresponding to the node and the text to be queried. It should be noted that each node in the database schema graph corresponds to a second potential vector.

[0039] Furthermore, to avoid propagation anomalies and eliminate dimensional differences, the second potential energy vector is subjected to nonnegativity and normalization. Nonnegativity involves setting all negative values ​​in the second potential energy vector to zero, ensuring that all potential energy values ​​are non-negative. Normalization involves scaling the nonnegative vector so that the sum of all components is 1, thus outputting the third potential energy vector.

[0040] The third potential energy vector is obtained by nonnegating the second potential energy vector. The third potential energy vectors corresponding to all nodes are nonnegative and sum to 1. This potential energy vector represents the probability distribution of energy at each node at the initial moment. That is: ; in, Let be the potential energy vector of the i-th node. To find the maximum value function, To query the embedded vector, Let be the description vector of the i-th node. A preset threshold, which can be set between 0 and 1, is used to suppress low-similarity noise. For example, it can be... Set it to 0.4.

[0041] Based on the above formula, the cosine similarity between the text to be queried and the description vector of each node, i.e. the second potential vector, is calculated, and a preset threshold is subtracted to remove weakly correlated tables and then nonnegated.

[0042] Furthermore, after nonnegativity, the potential energy vector is normalized to obtain the third potential energy vector. It should be noted that the normalized third potential energy vector satisfies... ,and .in, Let be the normalized potential energy vector of the i-th node, which is also the third potential energy vector. This is the potential energy vector after nonnegativity.

[0043] The state transition matrix is ​​a square matrix constructed based on the database schema graph. The dimension of the state transition matrix equals the number of nodes. It's important to note that the state transition matrix represents the probability of energy flowing from the root node to its neighboring nodes. This probability can be understood as the probability that energy transfers from one node to another during a random walk of potential energy at each node. In other words, each element in the state transition matrix represents the probability of starting from one node and randomly walking along an outgoing edge to reach another node.

[0044] It should be noted that the matrix elements in the state transition matrix are determined based on the adjacency matrix and the degree of the nodes: ; in, The element in the i-th row and j-th column of the state transition matrix. Let j be the degree of node j. It is the element in the i-th row and j-th column of the adjacency matrix.

[0045] The adjacency matrix is ​​a square matrix used to represent the connections between nodes in the database schema graph. The elements of the adjacency matrix are determined based on the edges between all nodes in the database schema graph. For example, if the elements in the adjacency matrix... If the value is 1, then the node is represented. With nodes An edge exists between two tables, meaning there is a foreign key connection between them. The degree of a node is the number of edges directly connected to that node. For example, if a node has three foreign keys linking it to other tables, then that node has a degree of 3.

[0046] The preset restart probability is a pre-defined hyperparameter. This hyperparameter indicates the probability at which energy is reset to the initial distribution in each iteration. The preset iteration stopping rule is the condition for determining whether the iteration process has converged. Optionally, the preset iteration stopping rule is that the difference between the potential energy vectors output by two adjacent iterations is less than a preset threshold. ; in, Let be the potential energy vector after the (t+1)th iteration. Let be the potential energy vector after the t-th iteration. This is a preset threshold.

[0047] Specifically, the query embedding vector and the description vector of each node are obtained from the semantic embedding model. Similarity is calculated between the query embedding vector and the description vector of each node to obtain the similarity result and third potential vector for each node. This process eliminates potential negative values ​​in the similarity calculation, avoids anomalies during potential propagation, and ensures that the initial potential of all nodes meets the probability distribution requirements. Furthermore, an adjacency matrix is ​​constructed based on the edges between nodes in the database pattern graph, and the state transition matrix is ​​determined based on the elements in the adjacency matrix and the degree of the nodes.

[0048] The state transition matrix is ​​determined based on the edges between nodes and the degree of each node in a pre-constructed database schema graph. After determining the state transition matrix, the potential vector is iteratively updated based on the state transition matrix, the preset restart probability, and the third potential vector. ; in, Let be the potential energy vector after the (t+1)th iteration. Let be the potential energy vector after the t-th iteration. Here is the state transition matrix. For the probability of restarting, This is the third potential energy vector. For diffusion term, This is a restart item.

[0049] The potential energy vector is iteratively updated based on the above formula. See also... Figure 2 First, set the preset restart probability. and convergence threshold The third potential energy vector is used as the initial vector for iteration. Further, the above formula is iterated repeatedly. In each iteration, the distribution of the current potential energy vector after one random walk along the database pattern graph topology is determined. This walk result is then retained with a weight of 1-c, and the third potential energy vector is superimposed with a weight of c. This involves calculating the diffusion term and the restart term, and summing them to obtain the potential energy vector for the next iteration. After each iteration, convergence is checked by calculating the norm difference between two adjacent potential energy vectors. When this difference is less than a preset threshold, the potential energy distribution is considered to have converged, and the iteration stops. Finally, the final potential energy vector, i.e., the first potential energy vector, is obtained. ,in, Let be the first potential vector. Let be the first potential vector of the first node. Let T be the first potential vector of the nth node, and T be the device symbol. The advantage of obtaining the first potential vector through iterative updates is that it realizes the transformation from semantic similarity to the topological potential field of the database graph. It propagates on the database graph through the state transition matrix and restart probability, and after convergence, it obtains the final potential energy that integrates semantics and structure, thereby improving the accuracy and interpretability of database pattern link generation.

[0050] It should be noted that during the iterative update of the first potential energy vector, an iteration stopping rule can be preset. It should be noted that after determining the second potential vector through similarity calculation, the second potential vectors of all nodes need to be evaluated. The evaluation result determines whether further processing is required. Optionally, after calculating the similarity between the query embedding vector and the description vector of each node to obtain the second potential vector of each node, the method further includes: The second potential vectors of all nodes are summed to obtain the sum result; if the sum result is equal to zero, a preset prompt message is output and the execution of subsequent steps is terminated.

[0051] In this embodiment, the process of summing the second potential vectors of all nodes can be understood as performing a summation operation on the second potential vectors of all nodes to obtain a summation result. This summation result reflects the sum of the initial semantic relevance of the nodes.

[0052] The preset message is a pre-defined text message from the system. This message informs the user that the current query cannot match any database table. For example, the preset message is "No database table related to the query found".

[0053] Specifically, after determining the second potential vector of all nodes, the second potential vector is evaluated. When the sum of the second potential vectors after semantic similarity calculation equals zero, it indicates that the relevance between all tables and the user-input query text is zero. In this case, there is no need to continue with subsequent graph propagation and connected subgraph determination. The preset prompt information is displayed directly and the process ends to improve system efficiency and user experience.

[0054] S140. Based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential vector, determine the connected subgraph; wherein the connected subgraph is composed of nodes associated with the text to be queried.

[0055] In this embodiment, the connected subgraph is a subgraph composed of nodes associated with the text to be queried. Each node corresponds to a table in the database schema, the edges between nodes represent the association between tables, and the resistance weight of the edge reflects the semantic tightness of the association path.

[0056] In other words, the connected subgraph is a highly relevant and low-resistance connected substructure extracted from the database schema graph based on the first potential vector and the resistance weights of the edges, through potential energy propagation. All tables in this subgraph have a direct or indirect semantic relationship with the text to be queried.

[0057] It's important to note that after obtaining the connected subgraph, SQL statements can be automatically generated based on it. That is, the nodes in the connected subgraph indicate the tables involved in the SQL query. Because the connected subgraph filters out a large number of irrelevant tables, the accuracy and execution efficiency of the SQL query are improved.

[0058] Furthermore, to extract a connected subgraph from the database schema graph that contains all tables related to the text to be queried and can automatically import necessary intermediate tables, the following section elaborates on the process of determining the connected subgraph based on the database schema graph, resistance weights, and the first potential vector. Optionally, the connected subgraph is determined based on the database schema graph, the resistance weights of each edge in the database schema graph, and the first potential vector, including: Based on the database schema graph and the second potential vector of each node, an anchor point set is determined; wherein the second potential vector of each node in the anchor point set is greater than zero; based on the database schema graph and the resistance weight of each edge in the database schema graph, a weighted graph is constructed; wherein the number of nodes in the weighted graph is the same as the number of nodes in the database schema graph, and the edge attributes in the weighted graph are the resistance weights of each edge in the database schema graph; the single-source shortest path algorithm is executed on the weighted graph, and a connected subgraph is output.

[0059] In this embodiment, the anchor point set is a set of nodes in the database pattern graph that satisfy a preset rule. Optionally, the preset rule can be that the second potential vector of a node is greater than zero. Such nodes are used as anchor points in the anchor point set. That is, only nodes with positive contributions can be selected as anchor points in the anchor point set to ensure that the anchor point set has directionality and avoid interference from a large number of irrelevant zero-potential-energy nodes in the subsequently generated connected subgraph.

[0060] A weighted graph can be understood as a graph obtained by assigning a resistance weight as an edge attribute to each edge, based on the database schema graph. It's important to note that the set of nodes in the weighted graph is exactly the same as the set of nodes in the database schema graph, while the edge attributes in the weighted graph are resistance weights.

[0061] The single-source shortest path algorithm can be used to calculate the shortest path from a source node to all nodes in a graph. It should be noted that nodes in the anchor set can serve as source nodes. After processing by the single-source shortest path algorithm, the output can be the shortest distance from a node in the anchor set to all nodes in the graph.

[0062] Specifically, based on the database pattern graph and the second potential vector of each node, nodes with a second potential vector greater than zero are first selected to form an anchor point set. This avoids including a large number of irrelevant nodes in subsequent processing, reducing computational complexity. Furthermore, using the database pattern graph and the resistance weight of each edge in the graph, a relationship between the number of nodes and the database pattern is constructed. Figure 1 This process constructs a weighted graph where each edge is assigned a resistance weight. Finally, based on multiple nodes in the anchor set, a single-source shortest path algorithm is performed on the weighted graph to calculate the minimum resistance distance from the anchor set to all nodes in the weighted graph, ensuring subgraph connectivity while eliminating redundant tables. Finally, all nodes reachable from the anchor set and whose resistance distance is within a threshold range are extracted, outputting a connected subgraph. This reduces the number and complexity of table joins, avoids omissions and errors in multi-table joins, and improves the execution efficiency and readability of the generated SQL.

[0063] For example, see Figure 3 Nodes in a weighted graph The node potential energy is relatively high, and the calculated drag weights are... Minimal. Furthermore, based on the second potential vector of the node, the set of anchor points is obtained. Select the one with the highest potential energy vector. As the root node, in the weighted graph The single-source shortest path algorithm is executed to calculate the root node. arrive The shortest path. Furthermore, based on the single-source shortest path algorithm, the path with minimum resistance is determined as... That is, the starting point is The user table starts with entity "A"; the end table is the product table, with entity "B" as the target; the intermediate table is... and To connect the paths between users and products, and to remove [items] during the extraction of connected subgraphs. , The interference table is independent of the target, and the foreign keys (1), (2), and (3) represent the associations between the tables. The nodes and edges on the path are merged to generate a connected subgraph.

[0064] It should be noted that, after constructing the weighted graph, to calculate the shortest path from the set of anchor points to each node and extract the connected subgraph based on this, a single-source shortest path algorithm based on a priority queue can be used. The following section elaborates on the specific process of outputting the connected subgraph based on the single-source shortest path algorithm. Optionally, the single-source shortest path algorithm is performed on the weighted graph to output the connected subgraph, including: Initialize the node distances of all nodes and the distances between the predecessor and root nodes of all nodes. Node distances represent the shortest path from the root node to the current node, and predecessor nodes represent the previous node of the current node. The root node is the node with the largest first potential vector in the anchor set. Define a pre-defined queue and add the root node as a node to be processed. The pre-defined queue stores nodes to be processed in ascending order of node distance. Nodes to be processed are those in the pre-defined queue that need to participate in the queue update process. Remove the node with the smallest node distance from the pre-defined queue as the target node. The target node is the node that did not participate in the queue update process. For each neighbor of the target node, execute the queue update process to update the queue. Repeat this process until the queue is empty. For each node in the anchor set, backtrack along the predecessor nodes to determine the connected subgraph.

[0065] In this embodiment, the node distance is the shortest path length from the root node to the current node in the single-source shortest path algorithm. This length is represented by the sum of the resistance weights of all edges on the path.

[0066] Before executing the single-source shortest path algorithm, the predecessor and root nodes of all nodes can be initialized. The predecessor node can be the node preceding the current node in the shortest path tree. Each node, except the root node, has one and only one predecessor node. The advantage of determining the predecessor node is that the complete shortest path from the root node to each node can be reconstructed during the final backtracking process.

[0067] The root node can be the starting point for a single-source shortest path algorithm. Optionally, the first potential vector of all nodes in the anchor set can be compared, and the node with the largest first potential vector in the anchor set can be used as the root node. The advantage of using the node with the largest first potential vector in the anchor set as the root node is that this node has the highest relevance to the query text. Expanding the shortest path from this node can prioritize covering tables with high relevance to the query text, thereby improving the focus of the connected subgraph on the query intent of the query text.

[0068] The root node distance is the length of the shortest path from the root node to itself, and can be set to 0 during the initialization of the single-source shortest path algorithm.

[0069] Optionally, the initialization process can be to initialize all nodes with positive infinity, empty predecessor nodes, and zero root node distance.

[0070] The preset queue is a priority queue used to manage nodes awaiting processing. Nodes in this queue are stored in ascending order of distance, and the node with the smallest current distance is retrieved each time. It's important to note that the nodes stored in the preset queue are nodes awaiting processing. These can be understood as nodes already added to the preset queue. The target node is the node retrieved from the preset queue with the smallest distance from the nodes awaiting processing. In other words, this node is the one whose shortest path is determined in the current round. It's crucial that the target node is a node that has not participated in the preset queue update process; that is, a node awaiting processing that has not yet been retrieved from the preset queue.

[0071] The preset queue update process involves replacing the nodes to be processed in the preset queue. The preset queue update can stop when the preset queue is empty, meaning that the update stops when there are no nodes to be processed in the preset queue, and all shortest path distances have been calculated.

[0072] Backtracking can be understood as, for each node in the anchor set, tracing backwards from that node along its predecessor nodes to the root node, thus obtaining the complete path from the root node to that node. The complete path can include the node, the root node, intermediate nodes, and the corresponding edges between nodes. The advantage of backtracking is that it can collect all nodes in the anchor set, as well as all intermediate nodes and edges on the path, providing a data source for determining the subsequent connected subgraph. This ensures that the connected subgraph contains all nodes highly relevant to the query text, guaranteeing the connectivity of the subgraph.

[0073] Specifically, before executing the single-source shortest path algorithm, the node distances, predecessor node distances, and root node distances of all nodes can be initialized by setting node distances to infinity, predecessor node distances to empty, and root node distances to zero. Further, the node with the largest first potential vector from the anchor set is selected as the root node, serving as the starting point for path searching. A pre-defined queue is constructed, and the root node is added to it as the initial node to be processed. The node with the smallest node distance in the pre-defined queue is selected as the target node, and the pre-defined queue is updated until it is empty, thus achieving the acquisition of the shortest path distance from the root node to all reachable nodes and its predecessor node. After updating the pre-defined queue, for each node in the anchor set, backtracking is performed along its respective predecessor node until the root node is reached. All intermediate nodes and connecting edges along the path from that node to the root node are determined during the backtracking process, thereby constructing a connected subgraph to improve query focus and semantic relevance, ensure the connectivity and path optimality of the connected subgraph, and reduce the complexity of subsequent calculations and SQL generation.

[0074] Furthermore, the update process for the preset queue is further refined. Optionally, for each neighboring node of the target node, the preset queue update process is executed to update the preset queue, including: For each neighboring node of the target node, calculate the sum of the node distance of the target node and the target resistance weight to obtain the candidate distance; where the target resistance weight is the resistance weight of the corresponding edge between the target node and the neighboring node; if the candidate distance is less than the node distance of the neighboring node, update the node distance of the neighboring node to the candidate distance, and take the target node as the predecessor node of the neighboring node, and add the neighboring node to the preset queue.

[0075] In this embodiment, each neighboring node of the target node can be a node directly connected to the target node via an edge in the weighted graph. The node distance of the target node is the length of the currently known shortest path from the root node to the target node. The shortest path length is the sum of the resistance weights of all edges on the path.

[0076] The target resistance weight is the resistance weight of the edge connecting the target node and its adjacent nodes. This weight represents the energy required to travel from one node to that adjacent node.

[0077] The candidate distance is a temporary path length. It can be understood as the total energy required to reach the target node via the shortest path, starting from the root node, and then traversing the current edge to the adjacent node. Optionally, the candidate distance can be determined by calculating the sum of the target node's distance and the target resistance weight.

[0078] For example, for a node z that is adjacent to node u, obtain the node distance. and the resistance weights of the edges corresponding to nodes u and z The candidate distance is determined by summing the node distance and resistance weight. The candidate distance is then compared with the node distance of node z. Compare. If Then update the node distance of node z. And set the predecessor node of node z as node z, that is At the same time, z is inserted into or updated in the preset queue Q.

[0079] Specifically, the node with the smallest distance in the current preset queue is selected as the target node. If this is the first update process, the preset queue only contains the root node, which is then selected as the target node. The neighboring nodes of the target node are determined, and the resistance weights of the edges between the target node and each neighboring node are obtained, which are then used as the target resistance weights.

[0080] Furthermore, the sum of the target node distance and the target resistance weight is calculated, and the sum is used as the candidate distance. The candidate distance is compared with the currently stored node distance of the adjacent node, i.e., the currently known shortest path estimate from the root node to the adjacent node. If the candidate distance is greater than or equal to the current node distance of the adjacent node, it indicates that no shorter path can be obtained through the target node, and no update is needed. If the candidate distance is less than the current node distance of the adjacent node, it indicates that a shorter path exists, and an update operation is performed. The update operation includes at least updating the node distance, updating the predecessor node, and updating the queue. Specifically, the node distance of the adjacent node is modified to the candidate distance, the predecessor node of the adjacent node is set as the target node, and the adjacent node is added to a preset queue as a node to be processed.

[0081] The above comparison and update operations are performed one by one on all the neighboring nodes of the target node. When all neighboring nodes have been processed, the current target node update operation ends. Then, the next node to be processed with the smallest distance from the preset queue can be taken as the target node. The above process is repeated until the preset queue is empty, so as to ensure the optimality of the path and improve the semantic relevance of the connected subgraph.

[0082] Furthermore, the backtracking process for each node in the anchor point set is described in detail. Optionally, for each node in the anchor point set, backtracking is performed along the predecessor node to determine the connected subgraph, including: For each node in the anchor set, based on that node, backtrack upwards along the predecessor nodes until the root node, and obtain the nodes traversed and the edges connecting the nodes; merge all the obtained nodes and edges to generate a connected subgraph.

[0083] Specifically, each node in the anchor set is retrieved sequentially. For the current node (an anchor), its predecessor node is determined, and the process iterates upwards along the predecessor node from the current node until the root node is reached. During the backtracking process, each node traversed is recorded, including the anchor itself, all intermediate nodes on the path, and the root node, while also identifying the edges connecting adjacent nodes. This backtracking process is performed on all nodes in the anchor set. All retrieved nodes and edges are merged, and a graph structure, i.e., a connected subgraph, is constructed based on the merged nodes. This ensures that the connected subgraph contains all core nodes, eliminates redundancy, reduces the complexity of the connected subgraph, and guarantees its connectivity.

[0084] The technical solution provided by this invention obtains the text to be queried and inputs it along with a pre-constructed database schema graph into a semantic embedding model for analysis and processing. This outputs a query embedding vector and a description vector corresponding to each node in the database schema graph. This provides a starting point for subsequent potential energy propagation. Based on the query embedding vector and the description vector of each node, a first potential energy vector for each node is determined. Further, the resistance weight of each edge in the database schema graph is calculated based on the first potential energy vector of each node. Finally, based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential energy vector, a connected subgraph is determined. This technical solution solves the problem in existing methods where the generated SQL lacks connection paths and cannot be executed due to the inability to recall intermediate association tables that lack intuitive semantic descriptions. It improves the accuracy of SQL generation and the robustness and efficiency of the database system.

[0085] Figure 4 This is a flowchart illustrating a semantic topology-based e-commerce database schema linking method according to an embodiment of the present invention. Based on the foregoing embodiments, this embodiment elaborates on the process of constructing the database schema graph. For example... Figure 4 As shown, the method includes: S210. Obtain the database schema; wherein the database schema contains at least multiple database tables and the connection relationships between the multiple database tables.

[0086] In this embodiment, the database schema specifies how data is organized, stored, and constrained within the database. Optionally, the database schema may include at least tables, columns, data types, primary key constraints, foreign key constraints, and indexes.

[0087] A database table is the basic logical unit used to store data in a database. It has a two-dimensional structure consisting of rows and columns. A join relationship can be understood as the logical association established between different database tables through foreign keys and primary keys in a relational database.

[0088] Specifically, in order to construct the database schema graph required for subsequent algorithms and extract connected subgraphs, it is first necessary to obtain the database schema to provide a data foundation for subsequent processing.

[0089] S220. Based on multiple database tables, determine multiple nodes in the database schema diagram; wherein the number of multiple database tables is the same as the number of multiple nodes; Specifically, taking all the obtained database tables as input, a corresponding node is created for each table, thus constructing a node set for the database schema graph. Because a one-to-one correspondence transformation method is used, the number of data in the database tables and the number of nodes remain consistent. This is the fundamental premise for attaching a potential energy vector to each subsequent node and assigning resistance weights to the edges.

[0090] S230. Based on the connection relationships between multiple database tables, determine multiple edges of the database schema graph; Specifically, the database schema is obtained. Based on the obtained multiple database tables, multiple nodes of the database schema graph are determined, with the number of database tables matching the number of nodes. Simultaneously, based on the connection relationships between the multiple database tables, multiple edges of the database schema graph are determined, with each edge corresponding to a usable inter-table association path. This ensures the complete preservation of the original structural information and facilitates the expansion of semantic and weight information.

[0091] S240. Construct a database schema graph based on the multiple nodes and edges of the database schema graph.

[0092] Specifically, a complete database schema graph is constructed based on multiple nodes and their corresponding edges. This graph uses tables as nodes and connections as edges, providing the basic graph structure for subsequent potential vector replication, resistance weight configuration, and node selection in the anchor point set.

[0093] The technical solution provided by this invention involves obtaining a database schema; determining multiple nodes of a database schema graph based on multiple database tables; determining multiple edges of the database schema graph based on the connection relationships between multiple database tables; and finally, constructing a database schema graph based on the multiple nodes and edges of the database schema graph. This solves the problem that relational database schemas are difficult to directly perform semantic similarity calculation, graph structure search, and automated schema linking, and provides a graph structure foundation for subsequent connected subgraph extraction.

[0094] Figure 5 This is an overall framework diagram of a semantic topology-based e-commerce database schema linking method provided in an embodiment of the present invention. Based on the above embodiment, an optional example is provided, which can be used for database schema linking scenarios.

[0095] like Figure 5As shown, firstly, a database schema graph is constructed and semantic energy is initialized based on the database schema. The database schema is represented as an undirected graph. Nodes in the schema graph represent sets of database tables, and edges represent sets of foreign key connections between tables. When a user inputs a natural language query (the text to be queried), the natural language query and the database schema graph are input into a pre-trained embedding model (semantic embedding model) for analysis and processing. The semantic relevance of each node in the database schema graph to the natural language query is calculated to obtain the initial potential energy (second potential energy vector). To prevent division by zero anomalies, the second potential energy vector is nonnegated and normalized to obtain the restart vector (third potential energy vector) for each node.

[0096] Furthermore, based on the propagation potential energy of the random walk to be restarted, firstly, an adjacency matrix of the database pattern graph is established based on the nodes and corresponding edges in the graph. Then, the degree matrix is ​​determined based on the number of edges connected to each node. Based on the determined adjacency matrix and degree matrix, a normalized transition matrix (state transition matrix) is constructed, where each element represents the probability of energy flowing from one node to another. Further, a preset restart probability and a preset threshold are set. Based on the state transition matrix and the preset restart probability, a restart random walk iteration is performed using the third potential energy vector as the initial vector until the preset iteration stopping rule is met, outputting a stable potential energy vector (first potential energy vector).

[0097] Furthermore, resistance modeling is performed based on potential energy vectors. For any existing edge, resistance weights are constructed based on the stable potential energy vector. That is, for each edge in the database pattern graph, a positive metric representing its degree of association is obtained. To convert the positive metric into resistance weights suitable for the shortest path algorithm, a reciprocal transformation is used. After the reciprocal transformation, the more closely associated edges are originally, the smaller their resistance weights. A semantic-topological resistance network (weighted graph) is then constructed based on the resistance weights.

[0098] Furthermore, an approximate minimum Steiner tree extraction is performed. Nodes with a second potential vector greater than zero are grouped into an anchor point set, and the node with the largest first potential vector is selected as the root node. Further, the single-source shortest path algorithm is executed on the weighted graph. The execution process is described below: First, initialize the node distances of all nodes in the database schema graph to infinity, the predecessor node to empty, and the root node distance to 0. Construct a pre-defined queue prioritizing node distances, initially including the root node. Next, iteratively retrieve the node with the smallest current node distance from this queue. If it has already been visited, skip it; otherwise, mark it as visited. For all adjacent nodes of the current node, calculate a candidate distance based on the sum of the node distance and the resistance weight. Compare this candidate distance with the node distances of adjacent nodes. If the candidate distance is smaller than the adjacent node's distance, update the adjacent node's distance to the candidate distance, designate the target node as the predecessor node of the adjacent node, and add the adjacent node to the pre-defined queue. Repeat this process until the queue is empty.

[0099] Then, for each node in the anchor set, backtrack from that node to the root node along its predecessor, collect all nodes and edges on the backtracking path, and merge them to obtain a connected subgraph. The connected subgraph is an approximately minimum-cost Steiner tree that contains all nodes in the anchor set.

[0100] Figure 6 This is a schematic diagram of a semantic topology-based e-commerce database schema linking device provided in an embodiment of the present invention. Figure 6 As shown, the device includes: a text acquisition module 310, a description vector output module 320, a resistance weight calculation module 330, and a connected subgraph determination module 340.

[0101] The system includes a text acquisition module 310 for acquiring the text to be queried, wherein the text to be queried is used for pattern linking queries based on a database; a description vector output module 320 for inputting the text to be queried and a pre-constructed database pattern graph into a semantic embedding model for analysis and processing, thereby outputting a query embedding vector and a description vector corresponding to each node in the database pattern graph; wherein the nodes in the database pattern graph represent database tables, and the edges represent the connection relationships between database tables; a resistance weight calculation module 330 for determining a first potential vector for each node based on the query embedding vector and the description vector of each node; and calculating the resistance weight of each edge in the database pattern graph based on the first potential vector of each node; and a connected subgraph determination module 340 for determining a connected subgraph based on the database pattern graph, the resistance weight of each edge in the database pattern graph, and the first potential vector; wherein the connected subgraph is composed of nodes associated with the text to be queried.

[0102] The technical solution provided by this invention obtains the text to be queried and inputs it along with a pre-constructed database schema graph into a semantic embedding model for analysis and processing. This outputs a query embedding vector and a description vector corresponding to each node in the database schema graph. This provides a starting point for subsequent potential energy propagation. Based on the query embedding vector and the description vector of each node, a first potential energy vector for each node is determined. Further, the resistance weight of each edge in the database schema graph is calculated based on the first potential energy vector of each node. Finally, based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential energy vector, a connected subgraph is determined. This technical solution solves the problem in existing methods where the generated SQL lacks connection paths and cannot be executed due to the inability to recall intermediate association tables that lack intuitive semantic descriptions. It improves the accuracy of SQL generation and the robustness and efficiency of the database system.

[0103] Based on the above embodiments, the database schema diagram is constructed in the following manner: A pattern acquisition module is used to acquire a database pattern; wherein the database pattern includes at least multiple database tables and the connection relationships between the multiple database tables; a node determination module is used to determine multiple nodes of the database pattern graph based on the multiple database tables; wherein the number of multiple database tables is consistent with the number of multiple nodes; an edge determination module is used to determine multiple edges of the database pattern graph based on the connection relationships between the multiple database tables; and a database pattern graph construction module is used to construct the database pattern graph based on the multiple nodes and multiple edges of the database pattern graph.

[0104] Based on the above embodiments, the resistance weight calculation module includes: The second potential vector determination unit is used to calculate the similarity between the query embedding vector and the description vector of each node to obtain the second potential vector of each node; and to perform nonnegation and normalization processing on the second potential vector to obtain the third potential vector of each node. A matrix construction unit is used to construct a state transition matrix based on the database schema graph; the state transition matrix is ​​used to represent the probability of energy flowing from a node to an adjacent node; The first potential energy vector output unit is used to iteratively update the first potential energy vector based on the state transition matrix, the preset restart probability, and the preset iteration stop rule, using the third potential energy vector as the initial vector, until the preset iteration stop rule is satisfied.

[0105] Based on the above embodiments, the connected subgraph determination module includes: An anchor point set determination unit is used to determine an anchor point set based on the database pattern graph and the second potential energy vector of each node; wherein the second potential energy vector of the nodes in the anchor point set is greater than zero; A weighted graph construction unit is used to construct a weighted graph based on the database schema graph and the resistance weight of each edge in the database schema graph; wherein the number of nodes in the weighted graph is the same as the number of nodes in the database schema graph, and the edge attributes in the weighted graph are the resistance weights of each edge in the database schema graph; The connected subgraph output unit is used to perform a single-source shortest path algorithm on the weighted graph and output a connected subgraph.

[0106] Based on the above embodiments, the connected subgraph output unit includes: An initialization processing subunit is used to initialize the node distances of all nodes and the distances between the predecessor nodes and the root node of all nodes; wherein, the node distance is used to represent the shortest path information from the root node to the current node, the predecessor node is used to represent the previous node of the current node; and the root node is the node with the largest first potential vector in the anchor point set. The queue update subunit is used to define a preset queue and add the root node as a node to be processed to the preset queue; wherein, the preset queue is used to store the nodes to be processed in ascending order of node distance; the nodes to be processed are the nodes in the preset queue that need to participate in the preset queue update process; The target node determination subunit is used to extract the node to be processed with the smallest distance from the preset queue as the target node; wherein, the target node is the node to be processed that has not participated in the preset queue update process; The preset queue update subunit is used to perform a preset queue update process for each adjacent node of the target node to update the preset queue; The connected subgraph determines the sub-unit, which is used to execute iteratively until the preset queue is empty; for each node in the anchor point set, the current node is backtracked along the predecessor node to determine the connected subgraph.

[0107] Based on the above embodiments, a preset queue update subunit includes: The candidate distance determination subunit is used to calculate the sum of the node distance of the target node and the target resistance weight for each neighboring node of the target node to obtain the candidate distance; wherein, the target resistance weight is the resistance weight of the corresponding edge between the target node and the neighboring node; The queue update subunit is used to update the node distance of the adjacent node to the candidate distance if the candidate distance is less than the node distance of the adjacent node, and to add the target node as the predecessor node of the adjacent node to the preset queue.

[0108] Based on the above embodiments, the connected subgraph determines the sub-units, including: The node backtracking subunit is used to, for each node in the anchor point set, backtrack sequentially upwards along the predecessor nodes to the root node based on that node, and obtain the nodes traversed and the edges connecting the nodes. The connected subgraph generation subunit is used to merge all the obtained nodes and edges to generate the connected subgraph.

[0109] Based on the above embodiments, the preset iteration stopping rule is that the difference between the potential energy vectors output by two adjacent iterations is less than a preset threshold.

[0110] Based on the above embodiments, the node attributes of the nodes in the database schema diagram include at least table name, column name, and comments.

[0111] Based on the above embodiments, after calculating the similarity between the query embedding vector and the description vector of each node to obtain the second potential vector of each node, the method further includes: The summation result determination module is used to sum the second potential vectors of all nodes to obtain the summation result. The information output module is used to output a preset prompt message and terminate the execution of subsequent steps if the summation result is equal to zero.

[0112] The semantic topology-based e-commerce database schema linking device provided in this embodiment of the invention can execute the semantic topology-based e-commerce database schema linking method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0113] Figure 7 A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0114] like Figure 7 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0115] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0116] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as a semantic topology-based e-commerce database schema linking method.

[0117] In some embodiments, a semantic topology-based e-commerce database schema linking method can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the semantic topology-based e-commerce database schema linking method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute a semantic topology-based e-commerce database schema linking method by any other suitable means (e.g., by means of firmware).

[0118] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0119] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0120] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0121] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0122] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0123] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0124] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0125] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A semantic topology-based method for linking e-commerce database schemas, characterized in that, The method includes: Obtain the text to be queried; wherein, the text to be queried is used for pattern linking queries based on the database; The text to be queried and a pre-constructed database schema graph are input into a semantic embedding model for analysis and processing, so as to output a query embedding vector and a description vector corresponding to each node in the database schema graph; wherein, the nodes in the database schema graph represent database tables, and the edges represent the connection relationships between database tables. Based on the query embedding vector and the description vector of each node, determine the first potential vector of each node; calculate the resistance weight of each edge in the database pattern graph based on the first potential vector of each node; Based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential vector, a connected subgraph is determined; wherein the connected subgraph is composed of nodes associated with the text to be queried.

2. The method according to claim 1, characterized in that, The database schema diagram is constructed in the following manner: Obtain the database schema; wherein the database schema contains at least multiple database tables and the connection relationships between the multiple database tables; Based on the multiple database tables, multiple nodes of the database schema graph are determined; wherein the number of the multiple database tables is the same as the number of the multiple nodes; Based on the connection relationships between the multiple database tables, multiple edges of the database schema graph are determined; The database schema graph is constructed based on multiple nodes and multiple edges of the database schema graph.

3. The method according to claim 1, characterized in that, The step of determining the first potential vector of each node based on the query embedding vector and the description vector of each node includes: The similarity between the query embedding vector and the description vector of each node is calculated to obtain the second potential vector of each node; the second potential vector is then nonnegated and normalized to obtain the third potential vector of each node. Based on the database schema graph, a state transition matrix is ​​constructed; the state transition matrix is ​​used to represent the probability of energy flowing from a node to an adjacent node; Using the third potential energy vector as the initial vector, the system iteratively updates the vector based on the state transition matrix, the preset restart probability, and the preset iteration stopping rule until the preset iteration stopping rule is satisfied, and then outputs the first potential energy vector.

4. The method according to claim 3, characterized in that, The step of determining the connected subgraph based on the database schema graph, the resistance weight of each edge in the database schema graph, and the first potential energy vector includes: Based on the database schema diagram and the second potential vector of each node, an anchor point set is determined; wherein the second potential vector of the nodes in the anchor point set is greater than zero. Based on the database schema graph and the resistance weight of each edge in the database schema graph, a weighted graph is constructed; wherein the number of nodes in the weighted graph is the same as the number of nodes in the database schema graph, and the edge attributes in the weighted graph are the resistance weights of each edge in the database schema graph; Perform the single-source shortest path algorithm on the weighted graph and output a connected subgraph.

5. The method according to claim 4, characterized in that, The step of performing the single-source shortest path algorithm on the weighted graph and outputting a connected subgraph includes: Initialize the node distances of all nodes and the distances between the predecessor nodes and the root node of all nodes; wherein, the node distance is used to represent the shortest path information from the root node to the current node, the predecessor node is used to represent the previous node of the current node; the root node is the node with the largest first potential vector in the anchor point set; Define a preset queue and add the root node as a node to be processed to the preset queue; wherein, the preset queue is used to store the nodes to be processed in ascending order of node distance; the nodes to be processed are the nodes in the preset queue that need to participate in the preset queue update process; The node with the smallest distance from the preset queue is selected as the target node; wherein, the target node is the node to be processed that has not participated in the preset queue update process. For each neighboring node of the target node, a preset queue update process is executed to update the preset queue; The process is repeated until the preset queue is empty; for each node in the anchor point set, the current node is backtracked along the predecessor node to determine the connected subgraph.

6. The method according to claim 5, characterized in that, The step of performing a preset queue update process for each neighboring node of the target node to update the preset queue includes: For each neighboring node of the target node, the sum of the node distance to the target node and the target resistance weight is calculated to obtain the candidate distance; wherein, the target resistance weight is the resistance weight of the corresponding edge between the target node and the neighboring node; If the candidate distance is less than the node distance of the adjacent node, update the node distance of the adjacent node to the candidate distance, and set the target node as the predecessor node of the adjacent node, and add the adjacent node to the preset queue.

7. The method according to claim 5, characterized in that, The step of backtracking along the predecessor nodes to determine the connected subgraph for each node in the set of anchor points includes: For each node in the set of anchor points, based on that node, backtrack upwards along the predecessor nodes until the root node, and obtain the nodes traversed and the edges connecting the nodes. All the obtained nodes and edges are merged to generate the connected subgraph.

8. The method according to claim 3, characterized in that, The preset iteration stopping rule is that the difference between the potential energy vectors output by two adjacent iterations is less than a preset threshold.

9. The method according to claim 1, characterized in that, The node attributes of the nodes in the database schema diagram include at least the table name, column name, and comments.

10. The method according to claim 3, characterized in that, After calculating the similarity between the query embedding vector and the description vector of each node to obtain the second potential vector of each node, the method further includes: The second potential vectors of all nodes are summed to obtain the summation result. If the summation result is equal to zero, a preset prompt message will be output and the execution of subsequent steps will be terminated.