Graph Structure-Based Data Management Method and Related Devices

Through the data management method based on graph structure, entity data is extracted from relational databases and the graph database is constructed and updated, which solves the problem of inefficient data management in the existing technology and realizes efficient and stable data management.

CN115495620BActive Publication Date: 2025-06-24PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211189822.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-28
Publication Date
2025-06-24
Estimated Expiration
2042-09-28

AI Technical Summary

Technical Problem

Existing relational databases are difficult to efficiently manage ever-changing data changes, and lack of rapid delivery solutions, resulting in inefficient data management.

Method used

Using a data management method based on graph structure, we extract entity data from a relational database, build nodes and combine association relationships to form a graph database, update the graph database in real time, and verify the node legitimacy to ensure the stability of data management.

Benefits of technology

Through the construction and real-time update of graph databases, the efficiency of data management is improved, the rapid needs of data changes can be better adapted to the rapid demands of data changes, and the stability and legitimacy of data management are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115495620B_ABST
    Figure CN115495620B_ABST
Patent Text Reader

Abstract

The present application provides a data management method, apparatus, electronic device, and storage medium based on a graph structure. The data management method based on a graph structure includes: extracting entity data from a preset relational database; constructing nodes based on the entity data, and combining the nodes according to the association relationships between the entity data to construct a graph database; obtaining new data in the preset relational database in real time, and constructing new nodes and new association relationships based on the new data; inserting the new nodes into the graph database according to the new association relationships; verifying the legality of each node in the graph database to complete the update of the graph database. This method can convert a relational database into a graph database in real time based on primary keys and foreign keys, thereby improving the efficiency of data management and update.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and particularly to a method, apparatus, electronic device, and storage medium for data management based on a graph structure. Background Art

[0002] With the development of information technology, more and more enterprises or organizations tend to manage enterprise data in a digital form to provide reliable data support for intelligent operation and maintenance.

[0003] Currently, relational databases are usually adopted as the main databases to store and manage the data of enterprises and organizations. Relational databases usually require complex model design, maintenance, and a long version cycle, making it difficult to manage the ever-changing data situation and lacking solutions for relatively fast delivery requirements. Therefore, it is imperative to explore a method that can efficiently manage enterprise data. Summary of the Invention

[0004] In view of the above, it is necessary to provide a data management method and related devices based on a graph structure to solve the technical problem of how to improve the efficiency of data management. Among them, the related devices include a data management device based on a graph structure, an electronic device, and a storage medium.

[0005] An embodiment of this application provides a data management method based on a graph structure. The method includes:

[0006] Extracting entity data from a preset relational database;

[0007] Constructing nodes based on the entity data, and combining the nodes according to the association relationships between the entity data to construct a graph database;

[0008] Obtaining the newly added data in the preset relational database in real time, and constructing newly added nodes and newly added association relationships based on the newly added data;

[0009] Inserting the newly added nodes into the graph database according to the newly added association relationships;

[0010] Verifying the legitimacy of each node in the graph database to complete the update of the graph database.

[0011] In some embodiments, the preset relational database includes multiple data tables. The extracting entity data from a preset relational database includes:

[0012] Querying the theme of each data table, where the theme is used to characterize the category of data stored in the data table;

[0013] Query the primary keys and foreign keys in each of the said data tables, take the data tables with primary keys as entity tables, and take the data tables without primary keys as supplementary attribute tables;

[0014] For each row of data in the said entity table, take the primary key as the entity name, and take the data other than the primary key as the first entity attribute of the entity;

[0015] Take each row of data in the supplementary attribute table as the second entity attribute of the entity corresponding to the foreign key of this row of data;

[0016] Unify the first entity attribute and the second entity attribute of the entity as the entity attribute of the entity;

[0017] Take the subject of the entity table as the entity label of each row of data in the entity table.

[0018] In some embodiments, the constructing nodes based on the entity data and combining the nodes according to the association relationships between the entity data to construct a graph database includes:

[0019] Combine the entity name, entity label and entity attribute to construct a node corresponding to each entity data;

[0020] Encode the entity name to obtain the index corresponding to the node;

[0021] If the entity table has a foreign key, there is an association relationship between the entity data in the entity table and the entity data corresponding to the foreign key;

[0022] Store the indexes of the nodes corresponding to the entity data with association relationships in the form of key-value pairs to construct a graph database.

[0023] In some embodiments, the real-time acquisition of new data in the preset relational database and the construction of new nodes and new association relationships based on the new data includes:

[0024] Real-time acquire new data in the preset relational database, and query the primary key and foreign key of the new data;

[0025] If the new data contains a primary key, construct a new node based on the new data;

[0026] If the new data also contains a foreign key, query the association relationship between the new node and each node in the graph database based on the foreign key of the new data;

[0027] If the new data does not contain a primary key but contains a foreign key, take the new data as the supplementary attribute data of the entity corresponding to the foreign key.

[0028] In some embodiments, inserting the new node into the graph database according to the new association relationship includes:

[0029] Querying the associated nodes of the new node according to the association relationship of the new node;

[0030] Adding the index of the new node to the association relationship key-value pair of the associated node to complete the insertion of the new node.

[0031] In some embodiments, verifying the legality of each node in the graph database to complete the update of the graph database includes:

[0032] a. Marking all nodes in the graph database as unvisited;

[0033] b. Selecting an arbitrary node from the graph database as the current node, verifying the current node according to a preset verification algorithm to obtain the verification result of the current node, and marking the current node as visited, where the verification result includes verification passed and verification failed;

[0034] c. Querying the associated nodes of the current node, verifying the associated nodes, obtaining the verification results of the associated nodes, and marking the associated nodes as visited;

[0035] d. Repeating steps b to c until all nodes in the graph database are marked as visited, then stopping the traversal and obtaining the verification results of all nodes;

[0036] e. If the verification results of all nodes in the graph database are verification passed, then complete the update of the graph database. If the verification result of at least one node in the graph database is verification failed, then delete the new node from the graph database and send a legality warning.

[0037] In some embodiments, the preset verification algorithm includes:

[0038] Taking the index of the current node as the index to be verified, and simultaneously querying all associated nodes of the current node;

[0039] Sequentially querying the association relationship key-value pairs of each associated node. If the index to be verified exists in each association relationship key-value pair, then the verification passes;

[0040] If at least one of the association relationship key-value pairs does not contain the index to be verified, then the verification fails.

[0041] An embodiment of the present application further provides a data management device based on a graph structure. The device includes:

[0042] An extraction unit for extracting entity data from a preset relational database;

[0043] A first construction unit for constructing nodes based on the entity data and combining the nodes according to the association relationships between the entity data to construct a graph database;

[0044] A second construction unit for obtaining new data in the preset relational database in real time and constructing new nodes and new association relationships based on the new data;

[0045] An insertion unit for inserting the new nodes into the graph database according to the new association relationships;

[0046] An inspection unit for inspecting the legality of each node in the graph database to complete the update of the graph database.

[0047] An embodiment of the present application further provides an electronic device, which includes:

[0048] A memory for storing computer-readable instructions; and

[0049] A processor for executing the computer-readable instructions stored in the memory to implement the data management method based on the graph structure.

[0050] An embodiment of the present application further provides a computer-readable storage medium, in which computer-readable instructions are stored, and the computer-readable instructions are executed by a processor in an electronic device to implement the data management method based on the graph structure.

[0051] The above data management method based on the graph structure obtains the entity data and association relationships in the relational database by querying the primary keys and foreign keys of the data tables in the relational database, and uses the association relationships to combine the nodes corresponding to the entity data to complete the construction of the graph database. In order to maintain the stability of the graph database, the new data in the relational database is inserted into the graph database in real time, and after the insertion is completed, the legality of all nodes in the graph database is inspected to maintain the overall legality of the graph database, so as to achieve efficient data management. Description of the Drawings

[0052] Figure 1 is a flowchart of a preferred embodiment of a data management method based on the graph structure involved in the present application.

[0053] Figure 2 is a functional module diagram of a preferred embodiment of a data management device based on the graph structure involved in the present application.

[0054] Figure 3It is a schematic structural diagram of an electronic device according to a preferred embodiment of the graph structure-based data management method involved in the present application.

[0055] Figure 4a It is a schematic structural diagram of the server information table according to an embodiment of the present application.

[0056] Figure 4b It is a schematic structural diagram of the server supplementary attribute table according to an embodiment of the present application.

[0057] Figure 4c It is a schematic structural diagram of the cabinet information table according to an embodiment of the present application.

[0058] Figure 4d It is a schematic structural diagram of the data center floor information table according to an embodiment of the present application.

[0059] Figure 5 It is a schematic structural diagram of the graph database according to an embodiment of the present application. Detailed implementation manners

[0060] In order to more clearly understand the purpose, features, and advantages of the present application, the present application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present application and the features in the embodiments may be combined with each other. Many specific details are set forth in the following description in order to fully understand the present application. The described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments.

[0061] In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality of" means two or more, unless otherwise specifically defined.

[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs. The terms used in the description of the present application herein are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0063] The embodiment of the present application provides a data management method based on a graph structure, which can be applied to one or more electronic devices. The electronic device is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.

[0064] The electronic device can be any electronic product that can perform human-computer interaction with a user. For example, a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an Internet Protocol Television (IPTV), a smart wearable device, etc.

[0065] The electronic device may further include a network device and / or a user device. Among them, the network device includes but is not limited to a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing (Cloud Computing).

[0066] The network where the electronic device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0067] As Figure 1 shown, it is a flowchart of a preferred embodiment of the data management method based on a graph structure of the present application. According to different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.

[0068] S10, extract entity data from a preset relational database.

[0069] In an optional embodiment, the preset relational database includes multiple data tables, and the entity data includes an entity name, an entity label, and entity attributes. The extracting of entity data from the preset relational database includes:

[0070] Query the subject of each data table, and the subject is used to characterize the category of data stored in the data table;

[0071] Query the primary keys and foreign keys in each data table. Use the data table with a primary key as the entity table, and use the data table with only foreign keys as the supplementary attribute table;

[0072] For each row of data in the entity table, use the primary key as the entity name, and use the data other than the primary key as the first entity attribute of the entity;

[0073] Use each row of data in the supplementary attribute table as the second entity attribute of the entity corresponding to the foreign key of that row of data;

[0074] Unify the first entity attribute and the second entity attribute of the entity data as the entity attribute of the entity data;

[0075] Use the theme of the entity table as the entity label for each row of data in the entity table.

[0076] In this optional embodiment, the preset relational database is used to store entity data using the multiple data tables. The preset relational database can be an existing relational database such as a MySQL database or an Oracle database, and this application does not limit it. The entity can be a server, a switch, a program interface, an organizational role, etc., and this application does not limit it. When the entity is a server, the entity data includes a server number, a server name, a server creator, a server creation time, etc.; when the entity is an organizational role, the entity data includes an organizational role name, an organizational role number, the department to which the organizational role belongs, an organizational role position name, etc.

[0077] In this optional embodiment, the data table contains multiple rows of data and multiple columns of data, and the data table contains a primary key and / or at least one foreign key. Each data table will have a theme, and the theme is used to characterize the category of data stored in each data table. For example, the theme of the data table can be a server, a switch, a program interface, an organizational role, employee information, etc. The primary key is a column of data in the data table, which is used to characterize the unique identifier of each row of data in the data table. The primary key can be used as the entity name of the entity data. Exemplarily, when the theme of the data table is a server, the primary key of the data table can be the number of the server; when the theme of the data table is employee information, the primary key of the data table can be the employee number; when the theme of the data table is a program interface, the primary key of the data table can be the program interface number.

[0078] The foreign key is a column of data in the data table, and the foreign key is the primary key of another data table. Exemplarily, as Figure 4a shown is the structural schematic diagram of the entity table with the theme of "server information", as Figure 4cThe following is a schematic structural diagram of an entity table with the theme of "cabinet information". The server information table contains a foreign key "cabinet number", and the "cabinet number" is the primary key in the cabinet information table.

[0079] In this alternative embodiment, when the data table contains a primary key, it indicates that each row of data in the data table is entity data in the relational database. Then, the data table can be regarded as an entity table, and the data other than the primary key in each row of the entity table can be regarded as the first entity attribute of the entity. Exemplarily, as Figure 4a shown in the entity table where the primary key is the server number, the data other than the server number in each row of this entity table can be regarded as the first entity attribute of each server; as Figure 4c shown in the entity table where the primary key is the cabinet number, the data other than the cabinet number in each row of this entity table can be regarded as the first entity attribute of each cabinet.

[0080] In this alternative embodiment, when the data table does not contain a primary key but contains a foreign key, it indicates that each row of data in the data table is not an entity in the relational database. The data table can be regarded as a supplementary attribute table, and each row of data in the supplementary attribute table is the second entity attribute of the entity corresponding to the foreign key in each row of data. Exemplarily, as Figure 4b shown in the schematic structural diagram of the server supplementary attribute table. The server supplementary attribute table does not contain a primary key and has a foreign key, and the foreign key is the server number. Therefore, the entity corresponding to the foreign key is the entity in the entity table with the server number as the primary key, that is, Figure 4a the entity in the server information table shown. Therefore, each row of data in the server supplementary attribute table is Figure 4a the second entity attribute of each entity in the server information table shown. In this alternative embodiment, when querying the theme of each data table in the relational database, if the data table is an entity table, the theme can be regarded as the entity label corresponding to all entity data in the entity table.

[0081] In this way, by querying the theme, primary key, and foreign key of the data tables in the relational database, the extraction of entity data is realized, providing a data basis for the subsequent construction of the graph database.

[0082] S11. Build nodes based on the entity data, and combine the nodes according to the association relationships between the entity data to build a graph database.

[0083] In an alternative embodiment, the building of nodes based on the entity data and the combination of the nodes according to the association relationships between the entity data to build a graph database includes:

[0084] Combine the entity name, entity label, and entity attributes to construct a node corresponding to each entity;

[0085] Encode the entity name to obtain the index corresponding to the node;

[0086] If the entity table has a foreign key, the entity data in the entity table has an association relationship with the entity data corresponding to the foreign key;

[0087] Store the indexes of the nodes corresponding to the entity data with an association relationship in the form of key-value pairs to construct a graph database.

[0088] In this optional embodiment, the entity name, entity label, and entity attributes can be combined according to a preset combination order to construct a node corresponding to each entity. The form of the node can be in the form of a list, string, etc., and the present application does not make any limitations thereto. The preset combination order can be "entity name + entity label + entity attributes".

[0089] Exemplarily, when the entity name is Server A, the entity label is server, and the entity attributes are "Creation time: July 10, 2022, Cabinet number: Cabinet 1, Memory capacity: Capacity 1, I / O rate: 1 Gb / s", the node corresponding to the entity is [Server A, server, Creation time: July 10, 2022, Cabinet number: Cabinet 1, Memory capacity: Capacity 1, I / O rate: 1 Gb / s].

[0090] In this optional embodiment, the entity name can be encoded according to a preset encoding algorithm as the index of each node corresponding to the entity. The preset encoding algorithm can be existing encoding algorithms such as hash encoding algorithm, ASCII encoding algorithm, UTF-8 encoding algorithm, etc., and the present application does not make any limitations thereto.

[0091] In this optional embodiment, if the entity table has a foreign key, the entity data in the entity table has an association relationship with the entity data corresponding to the foreign key. The index of the node corresponding to the entity data in the entity table can be used as the key, and the index of the node corresponding to the entity data of the foreign key can be used as the value to construct a key-value pair, such as Figure 4a and Figure 4c The entity data has an association relationship. Store all key-value pairs to obtain a graph database, such as Figure 5 shown as the structural schematic diagram of the graph database.

[0092] In this optional embodiment, if the entity table does not have a foreign key and the primary key in this entity table is not a foreign key in the remaining data tables in the preset relational database, it indicates that the node corresponding to the entity in the entity table has no association relationship with any node. Exemplarily, such as Figure 4dThe figure shows a schematic structural diagram of an entity table without a foreign key. The primary key of this table is "floor", and the primary key of this table is not a foreign key in any other data tables. Therefore, the entities in this table have no association relationship with any entities, and the nodes corresponding to the entities in this table are isolated nodes in the graph database, such as Figure 5 Node A in the graph database shown.

[0093] In this way, nodes are constructed based on the entity data in the relational database, and all nodes are stored as a graph structure using the association relationships between the nodes to implement the conversion of the relational database into a graph database, thereby improving the efficiency of subsequent data queries.

[0094] S12, real-time obtain the new data in the preset relational database, and construct new nodes and new association relationships according to the new data.

[0095] In an optional embodiment, the real-time obtaining the new data in the preset relational database and constructing new nodes and new association relationships according to the new data includes:

[0096] Real-time obtain the new data in the preset relational database, and query the primary key and foreign key of the new data;

[0097] If the new data contains a primary key, construct new nodes according to the new data;

[0098] If the new data also contains a foreign key, query the association relationship between the new nodes and each node in the graph database according to the foreign key of the new data;

[0099] If the new data does not contain a primary key but contains a foreign key, use the new data as supplementary attribute data of the entity corresponding to the foreign key.

[0100] In this optional embodiment, the new data in the preset relational database is obtained in real time, and the primary key and foreign key of the new data can be queried according to a preset SQL program.

[0101] If the new data has a primary key, it indicates that the new data is entity data. Then, the subject of the data table where the new data is located can be queried as the entity label of the new data, and the primary key of the new data can be used as the entity name of the new data, and the data other than the primary key can be used as the entity attributes of the new data. Combine the entity name, entity label, and entity attributes to construct the new nodes corresponding to the new data, and encode the entity name in the new nodes according to the preset encoding algorithm to obtain the index of the new nodes.

[0102] In this optional embodiment, if the new data also has a foreign key, the entity data corresponding to the foreign key of the new data can be queried, and the node corresponding to the entity data is recorded as the associated node. The index of the new node can be used as the key, and the index of the associated node can be used as the value to construct a new key-value pair, which is used to represent the association relationship between the new node and the existing nodes in the graph database.

[0103] Exemplarily, when the new data is server information data, the primary key of the new data is the server number. If the new data has a foreign key, and the foreign key is the cabinet number, the entity corresponding to the cabinet number can be queried, that is, the entity in the data table with the cabinet number as the primary key, and the node corresponding to the entity is used as the associated node of the new node corresponding to the new data.

[0104] In this optional embodiment, if the new data does not have a primary key but has a foreign key, it indicates that the new data is not entity data. Then the new data can be used as supplementary attribute data of the entity corresponding to its foreign key. Exemplarily, when the new data does not have a primary key but has a foreign key, and the foreign key of the new data is the server number, the entity corresponding to the new data is the entity corresponding to the foreign key, that is, the entity in the data table with the server number as the primary key.

[0105] In this way, querying the primary key and foreign key of the new data to perform different operations on the new data can provide guidance for the subsequent update of the data in the graph database.

[0106] S13. Insert the new node into the graph database according to the new association relationship.

[0107] In an optional embodiment, the inserting the new node into the graph database according to the new association relationship includes:

[0108] Query the associated node of the new node according to the association relationship of the new node;

[0109] Add the index of the new node to the association relationship key-value pair of the associated node to complete the insertion of the new node.

[0110] In this optional embodiment, the association relationship of the new node is a new key-value pair. The key of the new key-value pair is the index of the new node, and the value of the new key-value pair is the index of the node having an association relationship with the new node. The node having an association relationship with the new node can be queried according to the value in the new key-value pair as the associated node.

[0111] In this optional embodiment, the key in the association relationship key value of the associated node is the index of the associated node, and the value in the association relationship key value pair is the index of the node associated with the associated node. The index of the newly added node is respectively added to each association relationship key value pair of the associated node to update the association relationship of the associated node, thereby completing the insertion of the newly added node.

[0112] In this way, by updating the association relationship key value pair of the associated node to complete the insertion operation of the newly added node, the graph database can be updated in real time according to the update of the entity data in the relational database, thereby ensuring the integrity of the data in the graph database.

[0113] S14. Verify the legality of each node in the graph database to complete the update of the graph database.

[0114] In an optional embodiment, the verifying the legality of each node in the graph database to complete the update of the graph database includes:

[0115] a. Mark all nodes in the graph database as unvisited;

[0116] b. Select an arbitrary node from the graph database as the current node, and verify the current node according to a preset verification algorithm to obtain the verification result of the current node, and mark the current node as visited. The verification result includes verification passed and verification failed;

[0117] c. Query the associated nodes of the current node, and verify the associated nodes to obtain the verification results of the associated nodes, and mark the associated nodes as visited;

[0118] d. Repeat steps b to c until all nodes in the graph database are marked as visited, then stop traversing and obtain the verification results of all nodes;

[0119] e. If the verification results of all nodes in the graph database are verification passed, the update of the graph database is completed. If the verification result of at least one node in the graph database is verification failed, it indicates that an error occurred during the process of inserting the newly added node into the graph database. Therefore, the state of the graph database needs to be rolled back to the state before the newly added node was added, that is, the newly added node is deleted from the graph database, and a legality warning is sent to the developer of the graph database to remind the developer to troubleshoot the cause of the error. In an optional embodiment, the preset verification algorithm includes:

[0120] Take the index of the current node as the index to be verified, and at the same time query all the associated nodes of the current node;

[0121] Query the association relation key-value pairs of each of the said associated nodes in sequence. If the to-be-verified index exists in each of the said association relation key-value pairs, the verification passes;

[0122] If at least one of the said association relation key-value pairs does not contain the to-be-verified index, the verification fails.

[0123] In this way, by verifying the data of each node in the graph database to obtain the verification result, and evaluating the legality of the association relations of each node in the graph database in real time through the verification result, the stability of the graph database can be improved.

[0124] The above data management method based on the graph structure obtains the entity data and association relations in the relational database by querying the primary keys and foreign keys of the data tables in the relational database, and uses the association relations to combine the nodes corresponding to the entity data to complete the construction of the graph database. In order to maintain the stability of the graph database, the newly added data in the relational database is inserted into the graph database in real time, and the legality of all nodes in the graph database is verified after the insertion is completed to maintain the overall legality of the graph database, so as to achieve efficient data management.

[0125] As Figure 2 shown, it is the functional module diagram of the preferred embodiment of the data management device based on the graph structure provided by the embodiment of the present application. The data management device 11 based on the graph structure includes an extraction unit 110, a first construction unit 111, a second construction unit 112, an insertion unit 113, and a verification unit 114. The modules / units referred to in the present application refer to a series of computer program segments that can be executed by a processor 13 and can complete fixed functions, and are stored in a memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0126] In an optional embodiment, the extraction unit 110 is used to extract entity data from a preset relational database.

[0127] In an optional embodiment, the preset relational database includes multiple data tables, and the extracting entity data from the preset relational database includes:

[0128] Query the theme of each data table, and the theme is used to characterize the category of the data stored in the data table;

[0129] Query the primary key and foreign key in each data table, regard the data table with the primary key as the entity table, and regard the data table with only the foreign key as the supplementary attribute table;

[0130] For each row of data in the entity table, use the primary key as the entity name, and use the data other than the primary key as the first entity attribute of the entity;

[0131] Use each row of data in the supplementary attribute table as the second entity attribute of the entity corresponding to the foreign key of the row data.

[0132] Unify the first entity attribute and the second entity attribute of the entity data as the entity attribute of the entity data.

[0133] Use the theme of the entity table as the entity label for each row of data in the entity table.

[0134] In this optional embodiment, the preset relational database is used to store entity data using the multiple data tables. The preset relational database can be an existing relational database such as a MySQL database or an Oracle database, and this application does not limit it. The entity can be a server, a switch, a program interface, an organizational role, etc., and this application does not limit it. When the entity is a server, the entity data includes a server number, a server name, a server creator, a server creation time, etc.; when the entity is an organizational role, the entity data includes an organizational role name, an organizational role number, the department to which the organizational role belongs, an organizational role position name, etc.

[0135] In this optional embodiment, the data table contains multiple rows of data and multiple columns of data, and the data table contains a primary key and / or at least one foreign key. Each data table has a theme, and the theme is used to characterize the category of data stored in each data table. For example, the theme of the data table can be a server, a switch, a program interface, an organizational role, employee information, etc. The primary key is a column of data in the data table, which is used to represent the unique identifier of each row of data in the data table. The primary key can be used as the entity name of the entity data. Exemplarily, when the theme of the data table is a server, the primary key of the data table can be the number of the server; when the theme of the data table is employee information, the primary key of the data table can be the employee ID number; when the theme of the data table is a program interface, the primary key of the data table can be the program interface number.

[0136] The foreign key is a column of data in the data table, and the foreign key is the primary key in another data table. Exemplarily, as Figure 4a shown is a schematic structural diagram of an entity table with the theme of "server information", as Figure 4c shown is a schematic structural diagram of an entity table with the theme of "cabinet information". The server information table contains a foreign key "cabinet number", and the "cabinet number" is the primary key in the cabinet information table.

[0137] In this alternative embodiment, when the data table contains a primary key, it indicates that each row of data in the data table is entity data in the relational database. Then, the data table can be used as an entity table, and the data other than the primary key in each row of the entity table can be used as the first entity attribute of the entity. Exemplarily, as Figure 4a shown in the entity table where the primary key is the server number, the data other than the server number in each row of this entity table can be used as the first entity attribute of each server; as Figure 4c shown in the entity table where the primary key is the cabinet number, the data other than the cabinet number in each row of this entity table can be used as the first entity attribute of each cabinet.

[0138] In this alternative embodiment, when the data table does not contain a primary key but contains a foreign key, it indicates that each row of data in the data table is not an entity in the relational database. The data table can be used as a supplementary attribute table, and each row of data in the supplementary attribute table is the second entity attribute of the entity corresponding to the foreign key in each row of data. Exemplarily, as Figure 4b shown in the schematic structural diagram of the server supplementary attribute table. The server supplementary attribute table does not contain a primary key and has a foreign key, and the foreign key is the server number. Therefore, the entity corresponding to the foreign key is the entity in the entity table with the server number as the primary key, that is, Figure 4a the entity in the server information table shown. Therefore, each row of data in the server supplementary attribute table is Figure 4a the second entity attribute of each entity in the server information table shown. In this alternative embodiment, when querying the subject of each data table in the relational database, if the data table is an entity table, the subject can be used as the entity label corresponding to all entity data in the entity table.

[0139] In an alternative embodiment, the first construction unit 111 is configured to construct nodes based on the entity data, and combine the nodes according to the association relationship between the entity data to construct a graph database.

[0140] In an alternative embodiment, the constructing nodes based on the entity data and combining the nodes according to the association relationship between the entity data to construct a graph database includes:

[0141] Combining the entity name, entity label, and entity attribute to construct a node corresponding to each entity;

[0142] Encoding the entity name to obtain the index corresponding to the node;

[0143] If the entity table has a foreign key, there is an association relationship between the entity data in the entity table and the entity data corresponding to the foreign key;

[0144] Store the indexes of the corresponding nodes of the entity data with an associated relationship in the form of key-value pairs to construct a graph database.

[0145] In this optional embodiment, the entity name, entity label, and entity attributes can be combined according to a preset combination order to construct a node corresponding to each entity. The form of the node can be a list, a string, etc., and the present application does not limit this. The preset combination order can be "entity name + entity label + entity attributes".

[0146] Exemplarily, when the entity name is Server A, the entity label is server, and the entity attributes are "Creation time: July 10, 2022, Cabinet number: Cabinet 1, Memory capacity: Capacity 1, I / O rate: 1 Gb / s", the node corresponding to the entity is [Server A, server, Creation time: July 10, 2022, Cabinet number: Cabinet 1, Memory capacity: Capacity 1, I / O rate: 1 Gb / s].

[0147] In this optional embodiment, the entity name can be encoded according to a preset encoding algorithm to be used as the index of the node corresponding to each entity. The preset encoding algorithm can be existing encoding algorithms such as hash encoding algorithm, ASCII encoding algorithm, UTF-8 encoding algorithm, etc., and the present application does not limit this.

[0148] In this optional embodiment, if the entity table has a foreign key, the entity data in the entity table has an associated relationship with the entity data corresponding to the foreign key. The index of the node corresponding to the entity data in the entity table can be used as the key, and the index of the node of the entity data corresponding to the foreign key can be used as the value to construct a key-value pair. For example, Figure 4a and Figure 4c The entity data has an associated relationship. Store all key-value pairs to obtain a graph database. For example, Figure 5 The structure diagram of the graph database is shown as follows.

[0149] In this optional embodiment, if the entity table does not have a foreign key and the primary key in the entity table is not a foreign key in the other data tables in the preset relational database, it indicates that the node corresponding to the entity in the entity table has no associated relationship with any node. Exemplarily, as Figure 4d Shown is the structure diagram of the entity table without a foreign key. The primary key of this table is "floor", and the primary key of this table is not a foreign key in the other data tables. Therefore, the entity in this table has no associated relationship with any entity, and the node corresponding to the entity in this table is an isolated node in the graph database. For example, Figure 5 Node A in the graph database shown as follows.

[0150] In an optional embodiment, the second construction unit 112 is configured to obtain the newly added data in the preset relational database in real time, and construct new nodes and new association relationships based on the newly added data.

[0151] In an optional embodiment, the obtaining the newly added data in the preset relational database in real time and constructing new nodes and new association relationships based on the newly added data includes:

[0152] Obtaining the newly added data in the preset relational database in real time, and querying the primary key and foreign key of the newly added data;

[0153] If the newly added data includes a primary key, constructing new nodes based on the newly added data;

[0154] If the newly added data further includes a foreign key, querying the association relationship between the new node and each node in the graph database according to the foreign key of the newly added data;

[0155] If the newly added data does not include a primary key but includes a foreign key, using the newly added data as supplementary attribute data of the entity corresponding to the foreign key.

[0156] In this optional embodiment, the newly added data in the preset relational database is obtained in real time, and the primary key and foreign key of the newly added data can be queried according to a preset SQL program.

[0157] If the newly added data has a primary key, it indicates that the newly added data is entity data. Then, the subject of the data table where the newly added data is located can be queried as the entity label of the newly added data, and the primary key of the newly added data can be used as the entity name of the newly added data. The data other than the primary key is used as the entity attribute of the newly added data. The entity name, entity label, and entity attribute are combined to construct a new node corresponding to the newly added data, and the index of the new node is obtained by encoding the entity name in the new node according to the preset encoding algorithm.

[0158] In this optional embodiment, if the newly added data also has a foreign key, the entity data corresponding to the foreign key of the newly added data can be queried, and the node corresponding to the entity data is recorded as an associated node. The index of the new node can be used as the key, and the index of the associated node can be used as the value to construct a new key-value pair, and the new key-value pair is used to represent the association relationship between the new node and the existing nodes in the graph database.

[0159] Exemplarily, when the new data is server information data, the primary key of the new data is the server number. If the new data has a foreign key, and the foreign key is the cabinet number, then the entity corresponding to the cabinet number can be queried, that is, the entity in the data table with the cabinet number as the primary key, and the node corresponding to the entity is used as the associated node of the new node corresponding to the new data.

[0160] In this alternative embodiment, if the new data does not have a primary key but has a foreign key, it indicates that the new data is not entity data. Then, the new data can be used as supplementary attribute data of the entity corresponding to its foreign key. Exemplarily, when the new data does not have a primary key but has a foreign key, and the foreign key of the new data is the server number, the entity corresponding to the new data is the entity corresponding to the foreign key, that is, the entity in the data table with the server number as the primary key.

[0161] In an alternative embodiment, the insertion unit 113 is used to insert the new node into the graph database according to the new association relationship.

[0162] In an alternative embodiment, inserting the new node into the graph database according to the new association relationship includes:

[0163] Querying the associated node of the new node according to the association relationship of the new node;

[0164] Adding the index of the new node to the association relationship key-value pair of the associated node to complete the insertion of the new node.

[0165] In this alternative embodiment, the association relationship of the new node is a new key-value pair. The key of the new key-value pair is the index of the new node, and the value of the new key-value pair is the index of the node having an association relationship with the new node. The node having an association relationship with the new node can be queried according to the value in the new key-value pair to be used as the associated node.

[0166] In this alternative embodiment, the key in the association relationship key value of the associated node is the index of the associated node, and the value in the association relationship key-value pair is the index of the node having an association relationship with the associated node. The index of the new node is added to the association relationship key-value pair of each associated node to update the association relationship of the associated node, thereby completing the insertion of the new node.

[0167] In an alternative embodiment, the verification unit 114 is used to verify the legality of each node in the graph database to complete the update of the graph database.

[0168] In an optional embodiment, verifying the legality of each node in the graph database to complete the update of the graph database includes:

[0169] a. Mark all nodes in the graph database as unvisited;

[0170] b. Select an arbitrary node from the graph database as the current node, verify the current node according to a preset verification algorithm to obtain the verification result of the current node, and mark the current node as visited. The verification result includes verification passed and verification failed;

[0171] c. Query the associated nodes of the current node, verify the associated nodes, obtain the verification results of the associated nodes, and mark the associated nodes as visited;

[0172] d. Repeat steps b to c until all nodes in the graph database are marked as visited, then stop traversing and obtain the verification results of all nodes;

[0173] e. If the verification results of all nodes in the graph database are verification passed, complete the update of the graph database. If the verification result of at least one node in the graph database is verification failed, it indicates that an error occurred during the process of inserting the new node into the graph database. Therefore, it is necessary to roll back the state of the graph database to the state before the new node was added, that is, delete the new node from the graph database, and send a legality warning to the developers of the graph database to remind the developers to troubleshoot the cause of the error. In an optional embodiment, the preset verification algorithm includes:

[0174] Use the index of the current node as the index to be verified, and at the same time query all associated nodes of the current node;

[0175] Query the associated relationship key-value pairs of each associated node in sequence. If the index to be verified exists in each associated relationship key-value pair, the verification passes;

[0176] If at least one of the associated relationship key-value pairs does not contain the index to be verified, the verification fails.

[0177] The above data management method based on the graph structure obtains the entity data and the associated relationships in the relational database by querying the primary key and foreign key of the data table in the relational database, and uses the associated relationships to combine the nodes corresponding to the entity data to complete the construction of the graph database. In order to maintain the stability of the graph database, the newly added data in the relational database is inserted into the graph database in real time, and the legality of all nodes in the graph database is verified after the insertion is completed to maintain the overall legality of the graph database, so as to achieve efficient data management.

[0178] As shown Figure 3 in the figure, it is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device 1 includes a memory 12 and a processor 13. The memory 12 is used to store computer-readable instructions, and the processor 13 is used to execute the computer-readable instructions stored in the memory to implement the data management method based on the graph structure in any of the above embodiments.

[0179] In an optional embodiment, the electronic device 1 further includes a bus and a computer program stored in the memory 12 and executable on the processor 13, such as a data management program based on the graph structure.

[0180] Figure 3 Only the electronic device 1 with components 12-13 is shown. Those skilled in the art can understand that Figure 3 the shown structure does not limit the electronic device 1, and it may include fewer or more components than shown, or combine some components, or have different component arrangements.

[0181] In combination with Figure 1 , the memory 12 in the electronic device 1 stores multiple computer-readable instructions to implement a data management method based on the graph structure. The processor 13 can execute multiple instructions to implement:

[0182] Extract entity data from a preset relational database;

[0183] Construct nodes based on the entity data, and combine the nodes according to the association relationships between the entity data to construct a graph database;

[0184] Real-time obtain the new data in the preset relational database, and construct new nodes and new association relationships based on the new data;

[0185] Insert the new nodes into the graph database according to the new association relationships;

[0186] Verify the legality of each node in the graph database to complete the update of the graph database.

[0187] Specifically, for the specific implementation method of the above instructions by the processor 13, reference can be made to Figure 1 the description of the relevant steps in the corresponding embodiment, which will not be elaborated here.

[0188] Among them, the memory 12 includes at least one type of readable storage medium, which can be non-volatile or volatile. The readable storage medium includes flash memory, mobile hard disks, multimedia cards, card-type memories (such as SD or DX memories, etc.), magnetic memories, magnetic disks, optical disks, etc. The memory 12 can be an internal storage unit of the electronic device 1 in some embodiments, such as the mobile hard disk of the electronic device 1. The memory 12 can also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device 1. Further, the memory 12 can also include both the internal storage unit and the external storage device of the electronic device 1. The memory 12 can be used not only to store application software installed on the electronic device 1 and various types of data, such as the code of the data management program based on the graph structure, etc., but also to temporarily store the data that has been output or will be output.

[0189] In some embodiments, the processor 13 can be composed of integrated circuits. For example, it can be composed of a single packaged integrated circuit, or can be composed of multiple integrated circuits with the same or different functions, including a combination of one or more Central Processing Units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips, etc. The processor 13 is the control core (Control Unit) of the electronic device 1, connecting various components of the entire electronic device 1 through various interfaces and lines. By running or executing the programs or modules stored in the memory 12 (such as executing the data management program based on the graph structure), and by calling the data stored in the memory 12, it can execute various functions of the electronic device 1 and process data.

[0190] The processor 13 executes the operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application programs to implement the steps in the above-mentioned embodiments of various data management methods based on the graph structure, such as Figure 1 the steps shown.

[0191] Exemplarily, the computer program may be divided into one or more modules / units, and the one or more modules / units are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into an extraction unit 110, a first construction unit 111, a second construction unit 112, an insertion unit 113, and a verification unit 114.

[0192] The integrated units implemented in the form of software function modules may be stored in a computer-readable storage medium. The above-mentioned software function modules stored in a storage medium include several instructions for causing a computer device (which may be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of the data management method based on a graph structure described in each embodiment of the present application.

[0193] If the integrated module / unit of the electronic device 1 is implemented in the form of a software function unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above-mentioned method embodiments of the present application, it may also be completed by a computer program instructing relevant hardware devices. The computer program may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned method embodiments may be implemented.

[0194] Among them, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory, and other memories, etc.

[0195] Further, the computer-readable storage medium mainly includes a program storage area and a data storage area. Among them, the program storage area may store an operating system, application programs required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0196] The blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. Blockchain, in essence, is a decentralized database, a series of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer, etc.

[0197] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, in Figure 3 only one arrow is used to represent it, but it does not mean that there is only one bus or one type of bus. The bus is set to implement the connection and communication between the memory 12 and at least one processor 13, etc.

[0198] The embodiment of this application also provides a computer-readable storage medium (not shown in the figure). Computer-readable instructions are stored in the computer-readable storage medium, and the computer-readable instructions are executed by a processor in an electronic device to implement the data management method based on the graph structure described in any of the above embodiments.

[0199] In several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there can be other division methods in actual implementation.

[0200] The modules described as separate components may or may not be physically separated. The components shown as modules may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0201] In addition, each functional module in each embodiment of this application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a hardware plus a software functional module.

[0202] In addition, it is obvious that the term "comprising" does not exclude other units or steps, and the singular does not exclude the plural. A plurality of units or devices described in the specification can also be implemented by one unit or device through software or hardware. Terms such as first and second are used to denote names and do not denote any particular order.

[0203] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit them. Although the present application has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present application can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. A data management method based on a graph structure, characterized in that The method includes: Extracting entity data from a preset relational database; the preset relational database includes multiple data tables. The extracting of entity data from the preset relational database includes: querying the theme of each data table, where the theme is used to characterize the category of data stored in the data table; querying the primary key and foreign key in each data table, taking the data table with a primary key as an entity table, and taking the data table without a primary key as a supplementary attribute table; for each row of data in the entity table, taking the primary key as the entity name, and taking the data other than the primary key as the first entity attribute of the entity; taking each row of data in the supplementary attribute table as the second entity attribute of the entity corresponding to the foreign key of the row of data; unifying the first entity attribute and the second entity attribute of the entity as the entity attribute of the entity; taking the theme of the entity table as the entity label of each row of data in the entity table; Constructing nodes based on the entity data, and combining the nodes according to the association relationship between the entity data to construct a graph database, including: combining the entity name, entity label, and entity attribute to construct a node corresponding to each entity data; encoding the entity name to obtain the index corresponding to the node; if the entity table has a foreign key, then there is an association relationship between the entity data in the entity table and the entity data corresponding to the foreign key; storing the indexes of the nodes corresponding to the entity data with an association relationship in the form of key-value pairs to construct a graph database; Real-time obtaining of new data in the preset relational database, and constructing new nodes and new association relationships based on the new data; Inserting the new nodes into the graph database according to the new association relationships; Verifying the legality of each node in the graph database to complete the update of the graph database.

2. The data management method based on a graph structure according to claim 1, wherein The real-time obtaining of new data in the preset relational database, and constructing new nodes and new association relationships based on the new data, includes: Real-time obtaining of new data in the preset relational database, and querying the primary key and foreign key of the new data; If the new data contains a primary key, constructing a new node based on the new data; If the new data also contains a foreign key, querying the association relationship between the new node and each node in the graph database according to the foreign key of the new data; If the new data does not contain a primary key but contains a foreign key, taking the new data as supplementary attribute data of the entity corresponding to the foreign key.

3. The data management method based on a graph structure according to claim 1, wherein The inserting of the new nodes into the graph database according to the new association relationships includes: Querying the associated nodes of the new node according to the association relationship of the new node; Adding the index of the new node to the association relationship key-value pair of the associated node to complete the insertion of the new node.

4. The data management method based on a graph structure according to claim 1, wherein The verifying of the legality of each node in the graph database to complete the update of the graph database includes: a. Marking all nodes in the graph database as unvisited; b. Select an arbitrary node from the graph database as the current node, verify the current node according to a preset verification algorithm to obtain the verification result of the current node, and mark the current node as visited. The verification result includes verification passed and verification failed; c. Query the associated nodes of the current node, verify the associated nodes, obtain the verification results of the associated nodes, and mark the associated nodes as visited; d. Repeat steps b to c until all nodes in the graph database are marked as visited, then stop traversing and obtain the verification results of all nodes; e. If the verification results of all nodes in the graph database are verification passed, complete the update of the graph database. If the verification result of at least one node in the graph database is verification failed, delete the newly added node from the graph database and send a legality warning.

5. The data management method based on a graph structure according to claim 4, wherein The preset verification algorithm includes: Use the index of the current node as the index to be verified, and simultaneously query all associated nodes of the current node; Sequentially query the associated relationship key-value pairs of each associated node. If the index to be verified exists in each associated relationship key-value pair, the verification passes; If at least one of the associated relationship key-value pairs does not contain the index to be verified, the verification fails.

6. A data management device based on a graph structure, characterized in that, The device includes units for implementing the method according to any one of claims 1 to 5. The device includes: An extraction unit for extracting entity data from a preset relational database; A first construction unit for constructing nodes according to the entity data and combining the nodes according to the association relationships between the entity data to construct a graph database; A second construction unit for obtaining new data in the preset relational database in real time and constructing new nodes and new association relationships according to the new data; An insertion unit for inserting the new nodes into the graph database according to the new association relationships; A verification unit for verifying the legality of each node in the graph database to complete the update of the graph database.

7. An electronic device, characterized in that, The electronic device includes: A memory for storing computer-readable instructions; and A processor for executing the computer-readable instructions stored in the memory to implement the graph structure-based data management method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions are executed by a processor in an electronic device to implement the graph structure-based data management method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data table entity relation graph generation method and device, equipment and storage medium

    CN114637811A

  • Systems, methods, and apparatuses for executing a graph query against a graph representing a plurality of data stores

    US20200226156A1