Data conversion method, apparatus, device, and medium
By calculating the functional dependencies and similarities between fields in a relational database, entity relation triples are automatically generated, solving the problem of low efficiency in the conversion of relational data to graph data in existing technologies, and realizing efficient and accurate data conversion and data mining in complex scenarios.
Patent Information
- Application Number
- CN202511235940.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-01
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2045-09-01
AI Technical Summary
In existing technologies, the conversion from relational data to graph data requires manual intervention, which leads to low efficiency and a high risk of errors, and makes it impossible to effectively uncover potential rules in the data.
By calculating the functional dependencies and field similarities between different fields in a relational database, entity relation triples are generated, and graph data is automatically constructed, reducing manual intervention.
It enables efficient and accurate conversion of relational data to graph data, improves data correlation analysis capabilities, and supports data mining tasks in complex scenarios.
Smart Images

Figure CN120723835B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application is suitable for the technical field of data processing, and particularly relates to a data conversion method, a data conversion device, a computer device and a computer readable storage medium. BACKGROUND
[0002] In the wave of digital transformation, enterprises are facing the challenge of massive data, especially in the processing of relational data. The traditional structured storage method gradually shows its limitations. The relational database is suitable for storing structured data in its standardized table form, but it is not efficient in processing complex relationships, fast queries and data mining. Graph data has strong relationship modeling and query capabilities, and can flexibly present complex connection relationship structures in the form of nodes and edges. Therefore, if the relational data in the relational database can be converted into graph data, not only the correlation analysis capability of the data can be improved, but also the potential rules between the data can be further mined. However, in the related technology, the conversion process of relational data to graph data needs to be completed manually by technical personnel, which is not only time-consuming and laborious, but also easy to cause inconsistency of the conversion results due to human factors. SUMMARY
[0003] The embodiments of the present application provide a data conversion method, a data conversion device, a computer device and a computer readable storage medium, which can improve the conversion efficiency and accuracy of relational data to graph data.
[0004] In a first aspect, the embodiments of the present application provide a data conversion method, comprising:
[0005] determining a relational database that needs to be converted, and obtaining a relationship table in the relational database;
[0006] For each relationship table, calculating the functional dependency between different fields in the relationship table;
[0007] For each functional dependency, calculating the field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies;
[0008] generating an entity relationship triple according to the functional dependency and the field similarity;
[0009] constructing graph data corresponding to the relational database according to the entity relationship triple.
[0010] In a second aspect, the embodiments of the present application provide a data conversion device, comprising:
[0011] a relationship table obtaining module, configured to determine a relational database that needs to be converted, and obtain a relationship table in the relational database;
[0012] a dependency calculating module configured to calculate, for each relation table, functional dependencies between different fields in the relation table;
[0013] a similarity calculating module configured to calculate, for each functional dependency, field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies;
[0014] a triple generating module configured to generate entity-relation triples according to the functional dependencies and the field similarity;
[0015] a graph data constructing module configured to construct graph data corresponding to the relational database according to the entity-relation triples.
[0016] Optionally, in an embodiment, the dependency calculating module is configured to calculate, for each relation table, candidate functional dependencies between different fields in the relation table; select, from all the candidate functional dependencies, target candidate functional dependencies whose field definition order of the left-hand side field and the right-hand side field satisfies a preset definition order; perform functional dependency detection on the target candidate functional dependencies, and obtain the functional dependencies according to the target candidate functional dependencies that pass the detection.
[0017] Optionally, in an embodiment, the dependency calculating module is further configured to store, when calculating the candidate functional dependencies between different fields in the relation table, intermediate data in a cache space, and in response to the intermediate data being evicted, store the intermediate data to a persistent storage space and store index information of the intermediate data in the cache space.
[0018] Optionally, in an embodiment, the similarity calculating module is configured to calculate field name similarity and field data similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies; and fuse the field name similarity and the field data similarity to obtain the field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies.
[0019] Optionally, in an embodiment, the triple generation module is configured to: if there are two functional dependencies and the similarity of a left-hand side field of one functional dependency and a field of a right-hand side field of another functional dependency reaches a similarity threshold, generating two entities according to the two functional dependencies and a relationship between the two entities according to the right-hand side field to obtain an entity-relationship triple; and / or if the similarity of a left-hand side field of one functional dependency and two right-hand side fields of another functional dependency both reaches a similarity threshold, generating two entities according to the one functional dependency and a relationship between the two entities according to the two right-hand side fields to obtain an entity-relationship triple; and / or if the similarity of left-hand side fields of two functional dependencies and different right-hand side fields of the same functional dependency reaches a similarity threshold, generating two entities according to the two functional dependencies and a relationship between the two entities according to the different right-hand side fields to obtain an entity-relationship triple.
[0020] Optionally, in an embodiment, the graph data construction module is configured to: construct a complete graph by regarding each entity-relationship triple as a node; determine mutually exclusive entity-relationship triples and delete edges corresponding to the mutually exclusive entity-relationship triples in the complete graph to obtain an incomplete graph; determine maximal cliques in the incomplete graph and score the quality of each maximal clique to obtain a quality score of each maximal clique; and construct graph data corresponding to the relational database according to entity-relationship triples corresponding to the maximal clique with the highest quality score.
[0021] Optionally, in an embodiment, the graph data construction module is configured to: if two entity-relationship triples have the same entities and their relationships are generated according to different right-hand side fields in the same functional dependency, determine that the two entity-relationship triples are mutually exclusive; and / or if a left-hand side field corresponding to an entity of an entity-relationship triple belongs to a right-hand side field of another functional dependency, determine that the entity-relationship triple and an entity-relationship triple generated according to a left-hand side field of the another functional dependency are mutually exclusive.
[0022] Optionally, in an embodiment, the graph data construction module is configured to: score the quality of each maximal clique according to the following formula:
[0023] ;
[0024] wherein, represents the sum of the number of attributes of different categories of entities in the maximal clique, represents the number of categories of entity relationships in the maximal clique.
[0025] Optionally, in an embodiment, the graph data construction module is further configured to provide a data configuration interface and display the graph data in the data configuration interface, receive an adjustment operation for the graph data, and adjust the graph structure of the graph data according to the adjustment operation.
[0026] In a third aspect, a computer device is provided, which includes a processor and a memory. The memory stores a computer program capable of running on the processor. The processor runs the computer program to implement the data conversion method provided in the embodiments of the present application.
[0027] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program. The computer program is executed by a processor to implement the data conversion method provided in the embodiments of the present application.
[0028] The data conversion scheme provided in the present application determines a relational database that needs to be converted, and obtains a relation table in the relational database. For each relation table, the function dependency between different fields in the relation table is calculated. For each function dependency, the field similarity between the left-hand side field corresponding to the function dependency and the right-hand side field corresponding to other function dependencies is calculated. According to the function dependency and the field similarity, an entity relation triple is generated. According to the entity relation triple, graph data corresponding to the relational database is constructed. In this way, the goal of automatically extracting entities and their associated relations from relational data is achieved without relying on manual definition of rules or manual modeling, so that the structured relational data can be efficiently and accurately converted into graph data with rich semantics, thereby laying a foundation for subsequent intelligent analysis and mining tasks based on graph data. BRIEF DESCRIPTION OF DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0030] Figure 1 is an application environment schematic diagram of the data conversion method provided in the embodiments of the present application;
[0031] Figure 2 is a flowchart of the data conversion method provided in the embodiments of the present application;
[0032] Figure 3 is a structural schematic diagram of the data conversion device provided in the embodiments of the present application;
[0033] Figure 4This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0034] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0035] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0036] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0037] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0038] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0039] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0040] It should be understood that the size of the serial number of each step in the following embodiments does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0041] In order to illustrate the technical solutions of the present application, the following will be described by specific embodiments.
[0042] Please refer to Figure 1 , the present application also provides a data conversion system, which comprises a computer device 100 for executing the data conversion method provided by the present application. The computer device 100 can be a desktop computer, a notebook computer, and a server, etc. Any device configured with a processor and having processing capability. For example, the computer device 100 can determine the relational database that needs to be converted, and obtain the relational table in the relational database; for each relational table, calculate the functional dependence between different fields in the relational table; for each functional dependence, calculate the field similarity between the left-hand side field corresponding to the functional dependence and the right-hand side field corresponding to other functional dependences; generate entity relationship triple according to the functional dependence and the field similarity; and construct graph data corresponding to the relational database according to the entity relationship triple.
[0043] In addition, as Figure 1 shown, the data conversion system can also include a memory 200 for storing relevant data in the data conversion process, such as the obtained relational table, the calculated functional dependence, the field similarity, the generated entity relationship triple, and the constructed graph data, etc.
[0044] It should be noted that the above-described data conversion system is only an example, which is used to more clearly illustrate the technical solutions of the embodiments of the present application, and does not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of the data conversion system and the appearance of new business scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0045] The technical solutions of the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the following described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0046] Please refer to Figure 2 , Figure 2 is a flowchart of a data conversion method provided by the embodiments of the present application, as Figure 2 shown, the flow of the data conversion method can be as follows:
[0047] In S110, a relational database requiring data conversion is determined, and a relational table in the relational database is obtained.
[0048] A relational database is a database that stores data in the form of tables, and there is a clear relationship between the data. The relational database organizes and stores data in the form of two-dimensional relational tables, each of which is composed of rows and columns, where each row represents a record and each column represents a field with a fixed data type (such as integer, string). The relational tables are associated through primary keys and foreign keys. The primary key is used to uniquely identify each row of data in the table, while the foreign key is used to establish a connection between different tables, forming an association relationship. For example, the user ID field of the user table can be used as a foreign key of the order table, thereby associating the user table with the order table to realize cross-table data query and analysis.
[0049] Graph data represents data and its associated relationships in the form of nodes, edges, and attributes. Nodes represent entities, and edges represent relationships between entities, such as "user-purchase-goods", where the user and the goods are nodes, and purchase is an edge. Attributes are additional information for nodes or edges, such as user age, product price, and purchase time.
[0050] The data conversion method provided in the present application converts relational tables in a relational database into graph data, thereby more intuitively presenting the complex associations between data and improving the efficiency and accuracy of data mining. For example, in the fields of medical health, social network analysis, recommendation system construction, and anti-fraud detection, the structural characteristics of graph data make it have stronger expression ability and computational advantage. For example, in a medical information system, entity data such as patients, doctors, examinations, and prescriptions are widely distributed in multiple business tables, and there is a lack of unified structural expression method, making it difficult to support complex cross-entity analysis tasks. Using the data conversion method provided in the present application, multi-dimensional medical relationship graphs such as medical visit graphs and examination graphs can be automatically generated to support various downstream tasks such as clinical path analysis, diagnosis and treatment behavior modeling, and disease complication graph construction.
[0051] It should be noted that in the following embodiments, the computer device is taken as the execution subject to describe the data conversion method provided in the present application in detail.
[0052] In the embodiments of the present application, the computer device can receive an input data conversion request, which contains identification information of the relational database requiring conversion. After receiving the data conversion request, the computer device first determines the relational database requiring data conversion according to the identification information carried by the data conversion request, connects the relational database indicated by the identification information, and then obtains the relational table therein for subsequent data conversion.
[0053] In S120, for each relation table, function dependencies between different fields in the relation table are calculated.
[0054] A function dependency refers to that the values of a group of fields can uniquely determine the values of another group of fields in a relation table. Such a dependency relationship reflects the inherent association between data, and is in the form of X→Y, where X is referred to as left-hand side field (LHS) and is a determinant, and Y is referred to as right-hand side field and is a dependent factor. By identifying function dependencies in each relation table, semantic association rules between data can be effectively extracted, thereby providing a basis for subsequent construction of nodes and edges of graph data. For example, in a user order table, an order ID can uniquely determine the values of user ID, product ID and other fields, and thus there is a function dependency {order ID}→{user ID, product ID}.
[0055] In the embodiments of the present application, for each obtained relation table, function dependencies between internal fields are first calculated. The method for calculating the function dependencies is not limited here, and existing function dependency discovery algorithms can be used, such as a calculation method based on attribute closure or deduction using constraint information in a database.
[0056] In addition, it should be noted that in actual application, there can be isomorphic tables in a relational database, which have the same table mode or are highly similar. The isomorphic tables are generally derived from horizontal table splitting in database optimization technology. For example, in an e-commerce database, a database administrator can store orders according to order creation time or delivery address. In this case, the isomorphic tables have the same field structure and semantic meaning, and thus the computer device can combine the isomorphic tables into one relation table and then calculate the function dependencies, so as to improve the data processing efficiency and avoid repeated analysis.
[0057] In S130, for each function dependency, field similarity between the left-hand side field corresponding to the function dependency and the right-hand side field corresponding to other function dependencies is calculated.
[0058] In the embodiments of the present application, for each calculated function dependency, field similarity between the left-hand side field and the right-hand side field of other function dependencies is calculated. The field similarity is used to measure the semantic correlation between two fields. For example, if the left-hand side field of a certain function dependency is a user ID and the right-hand side field of another function dependency is also a user ID, the two fields are completely consistent in field name and semantics, and the similarity is the highest value. If the field names are different but the semantics are similar, such as customer number and user ID, the semantic analysis technology can be used to determine the correlation and give a corresponding similarity score. By calculating the field similarity, the potential association between different function dependencies can be identified, thereby providing support for further data integration and graph structure construction.
[0059] It should be noted that the specific calculation method of the field similarity in the embodiments of the present application is not limited, including but not limited to cosine similarity calculation based on word vector, edit distance analysis of field name, and knowledge graph reasoning combined with semantic ontology, etc.
[0060] In S140, according to the functional dependency and the field similarity, an entity relationship triple is generated;
[0061] The form of the entity relationship triple is (entity 1, relationship, entity 2), wherein entity 1 and entity 2 can correspond to the left-hand side fields of different functional dependencies, or can correspond to the left-hand side fields of the same functional dependency, and the relationship is determined by the field similarity between the fields.
[0062] In S150, according to the entity relationship triple, a graph data corresponding to the relational database is constructed.
[0063] In the embodiments of the present application, after the entity relationship triple is generated, the computer device determines the association rules and dependency relationships between the entities according to the information of the entity relationship triple, so as to construct the graph data corresponding to the relational database based on the association rules and dependency relationships between the entities, and convert the relational data originally stored in the relational database into nodes and relationships in the graph data.
[0064] Among them, the computer device takes each entity as a node in the graph database, and the attribute information of the node is derived from the right-hand side field of the functional dependency corresponding to the node; through the relationship path described in the entity relationship triple, the associated nodes are connected in the form of edges, and the attributes of the edges are empty or consistent with the attributes of the relationship path. For example, the "user node" and the "order node" are connected through the relationship path "user-user ID-order", which indicates that there is an association of "ordering" behavior between the user and the order. This conversion not only preserves the complete semantics of the original relational data, but also uses the association query capability of the graph data to more efficiently support data analysis and mining tasks in complex scenarios.
[0065] Optionally, in an embodiment, for each relationship table, the functional dependencies between different fields in the relationship table are calculated, including:
[0066] For each relationship table, the candidate functional dependencies between different fields in the relationship table are calculated;
[0067] From all the candidate functional dependencies, the target candidate functional dependencies whose field definition order of the left-hand side field and the right-hand side field satisfies the preset definition order are screened out;
[0068] The target candidate functional dependencies are subjected to functional dependency detection, and the functional dependencies are obtained according to the target candidate functional dependencies that pass the detection.
[0069] In the embodiments of the present application, when calculating the functional dependencies between different fields in the relation table, the computer device can use existing functional dependency discovery algorithms such as GAP, FD Mine or Tane, to automatically mine the functional dependencies between fields, and calculate the candidate functional dependencies between different fields in the relation table.
[0070] Then, the computer device screens and verifies the calculated candidate functional dependencies to ensure that the selected functional dependencies conform to the actual business logic and data semantics. Specifically, the computer device first screens the candidate functional dependencies that meet the preset definition order according to the definition order of the fields.
[0071] For example, in actual business, the definition order of the fields usually implies the order of the business meaning. For example, the user ID (user_id) is the unique identifier of the user, and is usually defined first (small order) in the table; the registration time (reg_time) is generated based on the user ID, and the definition order is second (medium order); the order ID (order_id) is generated by user behavior, and the definition order is later (large order); and the order amount (amount) is finally determined by the order ID (maximum order). Therefore, the preset definition order can be set as: the definition order of the left-hand side field of the candidate functional dependency should be earlier than that of the right-hand side field, which is represented as order(X)<order(Y). Through this definition order constraint, functional dependencies that do not conform to the business logic can be effectively filtered out, for example, to avoid the occurrence of "order amount" determining "user ID", which is impossible in actual business.
[0072] After screening the candidate functional dependencies that meet the definition order, the computer device further performs functional dependency detection on the target candidate functional dependencies screened out, that is, detects whether the left-hand side field of the target candidate functional dependency can uniquely determine the value of the right-hand side field. If a certain target candidate functional dependency passes the detection, the computer device retains it as a valid functional dependency, otherwise it is rejected.
[0073] The above combines the field definition order constraint and functional dependency detection to effectively improve the accuracy of functional dependency discovery, reduce redundant calculation and the generation of invalid functional dependencies, and avoid unnecessary computational overhead.
[0074] Optionally, in an embodiment, when calculating the candidate functional dependencies between different fields in the relation table, the intermediate data in the calculation process is stored in the cache space, and the data conversion method further includes:
[0075] In response to the intermediate data being evicted, the intermediate data is stored in the persistent storage space, and the index information of the intermediate data is stored in the cache space.
[0076] For a relation table, when the computer device calculates the candidate functional dependencies between different fields in the relation table, the computer device temporarily stores the intermediate data in the calculation process in the cache space to improve the calculation efficiency. When the cache space is insufficient, the computer device discards part of the intermediate data from the cache according to a preset eviction policy, such as a least recently used (LRU) algorithm, and stores the discarded intermediate data to a persistent storage space. At the same time, the index information of the part of the intermediate data is retained in the cache space, so as to quickly locate and call in the subsequent calculation process.
[0077] By setting the combination of the cache and the persistent storage, the above can effectively reduce the memory occupation pressure in the high-frequency calculation scenario, while ensuring the traceability and fast access ability of the key intermediate data, and providing a more stable and efficient calculation environment support for large-scale functional dependency calculation.
[0078] Optionally, in an embodiment, the field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies is calculated, including:
[0079] The field name similarity and the field data similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies are calculated.
[0080] The field name similarity and the field data similarity are fused to obtain the field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies.
[0081] In the embodiment of the application, when the computer device calculates the field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies, the computer device first calculates the field name similarity and the field data similarity. The field name similarity can be determined by comparing the semantic similarity and the string similarity of the field name, and the field data similarity is calculated by analyzing the data content stored in the field, such as by sampling data, combining the bloom filter to calculate the intersection size, or using the statistical characteristics of the data distribution to measure the similarity. After obtaining the field name similarity and the field data similarity, the computer device further fuses the field name similarity and the field data similarity to obtain the field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to other functional dependencies. The fusion manner between the two similarities is not limited here, including but not limited to weighted fusion, averaging, taking the larger value, taking the smaller value, and the like.
[0082] For example, the computer device can realize the fusion of the field name similarity and the field data similarity in a weighted fusion manner, which is represented as:
[0083] The field similarity is equal to a*field data similarity + (1-a)*field name similarity, wherein a is a preset weight parameter, and a value range of a is [0, 1], and a is used for adjusting an influence degree of the field name similarity and the field data similarity in the overall similarity calculation. Through the weighted fusion mode, the value of a can be flexibly adjusted according to the requirement of an actual application scene, so that a more accurate field similarity evaluation effect is achieved. For example, in a scene in which the field name semantic information is more important, the value of a can be appropriately reduced, so that the influence weight of the field name similarity on the final similarity result is enhanced; conversely, in a case in which the field data content is more critical, the value of a can be increased, so that the role of the field data similarity is highlighted.
[0084] The above can more comprehensively and accurately measure the semantic correlation degree between fields by comprehensively considering the field name similarity and the field data similarity, and provide more accurate data support for mining of the entity relationship triple.
[0085] Optionally, in an embodiment, generating the entity relationship triple according to the functional dependency and the field similarity comprises:
[0086] If there are two functional dependencies, and the field similarity between the left-hand side field of one functional dependency and the right-hand side field of another functional dependency reaches a similarity threshold, then two entities are generated according to the two functional dependencies, and a relationship between the two entities is generated according to the right-hand side field, so as to obtain the entity relationship triple; and / or
[0087] If the similarity between the left-hand side field of one functional dependency and two right-hand side fields of another functional dependency both reaches the similarity threshold, then two entities are generated according to the functional dependency, and a relationship between the two entities is generated according to the two right-hand side fields, so as to obtain the entity relationship triple;
[0088] If the field similarity between the left-hand side fields of two functional dependencies and different right-hand side fields of the same functional dependency reaches the similarity threshold, then two entities are generated according to the two functional dependencies, and a relationship between the two entities is generated according to the different right-hand side fields, so as to obtain the entity relationship triple.
[0089] In the embodiment of the application, by setting the similarity threshold, a field combination with a higher semantic correlation can be effectively screened, so that the accuracy and relevance of generating the entity relationship triple are improved. The setting of the similarity threshold can be flexibly adjusted according to a specific application scene, for example, in a scene requiring high precision, a higher threshold can be set to ensure that the semantics of the matched fields are highly consistent; and in a scene pursuing high coverage, the threshold can be appropriately reduced to include more potential associated field combinations. Through the mechanism, efficient and accurate mining of the entity relationship triple can be realized under different application requirements.
[0090] For example, two functional dependencies {A}→{B, C, D} and {L}→{M, N, P, Q} from different relationship tables, if the field similarity between the left-hand side field A of the first functional dependency and the right-hand side field M of the second functional dependency reaches the similarity threshold, an entity relationship triple can be generated as ({A}→{B, C, D}, A-M-L: {}, {L}→{M, N, P, Q}).
[0091] Among them, the first element in the entity relationship triple: {A}→{B, C, D}, represents entity 1 determined by the left-hand side field {A} of the first functional dependency, and the attributes of entity 1 are the right-hand side fields {B, C, D} of the first functional dependency, i.e. the specific characteristics of this entity 1 (such as the name, age, registration time of the user, etc.).
[0092] The third element in the entity relationship triple: {L}→{M, N, P, Q}, represents entity 2 determined by the left-hand side field {L} of the second functional dependency, and the attributes of entity 2 are the right-hand side fields {M, N, P, Q} of the second functional dependency, i.e. the specific characteristics of this entity 2 (such as the order number, product ID, status of the order, etc.).
[0093] The second element of the entity relationship triple: A-M-L: {}, represents the relationship path between entity 1 and entity 2. Among them, A and M are highly similar, indicating that M is a foreign key candidate of A, and A and L are associated through M (for example, the M column of the order table is the user ID, pointing to the A column of the user table), : after the colon is empty, indicating that the specific attributes of the current relationship are empty.
[0094] Further, taking the financial risk control scene as an example:
[0095] The relationship table 1 (user table) has a functional dependency: {user_id}→{name, age, reg_time} (i.e. A=user_id, B=name, C=age, D=reg_time), corresponding to entity 1 "user node", and the attributes are name, age, and registration time.
[0096] The relationship table 2 (order table) has a functional dependency: {order_id}→{user_id, product_id, amount, status} (i.e. L=order_id, M=user_id, N=product_id, P=amount, Q=status), corresponding to entity 2 "order node", and the attributes are user ID, product ID, amount, and status.
[0097] The calculation finds that the field similarity of A (user_id) and M (user_id) reaches a similarity threshold, and the generated entity relationship triple is: (user entity (user_id->name, age, reg_time), user-user ID-order: {}, order entity (order_id->user_id, product_id, amount, status), which means: the user entity and the order entity are associated through the "user ID" field to form the "user-ordering-order" relationship.
[0098] For example, two functional dependencies {A}→{B} and {L}→{M, N, P} from different relationship tables, the field similarity of the left-hand side field A of the first functional dependency and the right-hand side fields M and N of the second functional dependency all reach the similarity threshold, then a triple can be generated as ({A}→{B}, {A}-{M}-{N}-A:{L}→{M, N, P}, {A}→{B}).
[0099] Among them, the first element of the entity relationship triple: {A}→{B}, represents entity 1 determined by the left-hand side field {A} of the first functional dependency, and the attribute of entity 1 is the right-hand side field {B} of the first functional dependency, that is, the specific characteristics of this entity 1 (such as the name of the user).
[0100] The third element of the entity relationship triple: {A}→{B}, represents entity 2 determined by the left-hand side field {A} of the first functional dependency, and the attribute of entity 2 is the right-hand side field {B,} of the first functional dependency, that is, the specific characteristics of this entity 2 (such as the name of the user).
[0101] The second element of the entity relationship triple: {A}-{M}-{N}-A:{L}→{M, N, P}, represents the relationship path between entity 1 and entity 2: A is associated with itself through M and N, forming a "A-M-N-A" circular relationship structure, and {L}→{M, N, P} represents the attribute of the current relationship.
[0102] Further, taking the friend relationship in a social network as an example:
[0103] The relationship table 1 (user table) has a functional dependency: {user_id}→{name} (A=user_id, B=name);
[0104] The relation table 2 (social relation table) has a functional dependency: {relation_id}→{user_id1, user_id2, relation_type} (L=relation_id, M=user_id1, N=user_id2, P=relation_type).
[0105] The calculation finds that the field similarity of A (user_id) and M (user_id1) and N (user_id2) all reach the similarity threshold, and the generated entity relation triple is: user entity (user_id→name), user-user ID1-user ID2-user: social relation table (relation_id→user_id1, user_id2, relation_type), user entity (user_id→name), indicating that the user establishes a "friend" or "association" relationship with itself through the social relation table.
[0106] For example, three functional dependencies from different relation tables, {A}→{B}, {L}→{M}, and {U}→{V, W, X}, the field similarity of the left-hand side field A of the first functional dependency and the right-hand side field V of the third functional dependency reaches the similarity threshold, and the field similarity of the left-hand side field L of the second functional dependency and the right-hand side field W of the third functional dependency also reaches the similarity threshold, then an entity relation triple can be generated as ({A}→{B}, A-V-W-L:{V, W, X}, {L}→{M}).
[0107] Among them, the first element of the entity relation triple: {A}→{B}, represents entity 1 determined by the left-hand side field {A} of the first functional dependency, and the attribute of entity 1 is the right-hand side field {B} of the first functional dependency, that is, the specific characteristics of this entity 1 (such as the name of the user, etc.).
[0108] The third element of the entity relation triple: {L}→{M}, represents entity 2 determined by the left-hand side field {L} of the second functional dependency, and the attribute of entity 2 is the right-hand side field {M} of the second functional dependency, that is, the specific characteristics of this entity 2 (such as the order number of the order, etc.).
[0109] The second element of the entity relation triple: A-V-W-L:{V, W, X}, represents the relationship path between entity 1 and entity 2. Among them, A is highly similar to M, indicating that M is a foreign key candidate of A, and A is associated with L through M (for example, the M column of the order table is the user ID, pointing to the A column of the user table), and {V, W, X} represents the specific attributes of the current relationship as V, W, and X.
[0110] Further, taking the financial risk control scene as an example:
[0111] The relationship table 1 (user table) has a functional dependency: {user_id}→{name} (A=user_id, B=name);
[0112] The relationship table 2 (product table) has a functional dependency: {product_id}→{product_name} (L=product_id, M=product_name);
[0113] The relationship table 3 (transaction table) has a functional dependency: {trade_id}→{user_id_trade, product_id_trade, trade_time} (U=trade_id, V=user_id_trade, W=product_id_trade, X=trade_time).
[0114] It is found that the field similarity between A (user_id) and V (user_id_trade) reaches the similarity threshold, and the field similarity between L (product_id) and W (product_id_trade) also reaches the similarity threshold, and thus an entity relationship triple is generated as (user entity (user_id→name), user-transaction user ID-transaction product ID-product: transaction table (trade_id→user_id_trade, product_id_trade, trade_time), product entity (product_id→product_name)), which indicates that the user and the product establish a "purchase" relationship through the transaction table.
[0115] For example, three functional dependencies from the same relationship table are {A}→{B-N}, {B}→{C-E}, and {F}→{G-K}, the field similarity between the left-hand side field B of the second functional dependency and the right-hand side field B of the first functional dependency reaches the similarity threshold, and the field similarity between the left-hand side field F of the third functional dependency and the right-hand side field F of the first functional dependency also reaches the similarity threshold, and thus an entity relationship triple can be generated as ({B}→{C-E}, B-F: {A}→{B-N}, {F}→{G-K}). For details, refer to the description of the above related examples, which will not be repeated here.
[0116] Optionally, in an embodiment, according to the entity relationship triple, a graph data corresponding to the relational database is constructed, including:
[0117] A complete graph is constructed by taking each entity relationship triple as a node;
[0118] determine mutually exclusive entity relationship triples, and delete edges in the complete graph corresponding to the mutually exclusive entity relationship triples, to obtain a non-complete graph;
[0119] determine maximal cliques in the non-complete graph, and score each maximal clique to obtain a quality score of each maximal clique;
[0120] construct graph data corresponding to the relational database according to entity relationship triples corresponding to the maximal clique with the highest quality score.
[0121] In the embodiment of the application, when the computer device constructs graph data corresponding to the relational database according to entity relationship triples, each entity relationship triple is regarded as a node to construct a complete graph, mutually exclusive entity relationship triples are then determined, and edges in the complete graph corresponding to the mutually exclusive entity relationship triples are deleted to obtain a non-complete graph. Maximal cliques are then determined based on the non-complete graph (one maximal clique corresponds to one candidate solution of the graph data). In this way, the problem of generating all candidate solutions is converted into the problem of finding maximal cliques from the non-complete graph (for example, the Bron-Kerbosch algorithm can be used to solve the problem). Through the screening of maximal cliques, redundant or conflicting entity relationship combinations can be effectively excluded, thereby retaining a candidate solution that is logically consistent and structurally complete. On this basis, each maximal clique is scored, and the entity relationship triples corresponding to the maximal clique with the highest quality score are finally selected as the optimal graph data construction solution, thereby realizing efficient conversion of the relational database structure and graph data modeling.
[0122] It should be noted that two entity relationship triples are mutually exclusive if they cannot appear in the same graph data construction solution at the same time. Determining mutually exclusive entity relationship triples includes:
[0123] if the entities of two entity relationship triples are the same and the relationships are generated according to different right-hand side fields in the same functional dependency, it is determined that the two entity relationship triples are mutually exclusive; and / or,
[0124] if the left-hand side field corresponding to the entity of an entity relationship triple belongs to the right-hand side field of another functional dependency, it is determined that the entity relationship triple is mutually exclusive with the entity relationship triple generated according to the left-hand side field of the other functional dependency.
[0125] In the embodiment of the application, there are two types of mutually exclusive relationships. The first type of mutually exclusive relationship is that the field similarity between the left-hand side field of one functional dependency and multiple different left-hand side fields of another functional dependency reaches a similarity threshold, resulting in the inability of coexistence of entity relationship triples constructed based on the field similarity, which come from different relationship tables.
[0126] For example, assume there are two functional dependencies: {A}→{B, C, D, E} (from relation table 1) and {L}→{M, N, P, Q} (from relation table 2), and the left-hand side field A is similar to the fields M and N on the right-hand side, and the similarity reaches a similarity threshold, at this time, the entity relationship triple constructed based on A-M-L (such as "user-user ID-order") and the entity relationship triple constructed based on A-N-L (such as "user-user ID2-order") have a mutual exclusion relationship.
[0127] The second type of mutual exclusion relationship: the right-hand side field of one functional dependency contains the left-hand side field of another functional dependency, resulting in the entity relationship triples corresponding to the two functional dependencies being unable to coexist.
[0128] For example, assume there are two functional dependencies in the same relation table: {A}→{B, C, D, E} and {B}→{C, F, G}, the left-hand side field B of the second functional dependency is contained in the right-hand side field of the first functional dependency, at this time, the entity relationship triple generated based on the first functional dependency as an entity and the entity relationship triple generated based on the second functional dependency as an entity are mutually exclusive.
[0129] Optionally, in an embodiment, the quality score of each maximal clique is calculated according to the following formula:
[0130] ;
[0131] wherein, indicates the sum of the number of attributes of different categories of entities in the maximal clique, indicates the number of categories of entity relationships in the maximal clique.
[0132] It should be noted that a maximal clique corresponds to a candidate solution of the graph data. The more entity attributes, the more detailed the description of the entity (such as a user portrait containing name, age, address, consumption preferences, etc.), and the higher the information value of the graph data. This dimension ensures that the solution covers the core features of the entity and avoids information loss. The more relationships, the more complex the graph structure, and the more it can reflect the implicit association between entities (such as multi-hop connections of fraud gangs, potential associations between diseases and drugs), supporting more advanced graph mining tasks (such as path detection, community discovery). Therefore, the embodiments of the present application combine the two key dimensions of entity attributes and relationship quantity to ensure that the selected solution balances the following aspects:
[0133] Information comprehensiveness: more entity attributes, indicating that more business details are covered (such as basic information and behavior data of users);
[0134] Structural complexity: more relationships, indicating that the graph model can reflect more complex business logic (such as multi-dimensional association between user behavior and goods, devices);
[0135] Practicality: A high-scored solution contains sufficient entity attributes (supporting accurate characterization) and rich relationships (supporting in-depth analysis), and is more in line with actual business needs (such as financial risk control requiring complex relationship mining, and medical health requiring comprehensive patient attributes).
[0136] For example, assume that there are two maximal groups, maximal group 1 includes two types of entities (users and orders), each entity contains 3 attributes, and there are 4 relationships; maximal group 2 includes three types of entities (users, orders, and goods), each entity contains 2 attributes, and there are 5 relationships. According to the scoring formula, maximal group 1 scores 3x2+4=10, and maximal group 2 scores 2x3+5=11. Although the entity attributes of maximal group 1 are more abundant, maximal group 2 has advantages in structural complexity and practicality, and ultimately scores higher. This shows that in the selection of graph data solutions, the balance between entities and relationships is crucial: more attributes ensure complete information, more relationships improve analysis depth, and the combination of the two can better serve diverse business scenarios, such as capturing complex fraud chains in financial risk control, mining potential associations in intelligent recommendation, etc.
[0137] Optionally, in an embodiment, after constructing the graph data corresponding to the relational database according to the entity relationship triplets, the method further includes:
[0138] providing a data configuration interface and displaying the graph data in the data configuration interface;
[0139] receiving an adjustment operation for the graph data, and adjusting the graph structure of the graph data according to the adjustment operation.
[0140] In the embodiments of the present application, after generating the graph data, the computer device provides a visual data configuration interface, allowing users to intuitively view the structure and content of the current graph data. At the same time, the data configuration interface provides dynamic adjustment capabilities for the graph structure, such as adding or deleting entities, attributes, or relationships, etc., thereby flexibly adapting to changes in business needs.
[0141] From the above, the data conversion scheme provided in the application determines a relational database that needs to be converted, and obtains a relational table in the relational database. For each relational table, the function dependencies between different fields in the relational table are calculated. For each function dependency, the field similarity between the left-hand side field corresponding to the function dependency and the right-hand side field corresponding to other function dependencies is calculated. According to the function dependencies and the field similarity, entity relationship triplets are generated. According to the entity relationship triplets, graph data corresponding to the relational database is constructed. In this way, the goal of automatically extracting entities and their associated relationships from relational data is achieved, without relying on manually defined rules or manual modeling, so that the structured relational data can be efficiently and accurately converted into graph data with rich semantics, laying a foundation for subsequent intelligent analysis and mining tasks based on graph data.
[0142] To better implement the above-described data conversion method, an embodiment of the application further provides a corresponding data conversion device. The meanings of the terms are the same as in the above-described data conversion method, and specific implementation details are referred to the description in the method embodiment above.
[0143] Please refer to Figure 3 , Figure 3 The structural diagram of the data conversion device provided in the embodiment of the application can include a relational table obtaining module 210, a dependency calculation module 220, a similarity calculation module 230, a triplet generation module 240, and a graph data construction module 250, wherein,
[0144] The relational table obtaining module 210 is configured to determine a relational database that needs to be converted, and obtain a relational table in the relational database.
[0145] The dependency calculation module 220 is configured to calculate, for each relational table, function dependencies between different fields in the relational table.
[0146] The similarity calculation module 230 is configured to calculate, for each function dependency, field similarity between a left-hand side field corresponding to the function dependency and a right-hand side field corresponding to other function dependencies.
[0147] The triplet generation module 240 is configured to generate entity relationship triplets according to the function dependencies and the field similarity.
[0148] The graph data construction module 250 is configured to construct graph data corresponding to the relational database according to the entity relationship triplets.
[0149] Optionally, in an embodiment, the dependency calculating module 220 is configured to calculate candidate functional dependencies between different fields in each relation table; filter target candidate functional dependencies from all the candidate functional dependencies, wherein the target candidate functional dependencies satisfy a preset definition order of field definitions of left-hand side fields and right-hand side fields; and perform functional dependency detection on the target candidate functional dependencies to obtain functional dependencies according to the target candidate functional dependencies that pass the detection.
[0150] Optionally, in an embodiment, the dependency calculating module 220 is further configured to store intermediate data in a cache space during the calculation of the candidate functional dependencies between different fields in the relation table, and store the intermediate data to a persistent storage space and store index information of the intermediate data in the cache space in response to the intermediate data being evicted.
[0151] Optionally, in an embodiment, the similarity calculating module 230 is configured to calculate field name similarity and field data similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to another functional dependency; and fuse the field name similarity and the field data similarity to obtain field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side field corresponding to another functional dependency.
[0152] Optionally, in an embodiment, the triple generating module 240 is configured to, if there are two functional dependencies and the field similarity between the left-hand side field of one of the two functional dependencies and the right-hand side field of the other functional dependency reaches a similarity threshold, generate two entities according to the two functional dependencies and generate a relationship between the two entities according to the right-hand side field to obtain an entity-relationship triple; and / or, if the similarity between the left-hand side field of one functional dependency and two right-hand side fields of another functional dependency both reaches a similarity threshold, generate two entities according to the one functional dependency and generate a relationship between the two entities according to the two right-hand side fields to obtain an entity-relationship triple; and / or, if the field similarity between the left-hand side fields of two functional dependencies and different right-hand side fields of the same functional dependency reaches a similarity threshold, generate two entities according to the two functional dependencies and generate a relationship between the two entities according to the different right-hand side fields to obtain an entity-relationship triple.
[0153] Optionally, in an embodiment, the graph data constructing module 250 is configured to construct a complete graph by regarding each entity-relationship triple as a node; determine mutually exclusive entity-relationship triples and delete edges corresponding to the mutually exclusive entity-relationship triples in the complete graph to obtain an incomplete graph; determine maximal cliques in the incomplete graph and score each maximal clique to obtain a quality score of each maximal clique; and construct graph data corresponding to the relational database according to entity-relationship triples corresponding to a maximal clique with the highest quality score.
[0154] Optionally, in an embodiment, the graph data construction module 250 is configured to determine that two entity relationship triples are mutually exclusive if the entities of the two entity relationship triples are the same and the relationships of the two entity relationship triples are generated according to different right-hand side fields in a same functional dependency; and / or determine that an entity relationship triple is mutually exclusive with an entity relationship triple generated according to a left-hand side field of another functional dependency if the entity of the entity relationship triple corresponds to a right-hand side field of the another functional dependency.
[0155] Optionally, in an embodiment, the graph data construction module 250 is configured to perform quality scoring on each maximal clique according to the following formula:
[0156] ;
[0157] wherein, denotes summing the number of attributes of entities of different categories in the maximal clique, denotes the number of categories of entity relationships in the maximal clique.
[0158] Optionally, in an embodiment, the graph data construction module 250 is further configured to provide a data configuration interface and display the graph data in the data configuration interface, receive an adjustment operation for the graph data, and adjust the graph structure of the graph data according to the adjustment operation.
[0159] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of the present application, and the specific functions and technical effects brought by the same can be referred to the method embodiments part, which will not be repeated here.
[0160] Figure 4 A structural schematic diagram of a computer device provided by an embodiment of the present application is shown in FIG. 1. As shown in FIG. 1, the computer device includes at least one processor (only one processor is shown in the figure), a memory, and a computer program stored in the memory and executable on the at least one processor, and the processor implements the steps in the above data conversion method embodiments when executing the computer program. Figure 4 Figure 4 The computer device can include, but is not limited to, a processor, a memory. Those skilled in the art can understand that the computer device shown in FIG. 1 is only an example of the computer device, and does not constitute a limitation on the computer device. The computer device can include more or fewer components than those shown in the figure, or combine certain components, or different components, for example, it can also include a network interface, a display screen, and an input device, etc.
[0161] The computer device can include, but is not limited to, a processor, a memory. Those skilled in the art can understand that the computer device shown in FIG. 1 is only an example of the computer device, and does not constitute a limitation on the computer device. The computer device can include more or fewer components than those shown in the figure, or combine certain components, or different components, for example, it can also include a network interface, a display screen, and an input device, etc. Figure 4
[0162] The processor can be a CPU, and can also be other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0163] The memory includes a readable storage medium, an internal memory, etc., where the internal memory can be a memory of the computer device, and the internal memory provides an environment for running the operating system and the computer-readable instructions in the readable storage medium. The readable storage medium can be a hard disk of the computer device, and in other embodiments, can also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory can include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a BootLoader, data, and other programs, such as program codes of computer programs, etc. The memory can also be used to temporarily store data that has been output or will be output.
[0164] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the units and modules in the above device can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here. If the integrated unit is realized in the form of software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, all or part of the processes in the above embodiment methods can be completed by a computer program instructing related hardware. The computer program can be stored in a computer readable storage medium. When the processor executes the computer program, the steps of the above method embodiments can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form. The computer readable medium at least includes any entity or device that can carry computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, computer readable medium cannot be electrical carrier signal and telecommunication signal.
[0165] The above embodiment methods can also be implemented by a computer program product, which can be run on a computer device to make the computer device execute the steps of the above method embodiments.
[0166] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0167] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0168] In the embodiments provided by the present application, it should be understood that the disclosed apparatus / computer device and method can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely schematic. The division of the modules or units is only a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.
[0169] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.
[0170] The above embodiments are only used to illustrate the technical solutions of the present application, but not limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A data conversion method characterized by, The method comprises the following steps: determining a relational database requiring data conversion, and obtaining relational tables in the relational database; for each relational table, calculating functional dependencies between different fields in the relational table; for each functional dependency, calculating field similarity between a left-hand side field corresponding to the functional dependency and right-hand side fields corresponding to other functional dependencies; generating entity relationship triples according to the functional dependencies and the field similarity; constructing graph data corresponding to the relational database according to the entity relationship triples; the generating entity relationship triples according to the functional dependencies and the field similarity comprises: if there are two functional dependencies and the field similarity between the left-hand side field of one of the two functional dependencies and the right-hand side field of the other functional dependency reaches a similarity threshold, then generating two entities according to the two functional dependencies and a relationship between the two entities according to the right-hand side field to obtain the entity relationship triples; and / or if the field similarity between the left-hand side field of one functional dependency and two right-hand side fields of another functional dependency both reaches the similarity threshold, then generating two entities according to the one functional dependency and a relationship between the two entities according to the two right-hand side fields to obtain the entity relationship triples; and / or if the field similarity between the left-hand side fields of two functional dependencies and different right-hand side fields of the same functional dependency reaches the similarity threshold, then generating two entities according to the two functional dependencies and a relationship between the two entities according to the different right-hand side fields to obtain the entity relationship triples. the calculating functional dependencies between different fields in each relational table comprises:
2. The data conversion method of claim 1, wherein, for each relational table, calculating candidate functional dependencies between different fields in the relational table; from all the candidate functional dependencies, screening out target candidate functional dependencies whose field definition order of left-hand side fields and right-hand side fields meets a preset definition order; performing functional dependency detection on the target candidate functional dependencies to obtain the functional dependencies according to the target candidate functional dependencies that pass the detection. when calculating the candidate functional dependencies between different fields in the relational table, storing intermediate data in a cache space during the calculation process, and the data conversion method further comprises:
3. The data conversion method of claim 2, wherein, in response to the intermediate data being evicted, storing the intermediate data to a persistent storage space and storing index information of the intermediate data in the cache space. the calculating field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side fields corresponding to other functional dependencies comprises:
4. The data conversion method of claim 1, wherein, calculating field name similarity and field data similarity between the left-hand side field corresponding to the functional dependency and the right-hand side fields corresponding to other functional dependencies; fusing the field name similarity and the field data similarity to obtain the field similarity between the left-hand side field corresponding to the functional dependency and the right-hand side fields corresponding to other functional dependencies. the constructing graph data corresponding to the relational database according to the entity relationship triples comprises:
5. The data conversion method of claim 1, wherein, constructing a complete graph by regarding each entity relationship triple as a node. determine mutually exclusive entity relationship triples, and delete edges in the complete graph corresponding to the mutually exclusive entity relationship triples, to obtain a non-complete graph; determine maximal cliques in the non-complete graph, and score each maximal clique to obtain a quality score of each maximal clique; construct graph data corresponding to the relational database according to entity relationship triples corresponding to a maximal clique with the highest quality score.
6. The data conversion method of claim 5, wherein, The determining of the mutually exclusive entity relationship triples includes: if entities of two entity relationship triples are the same, and the relationships of the two entity relationship triples are generated according to different right-hand side fields in a same functional dependency, then it is determined that the two entity relationship triples are mutually exclusive; and / or if a left-hand side field corresponding to an entity of an entity relationship triple belongs to a right-hand side field of another functional dependency, then it is determined that the entity relationship triple is mutually exclusive with an entity relationship triple generated according to a left-hand side field of the another functional dependency.
7. The data conversion method of claim 5, wherein, The scoring of each maximal clique is performed according to the following formula: ; wherein, denotes the sum over the number of attributes of different classes of entities in the maximal clique, denotes the number of classes of entity relationships in the maximal clique.
8. The data conversion method according to any one of claims 1 to 7, characterized by, After the constructing of the graph data corresponding to the relational database according to the entity relationship triples, the method further includes: providing a data configuration interface, and displaying the graph data in the data configuration interface; receiving an adjustment operation on the graph data, and adjusting a graph structure of the graph data according to the adjustment operation.
9. A data conversion apparatus, characterized by comprising: The method includes: a relation table acquisition module, configured to determine a relational database that needs to be converted, and acquire relation tables in the relational database; a dependency calculation module, configured to calculate functional dependencies between different fields in each of the relation tables; a similarity calculation module, configured to calculate field similarity between a left-hand side field corresponding to each functional dependency and a right-hand side field corresponding to another functional dependency; a triple generation module, configured to generate entity relationship triples according to the functional dependencies and the field similarity; a graph data construction module, configured to construct graph data corresponding to the relational database according to the entity relationship triples; The triple generation module is specifically configured to: if there are two functional dependencies, and field similarity between a left-hand side field of one of the two functional dependencies and a right-hand side field of the other functional dependency reaches a similarity threshold, then generate two entities according to the two functional dependencies, and generate a relationship between the two entities according to the right-hand side field, to obtain the entity relationship triples; and / or if field similarity between a left-hand side field of one functional dependency and two right-hand side fields of another functional dependency both reaches the similarity threshold, then generate two entities according to the one functional dependency, and generate a relationship between the two entities according to the two right-hand side fields, to obtain the entity relationship triples; and / or if field similarity between left-hand side fields of two functional dependencies and different right-hand side fields of a same functional dependency both reaches the similarity threshold, then generate two entities according to the two functional dependencies, and generate a relationship between the two entities according to the different right-hand side fields, to obtain the entity relationship triples. 10. A computer device, comprising: The computer device comprises a processor and a memory, and the memory stores a computer program capable of running on the processor, and the processor runs the computer program to implement the data conversion method in any one of claims 1 to 8.
11. A computer readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the data conversion method in any one of claims 1 to 8.
Citation Information
Patent Citations
Cross-data-structure attribute value extraction method and device, equipment and medium
CN118690208A
Graph association rule mining method and device, equipment and medium
CN120494056A