CN115269745A - Relational data-to-graph data mapping method, device and storage medium - Google Patents
Relational data-to-graph data mapping method, device and storage medium Download PDFInfo
- Publication number
- CN115269745A CN115269745A CN202210891628.XA CN202210891628A CN115269745A CN 115269745 A CN115269745 A CN 115269745A CN 202210891628 A CN202210891628 A CN 202210891628A CN 115269745 A CN115269745 A CN 115269745A
- Authority
- CN
- China
- Prior art keywords
- equipment
- node
- information
- association
- nodes
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 44
- 238000013506 data mapping Methods 0.000 title claims description 7
- 238000013507 mapping Methods 0.000 claims abstract description 17
- 230000015654 memory Effects 0.000 claims description 19
- 230000008859 change Effects 0.000 claims description 16
- 239000002243 precursor Substances 0.000 claims description 13
- 238000004590 computer program Methods 0.000 claims description 10
- 238000012544 monitoring process Methods 0.000 claims description 4
- 238000012545 processing Methods 0.000 abstract description 2
- 238000012098 association analyses Methods 0.000 abstract 1
- 238000005516 engineering process Methods 0.000 description 8
- 238000011161 development Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 5
- 238000012986 modification Methods 0.000 description 5
- 230000004048 modification Effects 0.000 description 5
- 238000004458 analytical method Methods 0.000 description 4
- 230000009191 jumping Effects 0.000 description 4
- 230000005291 magnetic effect Effects 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000000007 visual effect Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 239000000463 material Substances 0.000 description 2
- 206010063385 Intellectualisation Diseases 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9024—Graphs; Linked lists
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to the technical field of data processing, in particular to a method, equipment and a storage medium for mapping relational data to graph data, wherein the method comprises the following steps: acquiring data table information in a relational database, wherein the data table information at least comprises an equipment entity table, an association relation table and a primary key; traversing the equipment entity table, and sequentially creating equipment nodes in the graph database according to the main key; searching whether subsequent equipment exists in the association relation table or not according to the equipment nodes; if the subsequent equipment exists, searching the equipment entity table of the subsequent equipment, and judging whether the equipment node is established in the graph database; if the equipment node is not created, a new node is created, and the incidence relation among the nodes is created according to the incidence relation table; and if the equipment nodes are established, establishing the association relationship among the nodes according to the association relationship table. According to the invention, automatic mapping from relational data to graph data can be completed, and a more efficient and intuitive database is provided for subsequent association analysis, data retrieval and the like.
Description
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method, a device, and a storage medium for mapping relational data to graph data.
Background
With the high-speed development of the internet of things technology, the intellectualization of the power grid is gradually popularized, and the smart power grid integrates an efficient control mode, a decision-making strategy and an equipment technology on the basis of the development of a high-speed stable two-way communication network, so that the power grid application taking the cash sensing technology and the measuring technology as the core is finally formed. The smart grid is a product of the common development of the internet technology and the traditional power technology, and aims to meet the intelligent management and efficient operation and maintenance of a power system and provide good power service for users. However, with the continuous development of the smart grid technology, mass data are generated by widely distributed smart terminals, and how to store and analyze the mass data becomes a difficult problem in the further development of the smart grid.
In the existing intelligent power grid system, a relational database is mainly adopted to store data and user data acquired by an intelligent terminal, but under the condition of large data volume, the response time for searching the data is long, a general database system mainly relates to four basic operations of adding, deleting, modifying and searching, for searching and searching the data, the relational database needs to perform a large number of connection and traversal operations, and is complex and time-consuming.
The graph database can realize a data scale-independent query function by utilizing an index-free adjacency characteristic for connection operation, can be beneficial to storing data with high association degree in a large quantity, performs complex analysis aiming at the relationship, and provides great potential for exploring data association relationship and power grid innovation. The existing storage structure design of the smart power grid system and other power grid management systems is based on a relational database, and although the development of the relational database is relatively mature, the relational database is not suitable for storing data with high association degree, so that a method for automatically converting power distribution network data in the relational database into data in a graphic database is urgently needed.
The information disclosed in this background section is only for enhancement of understanding of the general background of the invention and should not be taken as an acknowledgement or any form of suggestion that this information forms the prior art already known to a person skilled in the art.
Disclosure of Invention
The invention provides a method, equipment and a storage medium for mapping relational data to graph data, thereby effectively solving the problems in the background art.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows: a relational data-to-graph data mapping method comprises the following steps:
acquiring data table information in a relational database, wherein the data table information at least comprises an equipment entity table, an association relation table and a primary key;
traversing the equipment entity table, and sequentially creating equipment nodes in a graph database according to the main key;
searching whether subsequent equipment exists in the association relation table or not according to the equipment node;
if the subsequent equipment exists, retrieving the equipment entity table of the subsequent equipment, and judging whether a standby node is established in the graph database or not;
if the equipment node is not created, a new node is created, and the incidence relation among the nodes is created according to the incidence relation table;
and if the equipment nodes are established, establishing the association relationship among the nodes according to the association relationship table.
Further, when the data table information in the relational database is obtained, whether the data table information at least comprises the equipment entity table, the association relation table and the primary key is judged;
if not, stopping mapping.
Further, when the data table information in the relational database is obtained, whether the equipment entity table has a single primary key is judged;
if not, stopping mapping.
Further, the sequentially creating device nodes in the image database according to the device entity table by the primary key includes:
acquiring a plurality of key values of the primary key corresponding to the equipment entity table;
searching equipment information in the equipment entity table and the association relation table according to the key value;
using the searched equipment information as an equipment nodeiAnd (4) writing the attribute into the image database.
Further, the step of searching for the device information in the device entity table and the association table according to the key value includes the following steps:
s100: according to the primary key id of the equipment entity table, creating a key value pair { k }i:viIn which k isiId, v of the ith key value of the primary keyiIs a tag value of an ith key value, and viIs 0;
s110: creating a set map, and matching the key-value pair ki:viAdding the obtained data into the set map;
s120: sequentially traversing the key value pairs with the mark value of 0 in the set map, and searching the equipment information;
s130: let the tag value v of the key-value pair traversediHas a value of 1;
s140: judging the mark value v in the set mapiWhether both are 1;
if not, repeating the steps S120 to S130, if yes, finishing the search.
Further, when retrieving whether a subsequent device exists in the association relationship table according to the device node, the method includes the following steps:
s200: upon creation of said device nodeiSaid device nodeiThe corresponding key-value pair is { ki:1};
S210: the equipment node is connected with the nodeiAdding the precursor into a precursor queue;
s220: judging whether the predecessor queue is empty;
s230: if not, taking out the head node of the precursor queuepSaid head of line nodepThe corresponding primary key value is kp(ii) a If yes, go back to the step S140;
s240: searching whether the head node of the queue exists in the incidence relation table or notpThe subsequent device key value is kjAnd v isjIs 0;
s250: if yes, finding a key value k in the equipment entity tablejApparatus of creating a new nodej(ii) a If not, returning to the step S220;
s260: according to the incidence relation table, the node is taken as a nodepAnd a nodejCreating an incidence relation;
s270: the node is connected with the nodejPut into the predecessor queue and return to step S240.
Further, the method also comprises the following steps:
monitoring whether equipment is changed in a PMS;
and if so, modifying the equipment node and/or the incidence relation according to the equipment entity table and/or the incidence relation table.
Further, the device change comprises: any one or more of newly added equipment, equipment retirement, equipment information change and association information change among equipment.
Further, when the device is newly added, a new node is created according to the device entity table, and an association relationship between the new node and the original node is created according to the association relationship table.
Further, when the device is retired, the device node corresponding to the device is deleted, and the association relationship between the other device nodes and the device node is deleted.
Further, when the device information changes, the device node attribute information is modified according to the device entity table.
Further, when the association information between the devices changes, the association information between the device nodes is modified according to the association relation table.
Further, the data table information further includes a device record table describing device information, and when the device node is created, the device information in the device record table is written into an image database as an attribute of the device node.
The invention also includes a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method as described above when executing the computer program.
The invention also comprises a storage medium having stored thereon a computer program which, when executed by a processor, implements the method as described above.
The invention has the beneficial effects that: according to the invention, by acquiring the data table information in the relational database, then creating the equipment nodes according to the equipment entity table, the incidence relation table and the main key, searching whether the subsequent equipment exists or not according to the created equipment nodes, judging whether the subsequent equipment has created the equipment nodes or not if the subsequent equipment exists, creating the incidence relation among the nodes if the equipment nodes have been created, creating a new node if the equipment nodes are not created, creating the incidence relation among the nodes, finally generating the equipment nodes from all the equipment information in the relational database in the graph database, and creating the incidence relation among the nodes, the power distribution network topology in the relational database is automatically converted into the graph data in the graph database on the premise that the existing power grid system only can be changed as far as possible, automatic mapping can be completed, and a more efficient and visual database is provided for subsequent incidence analysis, data search and the like.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present invention, and it is also possible for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
FIG. 1 is a flowchart in example 1;
FIG. 2 is a flowchart in example 2;
fig. 3 is a schematic structural diagram of a computer device.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.
Example 1:
as shown in fig. 1: a relational data-to-graph data mapping method, comprising:
acquiring data table information in a relational database, wherein the data table information at least comprises an equipment entity table, an association relation table and a primary key;
traversing the equipment entity table, and sequentially creating equipment nodes in the graph database according to the main key;
searching whether subsequent equipment exists in the association relation table or not according to the equipment nodes;
if the subsequent equipment exists, searching the equipment entity table of the subsequent equipment, and judging whether the equipment node is established in the graph database;
if the equipment node is not created, a new node is created, and the incidence relation among the nodes is created according to the incidence relation table;
and if the equipment nodes are established, establishing the association relationship among the nodes according to the association relationship table.
The method comprises the steps of obtaining data table information in a relational database, then creating equipment nodes according to an equipment entity table, an incidence relation table and a main key, retrieving whether subsequent equipment exists or not according to the created equipment nodes, judging whether the subsequent equipment has created the equipment nodes or not if the subsequent equipment exists, creating incidence relation among the nodes if the equipment nodes are created, creating new nodes if the equipment nodes are not created, creating incidence relation among the nodes, finally generating the equipment nodes from all equipment information in the relational database in a graph database, and creating the incidence relation among the nodes, so that the topology of a power distribution network in the relational database is automatically converted into graph data in the graph database on the premise that only a power grid system in the prior art is not changed as much as possible, automatic mapping can be completed, and a more efficient and visual database is provided for subsequent incidence analysis, data retrieval and the like.
In this embodiment, when data table information in the relational database is obtained, it is determined whether the data table information at least includes an apparatus entity table, an association table, and a primary key;
if not, stopping mapping.
When the data table information in the relational database is acquired, whether the equipment entity table has a single primary key is judged;
if not, stopping mapping.
Because the device nodes and the connection among the nodes are required to be established when the relational database is converted into the graph database, at least a device entity table and an association relation table are required, the device entity table is provided with a single primary key, and if the database of the current power distribution network does not meet the conditions, the mapping is stopped.
In this embodiment, sequentially creating device nodes in the image database by using the device entity table according to the primary key includes:
acquiring a plurality of key values of a primary key corresponding to an equipment entity table;
searching equipment information in the equipment entity table and the association relation table according to the key value;
using the searched equipment information as an equipment nodeiAnd (4) writing the attribute into the image database.
The primary key is a combination of one or more of a value that uniquely identifies a row in a table by which the physical integrity of the table can be enforced, the primary key being used primarily for association with foreign keys of other tables, and modification and deletion of text records. According to the key value of the primary key, searching the equipment information, thereby using the searched equipment information as an equipment node in the graph databaseiAnd (4) writing the attribute into the graph database.
As a preferred embodiment of the foregoing method, searching for device information in the device entity table and the association table according to the key value includes the following steps:
s100: creating key-value pairs { k) from the primary key id of the device entity tablei:viIn which k isiId, v of the ith key value of the primary keyiIs a tag value of an ith key value, and viIs 0;
s110: create set map, put key-value pair { k }i:viAdding the data into the set map;
s120: sequentially traversing key value pairs with the mark value of 0 in the set map, and searching equipment information;
s130: marking value v of traversed key-value pairiHas a value of 1;
s140: judging the mark value v in the set mapiWhether both are 1;
if not, repeating the steps S120 to S130, if yes, finishing the search.
And creating a key value pair through the primary key id, and judging whether equipment corresponding to the key value is created in the graph database or not through a mark value, so that when the key value pair is created, the initial value of the mark value is set to be 0, when the key value pair with the mark value of 0 in the set map is traversed, the equipment information corresponding to the key value pair is searched, an equipment node is created, meanwhile, the mark value of the key value pair is set to be 1, and then the next key value pair with the mark value of 0 is searched until the mark values of all the key value pairs in the set map are all set to be 1.
When searching whether the subsequent equipment exists in the association relation table according to the equipment node, the method comprises the following steps:
s200: upon creation of a device nodeiNode of deviceiThe corresponding key-value pair is ki:1};
S210: node of deviceiAdding the precursor into a precursor queue;
s220: judging whether the precursor queue is empty or not;
s230: if not, taking out the head node of the precursor queuepHead of line nodepThe corresponding primary key value is kp(ii) a If yes, go back to step S140;
s240: searching whether a head node of the queue exists in the association relation tablepThe subsequent device of (1), the subsequent device key value being kjAnd v isjIs 0;
s250: if yes, finding the key value k in the equipment entity tablejApparatus of creating a new nodej(ii) a If not, go back to step S220;
s260: taking the node as a node according to the incidence relation tablepAnd a nodejCreating an incidence relation;
s270: nodejPut into the predecessor queue and return to step S240.
Through the steps, a device node is creatediThen, at this time, the nodeiKey value pair of { k }i:1, the node of the equipment is connectediAdding the queue into a precursor queue, wherein the queue is a special linear table according to the property of the queue, only deleting operation is allowed to be carried out at the front end of the table, inserting operation is carried out at the rear end of the table, the end for carrying out inserting operation is called a tail end of the queue, the end for carrying out deleting operation is called a head of the queue, and the precursor queue is added into a precursor queueIs taken out according to the taken out nodepSearching whether subsequent equipment exists, if the subsequent equipment with a mark value of 0 in the key value pair exists, indicating that the subsequent equipment does not create a node in the graph database, and creating a new node at the momentjAt the same time vjIs set to 1, then to nodepAnd a nodejCreate an association, at which point the node is movedjPut into a predecessor queue and repeatedly search for the nodejAnd is a nodejAnd the subsequent equipment creates the node and the incidence relation until no subsequent equipment exists, the front queue is empty at the moment, then the key value pair with the mark value of 0 in the key value pair in the retrieval set map is returned, and the steps of creating the node, retrieving the subsequent equipment, creating the node of the subsequent equipment and creating the incidence relation are repeated until the mark values of all the key value pairs in the set map are all 1, and then the equipment node corresponding to the equipment entity table, the node of the subsequent equipment and the incidence relation are created.
In this embodiment, the method further includes the following steps:
monitoring whether equipment is changed in a PMS;
and if so, modifying the equipment nodes and/or the association relation according to the equipment entity table and/or the association relation table.
Wherein the device change comprises: any one or more of newly added equipment, equipment retirement, equipment information change and association information change among equipment.
When the equipment is newly added, a new node is created according to the equipment entity table, and the incidence relation between the new node and the original node is created according to the incidence relation table.
And when the equipment is retired, deleting the equipment nodes corresponding to the equipment, and deleting the association relation between the other equipment nodes and the equipment nodes.
And when the equipment information changes, modifying the equipment node attribute information according to the equipment entity table.
And when the association information between the devices changes, modifying the association information between the device nodes according to the association relation table.
After the conversion from the relational database to the graphic database is completed, the condition of equipment change may exist subsequently, at this time, whether the equipment change exists in the PMS system or not can be monitored, and then the equipment change is automatically mapped into the graphic database according to the type of the equipment change.
And when the equipment node is created, writing the equipment information in the equipment record table into an image database as the attribute of the equipment node.
Example 2:
as shown in fig. 2, unlike embodiment 1, the present embodiment includes the following steps:
step 1: the method comprises the steps of defining an equipment entity table for storing basic information of equipment in the power distribution topology network as entityTable, defining an association table for storing connection relations among the equipment as connectionTable, and other equipment record tables for describing the equipment information.
Step 2: whether the power distribution topology network to be converted at least comprises an equipment entity table entityTable and an association relation table, wherein the equipment entity table is provided with a single main key; and if the current power distribution topology network cannot meet the conditions, jumping to the step 15.
And 3, step 3: traversing the device entity table, establishing a key value pair { id:0} according to the primary key id in the table and putting the key value pair into a set map, wherein { id:0} indicates that the device corresponding to the current id does not establish a corresponding node in the graph database.
And 4, step 4: selecting a key value pair k from the map according to the traversal order of the set mapi:viH, if vi=0, record start node primary key as start = kiAnd order vi=1, jump to step 5; otherwise, go to step 4 to reselect the next key-value pair.
And 5: creating a device node in a graph database with a start value as a primary keyiSearching the equipment information with the primary key value as start in the equipment entity table entry and the equipment record table records, and using the searched information as the equipment nodeiWrites the created equipment node into the graph databaseiPutting in a precursor nodeIn queue prenequeue.
Step 6: checking whether a predecessor node queue preNodeQueue is empty, checking a set map if the predecessor node queue preNodeQueue is empty, and jumping to a step 11 if values of all key-value pairs in the set map are 1; if the values of the key-value pairs in the set map are not all 1, then step 4 is skipped.
And 7: if the predecessor node queue prenoQueue is not empty, then the head node in the predecessor node queue prenoQueue is taken outpThe corresponding node primary key is denoted as kp。
And 8: checking the association table connectionTable, if there is a subsequent device connected with the current device, its primary key is kjAnd satisfy vjIf =0, the execution is continued; otherwise, jump to step 6.
And step 9: in graphic database with kjValue-creating device node for primary keyjSearching the primary key value as k in the equipment entity table entityTable and the equipment record table recordTablesjAnd using the searched information as an equipment nodejThe attributes of (2) are written into the graph database.
Step 10: node being a deviceiAnd equipment nodejAn incidence relation is established in a graph database, and the established equipment node isjAnd (4) putting the data into a predecessor node queue prenoQueue, and jumping to the step 8.
Step 11: monitoring the received modification request in the PMS system and jumping to step 12 if the received modification request is a device connection change and to step 14 if the received modification request is a device property change.
Step 12: if the received request is a new device adding request, the device information is obtained from the request and a new node is createdmThe main key is kmThen, the primary key of the predecessor device of the new device is obtained as klSearching node in graph databaselIs a nodelAnd a nodemAnd creating an association relation.
Step 13: if the received request is a device disconnection or device fallbackThe active request obtains the node key k corresponding to the device in the graph database from the requesttRemoving device node in graph databasetAssociation with other device nodes. After this, the process jumps to step 11.
Step 14: node primary key k corresponding to graph database of equipment in slave requestuFinding device node in graph databaseuUpdating device node according to request fielduThe attribute information of (1). After this, the process jumps to step 11.
Step 15: and (4) the automatic conversion from the topology of the power distribution network to the graphic data and the mapping execution fail, and the conversion and the mapping are finished.
According to the invention, by acquiring the data table information in the relational database, then creating the equipment nodes according to the equipment entity table, the incidence relation table and the main key, searching whether the subsequent equipment exists or not according to the created equipment nodes, judging whether the subsequent equipment has created the equipment nodes or not if the subsequent equipment exists, creating the incidence relation among the nodes if the equipment nodes have been created, creating a new node if the equipment nodes are not created, creating the incidence relation among the nodes, finally generating the equipment nodes from all the equipment information in the relational database in the graph database, and creating the incidence relation among the nodes, the power distribution network topology in the relational database is automatically converted into the graph data in the graph database on the premise that the existing power grid system only can be changed as far as possible, automatic mapping can be completed, and a more efficient and visual database is provided for subsequent incidence analysis, data search and the like.
Please refer to fig. 3 for a schematic structural diagram of a computer device provided in the embodiment of the present application. The embodiment of the present application provides a computer device 400, including: a processor 410 and a memory 420, the memory 420 storing a computer program executable by the processor 410, the computer program performing the method as above when executed by the processor 410.
The embodiment of the present application also provides a storage medium 430, where the storage medium 430 stores a computer program, and the computer program is executed by the processor 410 to perform the method as above.
In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. The meaning of "plurality" is two or more unless specifically limited otherwise.
In the present invention, unless otherwise expressly stated or limited, the terms "mounted," "connected," "secured," and the like are to be construed broadly and can, for example, be fixedly connected, detachably connected, or integrally formed; can be mechanically or electrically connected; they may be directly connected or indirectly connected through intervening media, or may be connected through the use of two elements or the interaction of two elements. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
In the description of the specification, reference to the description of "one embodiment," "some embodiments," "an example," "a specific example," or "some examples" or the like means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Moreover, various embodiments or examples and features of various embodiments or examples described in this specification can be combined and combined by one skilled in the art without being mutually inconsistent.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps in the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer cartridge (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (E)PROM or flash memory), fiber optic devices, and portable Compact Disc Read Only Memories (CDROMs). In addition, the computer readable medium may even be such that the program is printable thereonPaper or other suitable medium as the program can be electronically captured, via, for instance, optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: discrete logic circuit with logic gates for implementing logic functions on data signals, application specific integrated circuit with suitable combinational logic gates, programmable gate array: (PGA), field Programmable Gate Array (FPGA), etc.
It will be understood by those skilled in the art that all or part of the steps carried out in the method of implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and the program, when executed, includes one or a combination of the steps of the method embodiments.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are exemplary and not to be construed as limiting the present invention, and that changes, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.
Claims (15)
1. A method for mapping relational data to graph data is characterized by comprising the following steps:
acquiring data table information in a relational database, wherein the data table information at least comprises an equipment entity table, an association relation table and a primary key;
traversing the equipment entity table, and sequentially creating equipment nodes in a graph database according to the main key;
searching whether subsequent equipment exists in the association relation table or not according to the equipment node;
if the subsequent equipment exists, searching the equipment entity table of the subsequent equipment, and judging whether a standby node is established in the graph database;
if the equipment node is not created, a new node is created, and the incidence relation among the nodes is created according to the incidence relation table;
and if the equipment nodes are established, establishing the association relationship among the nodes according to the association relationship table.
2. The method according to claim 1, wherein when obtaining the information of the data tables in the relational database, determining whether the data tables at least include the device entity table, the association table, and the primary key;
if not, stopping mapping.
3. The method according to claim 2, wherein when obtaining the table information in the relational database, determining whether the device entity table has a single primary key;
if not, stopping mapping.
4. The method according to claim 1, wherein the sequentially creating device nodes in the image database according to the primary key by the device entity table comprises:
acquiring a plurality of key values of the primary key corresponding to the equipment entity table;
searching equipment information in the equipment entity table and the association relation table according to the key value;
using the searched equipment information as equipment nodesnode i And (4) writing the attribute into the image database.
5. The method according to claim 4, wherein the step of searching the device information in the device entity table and the association table according to the key value comprises the following steps:
s100: according to the main key of the equipment entity tableidCreating a key value pairk i :v i Therein ofk i Is a main keyiOf individual key valueid,v i Is as followsiA tag value of the individual key value, anv i Is 0;
s110: creating collectionsmapSaid key value pair-k i :v i Add said setmapPerforming the following steps;
s120: sequentially traversing the setmapSearching the device information for the key-value pair with the mark value of 0;
s130: enabling the labeled value of the traversed key-value pairv i The value of (b) is 1;
s140: determining the setmapThe value of the flag in (1)v i Whether both are 1;
if not, repeating the steps S120 to S130, if yes, finishing the search.
6. The method according to claim 5, wherein said retrieving whether a subsequent device exists in said association table according to said device node comprises the steps of:
s200: upon creation of the device nodenode i Said device nodenode i Said corresponding key-value pair is:k i :1};
s210: connecting the equipment nodenode i Adding the precursor into a precursor queue;
s220: judging whether the predecessor queue is empty;
s230: if not, taking out the front partHead node of drive queuenode p Said head of line nodenode p Corresponding primary key value ofk p (ii) a If yes, go back to the step S140;
s240: searching whether the head of line node exists in the incidence relation table or notnode p The subsequent device of (2), the subsequent device key value isk j And is andv j is 0;
s250: if yes, finding a key value ask j Apparatus for creating a new nodenode j (ii) a If not, returning to the step S220;
s260: taking the nodes according to the incidence relation tablenode p Andnode j creating an incidence relation;
s270: the node is connected withnode j Put into the predecessor queue and return to step S240.
7. The relational data-to-graph data mapping method according to any one of claims 1 to 6, further comprising the steps of:
monitoringPMSWhether there is a device change in the system;
and if so, modifying the equipment node and/or the association relation according to the equipment entity table and/or the association relation table.
8. The relational data-to-graph data mapping method according to claim 7, wherein the device change comprises: any one or more of newly added equipment, equipment retirement, equipment information change and association information change among equipment.
9. The method according to claim 8, wherein when a device is newly added, a new node is created according to the device entity table, and an association relationship between the new node and an original node is created according to the association relationship table.
10. The method according to claim 8, wherein when the device is retired, the device node corresponding to the device is deleted, and the association relationship between the remaining device nodes and the device node is deleted.
11. The method according to claim 8, wherein the device node attribute information is modified according to the device entity table when the device information changes.
12. The method according to claim 8, wherein when the association information between the devices changes, the association information between the device nodes is modified according to the association table.
13. The relational data-to-graph data mapping method according to claim 1, wherein the data table information further includes a device record table describing device information, and when the device node is created, the device information in the device record table is written into an image database as an attribute of the device node.
14. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-13 when executing the computer program.
15. A storage medium on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-13.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210891628.XA CN115269745B (en) | 2022-07-27 | 2022-07-27 | Method, equipment and storage medium for mapping relational data to graph data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210891628.XA CN115269745B (en) | 2022-07-27 | 2022-07-27 | Method, equipment and storage medium for mapping relational data to graph data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115269745A true CN115269745A (en) | 2022-11-01 |
CN115269745B CN115269745B (en) | 2023-11-14 |
Family
ID=83770409
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210891628.XA Active CN115269745B (en) | 2022-07-27 | 2022-07-27 | Method, equipment and storage medium for mapping relational data to graph data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115269745B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116991892A (en) * | 2023-07-08 | 2023-11-03 | 上海螣龙科技有限公司 | Network asset data query method, system, equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140258533A1 (en) * | 2013-03-06 | 2014-09-11 | Vmware, Inc. | Method and System for Providing a Roaming Remote Desktop |
CN104123369A (en) * | 2014-07-24 | 2014-10-29 | 中国移动通信集团广东有限公司 | CMDB system based on graphic data base and implementation method |
CN109597855A (en) * | 2018-11-29 | 2019-04-09 | 北京邮电大学 | Domain knowledge map construction method and system based on big data driving |
CN109684418A (en) * | 2018-11-22 | 2019-04-26 | 全球能源互联网研究院有限公司 | Date storage method and device based on power grid chart database |
CN113220659A (en) * | 2021-04-08 | 2021-08-06 | 杭州费尔斯通科技有限公司 | Data migration method, system, electronic device and storage medium |
-
2022
- 2022-07-27 CN CN202210891628.XA patent/CN115269745B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140258533A1 (en) * | 2013-03-06 | 2014-09-11 | Vmware, Inc. | Method and System for Providing a Roaming Remote Desktop |
CN104123369A (en) * | 2014-07-24 | 2014-10-29 | 中国移动通信集团广东有限公司 | CMDB system based on graphic data base and implementation method |
CN109684418A (en) * | 2018-11-22 | 2019-04-26 | 全球能源互联网研究院有限公司 | Date storage method and device based on power grid chart database |
CN109597855A (en) * | 2018-11-29 | 2019-04-09 | 北京邮电大学 | Domain knowledge map construction method and system based on big data driving |
CN113220659A (en) * | 2021-04-08 | 2021-08-06 | 杭州费尔斯通科技有限公司 | Data migration method, system, electronic device and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116991892A (en) * | 2023-07-08 | 2023-11-03 | 上海螣龙科技有限公司 | Network asset data query method, system, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115269745B (en) | 2023-11-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107704203A (en) | It polymerize delet method, device, equipment and the computer-readable storage medium of big file | |
CN115840543B (en) | Data hierarchical storage method, device, equipment and storage medium | |
CN108614837A (en) | File stores and the method and device of retrieval | |
CN115269745B (en) | Method, equipment and storage medium for mapping relational data to graph data | |
CN109766318A (en) | File reading and device | |
KR100442991B1 (en) | Searching device using moving picture index descripter and method thereof | |
US8548980B2 (en) | Accelerating queries based on exact knowledge of specific rows satisfying local conditions | |
CN109189343B (en) | Metadata disk-dropping method, device, equipment and computer-readable storage medium | |
CN112000971B (en) | File permission recording method, system and related device | |
CN111752941B (en) | Data storage and access method and device, server and storage medium | |
CN112463734A (en) | File retrieval method, system and related device | |
CN117194907A (en) | Low-value data theme identification method for data center | |
CN115878625A (en) | Data processing method and device and electronic equipment | |
CN112307272B (en) | Method, device, computing equipment and storage medium for determining relation information between objects | |
CN110262755A (en) | A kind of file memory method of embedded system | |
CN115391355A (en) | Data processing method, device, equipment and storage medium | |
CN115454947A (en) | Method, device and equipment for storing unstructured data and storage medium | |
CN116414733B (en) | Data processing method, device, computer equipment and storage medium | |
CN117252160B (en) | Document editing method, device, equipment and medium | |
CN115374127B (en) | Data storage method and device | |
CN110019987A (en) | A kind of log matches method and apparatus based on decision tree | |
CN117131048A (en) | Data access method, device, computer equipment and storage medium | |
CN117851341A (en) | Metadata indexing method, apparatus, computer device and storage medium | |
CN117112559A (en) | Method, apparatus, device and medium for managing vector data sets | |
CN115168296A (en) | Method and device for splitting network element back calculation data |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |