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 PDF

Info

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
node
data
information
key
created
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
Application number
CN202210891628.XA
Other languages
Chinese (zh)
Other versions
CN115269745B (en
Inventor
苏伟
肖小龙
史明明
杨景刚
袁晓冬
孙健
杨雄
郭佳豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
State Grid Jiangsu Electric Power Co Ltd
Electric Power Research Institute of State Grid Jiangsu Electric Power Co Ltd
Original Assignee
State Grid Jiangsu Electric Power Co Ltd
Electric Power Research Institute of State Grid Jiangsu Electric Power Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by State Grid Jiangsu Electric Power Co Ltd, Electric Power Research Institute of State Grid Jiangsu Electric Power Co Ltd filed Critical State Grid Jiangsu Electric Power Co Ltd
Priority to CN202210891628.XA priority Critical patent/CN115269745B/en
Publication of CN115269745A publication Critical patent/CN115269745A/en
Application granted granted Critical
Publication of CN115269745B publication Critical patent/CN115269745B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; 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

一种关系型数据至图数据映射方法、设备及存储介质Method, device and storage medium for mapping relational data to graph data

技术领域technical field

本发明涉及数据处理技术领域,尤其涉及一种关系型数据至图数据映射方法、设备及存储介质。The present invention relates to the technical field of data processing, in particular to a method, device and storage medium for mapping relational data to graph data.

背景技术Background technique

随着物联网技术的高速发展,电网的智能化也已经逐步普及,智能电网以高速稳定的双向通信网络为发展基础,将高效的控制方式、决策策略和设备技术相融合,最终形成以现金的传感技术和测量技术为核心的电网应用。智能电网是互联网技术和传统电力技术共同发展的产物,其目标是满足电力系统的智能化管理和高效运维,并为用户提供良好的电力服务。但是随着智能电网技术的持续发展,广泛分布的智能终端产生了海量的数据,海量数据如何存储和分析成为了智能电网进一步发展的难题。With the rapid development of the Internet of Things technology, the intelligence of the power grid has gradually become popular. Based on the development of a high-speed and stable two-way communication network, the smart grid integrates efficient control methods, decision-making strategies and equipment technologies, and finally forms a cash-based transmission system. Power grid applications with sensing technology and measurement technology as the core. The smart grid is the product of the joint development of Internet technology and traditional power technology. Its goal is to meet the intelligent management and efficient operation and maintenance of the power system, and to provide users with good power services. However, with the continuous development of smart grid technology, widely distributed smart terminals generate massive data, how to store and analyze massive data has become a difficult problem for the further development of smart grid.

在现有的智能电网系统中主要采用关系型数据库来存储智能终端采集的数据和用户数据,但是关系型数据在数据量很大的情况下,对于数据的搜索响应时间会很长,一般数据库系统主要涉及增、删、改、查四种基本操作,对于数据的查找和搜索,关系型数据库需要进行大量的连接和遍历操作,不仅复杂还非常耗时。In existing smart grid systems, relational databases are mainly used to store data collected by smart terminals and user data. However, when relational data has a large amount of data, the search response time for data will be very long. General database systems It mainly involves the four basic operations of adding, deleting, modifying, and searching. For data search and search, relational databases require a large number of connection and traversal operations, which are not only complicated but also time-consuming.

图形数据库对于连接操作可以利用免索引邻接特性实现无关于数据规模的查询功能,图形数据库可以有助于存储海量高关联度的数据,针对关系进行复杂的分析,为发掘数据关联关系和电网创新提供了巨大的潜力。现有的智能电网系统和其他电网管理系统的存储结构设计都是基于关系型数据库的,虽然关系型数据库发展的相对成熟,但是关系型数据库并不适合具有高关联度数据的存储,因此亟需一种将关系型数据库中配电网数据自动转化为图形数据库中数据的方法。For connection operations, the graph database can use the index-free adjacency feature to realize the query function independent of the data scale. The graph database can help store a large amount of high-relationship data, conduct complex analysis on the relationship, and provide data for the discovery of data correlation and power grid innovation. huge potential. The storage structure design of existing smart grid systems and other power grid management systems is based on relational databases. Although the development of relational databases is relatively mature, relational databases are not suitable for the storage of highly correlated data. Therefore, there is an urgent need for A method for automatically converting distribution network data in a relational database into data in a graph database.

公开于该背景技术部分的信息仅仅旨在加深对本发明的总体背景技术的理解,而不应当被视为承认或以任何形式暗示该信息构成已为本领域技术人员所公知的现有技术。The information disclosed in this Background section is only intended to enhance the understanding of the general background of the present invention, and should not be considered as an acknowledgment or any form of suggestion that the information constitutes the prior art that is already known to those skilled in the art.

发明内容Contents of the invention

本发明提供了一种关系型数据至图数据映射方法、设备及存储介质,从而有效解决背景技术中的问题。The present invention provides a method, device and storage medium for mapping relational data to graph data, thereby effectively solving the problems in the background technology.

为了达到上述目的,本发明所采用的技术方案是:一种关系型数据至图数据映射方法,包括如下步骤:In order to achieve the above object, the technical solution adopted in the present invention is: a method for mapping relational data to graph data, comprising the following steps:

获取关系型数据库中数据表信息,所述数据表信息至少包括设备实体表、关联关系表和主键;Obtain data table information in a relational database, where the data table information at least includes a device entity table, an association table and a primary key;

遍历所述设备实体表,根据所述主键将所述设备实体表依次在图形数据库中创建设备节点;Traversing the device entity table, creating device nodes in the graph database sequentially from the device entity table according to the primary key;

根据所述设备节点,检索所述关联关系表中是否存在后继设备;Retrieving whether there is a successor device in the association table according to the device node;

若存在后继设备,检索后续设备的所述设备实体表,判断是否已在图形数据库中创建设备节点;If there is a subsequent device, retrieve the device entity table of the subsequent device, and determine whether the device node has been created in the graph database;

若未创建设备节点,则创建新节点,并根据所述关联关系表,创建节点间的关联关系;If no device node is created, a new node is created, and an association relationship between nodes is created according to the association relationship table;

若已创建设备节点,则根据所述关联关系表,创建节点间的关联关系。If the device nodes have been created, an association relationship between nodes is created according to the association relationship table.

进一步地,所述获取关系型数据库中数据表信息时,判断是否至少包含所述设备实体表、关联关系表和主键;Further, when acquiring data table information in a relational database, it is judged whether at least the device entity table, association table and primary key are included;

若否,则停止映射。If not, stop mapping.

进一步地,所述获取关系型数据库中数据表信息时,判断所述设备实体表是否具有单个主键;Further, when acquiring data table information in a relational database, it is judged whether the device entity table has a single primary key;

若否,则停止映射。If not, stop mapping.

进一步地,所述根据所述主键将所述设备实体表依次在图像数据库中创建设备节点,包括:Further, the step of sequentially creating device nodes in the image database from the device entity table according to the primary key includes:

获取所述设备实体表对应主键的若干键值;Obtain several key values corresponding to the primary key of the device entity table;

依据所述键值在所述设备实体表和所述关联关系表中查找设备信息;Searching for device information in the device entity table and the association relationship table according to the key value;

将查找到的所述设备信息作为设备节点nodei的属性,写入图像数据库中。The found device information is written into the image database as an attribute of the device node node i .

进一步地,所述依据所述键值在所述设备实体表和所述关联关系表中查找设备信息,包括如下步骤:Further, the searching for device information in the device entity table and the association relationship table according to the key value includes the following steps:

S100:根据所述设备实体表的主键id,创建键值对{ki:vi},其中ki为主键第i个键值的id,vi为第i个键值的标记值,且vi的初始值为0;S100: Create a key-value pair {k i : v i } according to the primary key id of the device entity table, where k i is the id of the i-th key value of the primary key, and v i is the tag value of the i-th key value, and The initial value of v i is 0;

S110:创建集合map,将所述键值对{ki:vi}加入所述集合map中;S110: Create a collection map, and add the key-value pair {k i : v i } to the collection map;

S120:依次遍历所述集合map中所述标记值为0的所述键值对,查找所述设备信息;S120: traversing the key-value pairs whose tag values are 0 in the set map in sequence, and searching for the device information;

S130:令遍历的所述键值对的所述标记值vi的值为1;S130: Set the value of the tag value v i of the traversed key-value pair to 1;

S140:判断所述集合map中的所述标记值vi是否都为1;S140: judging whether the tag values v i in the set map are all 1;

若否,则重复所述步骤S120至S130,若是,则完成查找。If not, repeat steps S120 to S130, and if yes, complete the search.

进一步地,所述根据所述设备节点,检索所述关联关系表中是否存在后继设备时,包括如下步骤:Further, according to the device node, when retrieving whether there is a successor device in the association relationship table, the following steps are included:

S200:依据创建的所述设备节点nodei,所述设备节点nodei对应的所述键值对为{ki:1};S200: According to the created device node node i , the key-value pair corresponding to the device node node i is {k i : 1};

S210:将所述设备节点nodei加入前驱队列中;S210: Add the device node node i to the precursor queue;

S220:判断所述前驱队列是否为空;S220: Determine whether the precursor queue is empty;

S230:若否,则取出所述前驱队列的队首节点nodep,所述队首节点nodep对应的主键键值为kp;若是,则回到所述步骤S140;S230: If not, take out the head node node p of the precursor queue, and the primary key value corresponding to the head node node p is kp ; if so, return to the step S140;

S240:检索所述关联关系表中是否存在所述队首节点nodep的后续设备,所述后续设备键值为kj,且vj为0;S240: Retrieve whether there is a follow-up device of the head node node p in the association table, the key value of the follow-up device is k j , and v j is 0;

S250:若是,则在所述设备实体表中找到键值为kj的设备,创建新节点nodej;若否,则回到所述步骤S220;S250: If yes, then find the device whose key value is k j in the device entity table, and create a new node node j ; if not, return to the step S220;

S260:根据所述关联关系表为节点nodep和nodej创建关联关系;S260: Create an association relationship for nodes node p and node j according to the association relationship table;

S270:将所述节点nodej放入所述前驱队列中,并回到所述步骤S240。S270: Put the node node j into the precursor queue, and return to the step S240.

进一步地,还包括如下步骤:Further, the following steps are also included:

监测PMS系统中是否有设备变更;Monitor whether there is equipment change in the PMS system;

若是,则根据所述设备实体表和/或所述关联关系表,对所述设备节点和/或关联关系进行修改。If so, modify the device node and/or the association relationship according to the device entity table and/or the association relationship table.

进一步地,所述设备变更包括:新增设备、设备退役、设备信息变化、设备间的关联信息变化中的任意一种或多种。Further, the device change includes any one or more of: adding new devices, decommissioning devices, changing device information, and changing related information between devices.

进一步地,所述新增设备时,根据所述设备实体表,创建新节点,根据所述关联关系表,创建所述新节点与原节点的关联关系。Further, when adding a device, 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.

进一步地,所述设备退役时,删除设备对应的所述设备节点,将其余设备节点与所述设备节点间的关联关系删除。Further, when the device is decommissioned, the device node corresponding to the device is deleted, and the association relationship between 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 relationship table.

进一步地,所述数据表信息还包括描述设备信息的设备记录表,在创建所述设备节点时,将所述设备记录表中设备信息作为所述设备节点的属性,写入到图像数据库中。Further, the data table information also includes a device record table describing device information, and when creating the device node, the device information in the device record table is written into the image database as an attribute of the device node.

本发明中还包括一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现如上述的方法。The present invention also includes a computer device, including a memory, a processor, and a computer program stored in the memory and operable on the processor. When the processor executes the computer program, the above method is realized.

本发明中还包括一种存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述的方法。The present invention also includes a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above method is realized.

本发明的有益效果为:本发明通过获取关系型数据库中数据表信息,然后根据设备实体表、关联关系表和主键,创建设备节点,依据已创建的设备节点,检索是否存在后继设备,若存在后继设备,则判断这个后继设备是否已创建设备节点,如果已创建设备节点,则创建节点间的关联关系,如果没有创建设备节点,则创建新节点,再创建节间的关联关系,最终将关系型数据库中的所有设备信息在图形数据库中生成设备节点,节点与节点间创建关联关系,从而在尽可能不更改现有只能电网系统的前提下,将关系型数据库中的配电网拓扑自动转化为图形数据库中的图形数据,并且能够完成自动映射,为后续关联分析、数据检索等提供了更高效直观的数据库。The beneficial effects of the present invention are as follows: the present invention obtains the data table information in the relational database, then creates a device node according to the device entity table, the association relationship table and the primary key, and searches whether there is a successor device based on the created device node. For the successor device, it is judged whether the device node has been created for the successor device. If the device node has been created, the association relationship between the nodes is created. If the device node is not created, a new node is created, and the association relationship between the nodes is created. All equipment information in the database will generate equipment nodes in the graph database, and an association relationship will be created between nodes, so that the topology of the distribution network in the relational database can be automatically integrated under the premise of not changing the existing smart grid system as much as possible. It can be transformed into graphic data in a graphic database, and can complete automatic mapping, providing a more efficient and intuitive database for subsequent correlation analysis, data retrieval, etc.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments described in the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.

图1为实施例1中的流程图;Fig. 1 is the flowchart in embodiment 1;

图2为实施例2中的流程图;Fig. 2 is the flowchart in embodiment 2;

图3为计算机设备的结构示意图。Fig. 3 is a schematic structural diagram of a computer device.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention.

实施例1:Example 1:

如图1所示:一种关系型数据至图数据映射方法,包括:As shown in Figure 1: a method for mapping relational data to graph data, including:

获取关系型数据库中数据表信息,数据表信息至少包括设备实体表、关联关系表和主键;Obtain the data table information in the relational database, the data table information includes at least the equipment entity table, the association table and the primary key;

遍历设备实体表,根据主键将设备实体表依次在图形数据库中创建设备节点;Traversing the equipment entity table, according to the primary key, the equipment entity table is sequentially created in the graph database to create equipment nodes;

根据设备节点,检索关联关系表中是否存在后继设备;According to the device node, retrieve whether there is a successor device in the association table;

若存在后继设备,检索后续设备的设备实体表,判断是否已在图形数据库中创建设备节点;If there is a subsequent device, retrieve the device entity table of the subsequent device to determine whether the device node has been created in the graph database;

若未创建设备节点,则创建新节点,并根据关联关系表,创建节点间的关联关系;If no device node is created, create a new node, and create an association relationship between nodes according to the association relationship table;

若已创建设备节点,则根据关联关系表,创建节点间的关联关系。If the device node has been created, create an association relationship between nodes according to the association relationship table.

通过获取关系型数据库中数据表信息,然后根据设备实体表、关联关系表和主键,创建设备节点,依据已创建的设备节点,检索是否存在后继设备,若存在后继设备,则判断这个后继设备是否已创建设备节点,如果已创建设备节点,则创建节点间的关联关系,如果没有创建设备节点,则创建新节点,再创建节间的关联关系,最终将关系型数据库中的所有设备信息在图形数据库中生成设备节点,节点与节点间创建关联关系,从而在尽可能不更改现有只能电网系统的前提下,将关系型数据库中的配电网拓扑自动转化为图形数据库中的图形数据,并且能够完成自动映射,为后续关联分析、数据检索等提供了更高效直观的数据库。Obtain the data table information in the relational database, and then create a device node based on the device entity table, association relationship table and primary key, and retrieve whether there is a successor device based on the created device node. If there is a successor device, judge whether the successor device is The device node has been created. If the device node has been created, the association relationship between the nodes will be created. If the device node has not been created, a new node will be created, and then the inter-node association relationship will be created. Finally, all the equipment information in the relational database will be displayed on the graph Device nodes are generated in the database, and association relationships are created between nodes, so that the distribution network topology in the relational database is automatically converted into graph data in the graph database without changing the existing smart grid system as much as possible. And it can complete automatic mapping, providing a more efficient and intuitive database for subsequent correlation analysis and data retrieval.

在本实施例中,获取关系型数据库中数据表信息时,判断是否至少包含设备实体表、关联关系表和主键;In this embodiment, when obtaining the data table information in the relational database, it is judged whether at least the equipment entity table, the association table and the primary key are included;

若否,则停止映射。If not, stop mapping.

其中,获取关系型数据库中数据表信息时,判断设备实体表是否具有单个主键;Among them, when obtaining the data table information in the relational database, it is judged whether the equipment entity table has a single primary key;

若否,则停止映射。If not, stop mapping.

由于在将关系型数据库转化到图形数据库时,需要创建设备节点以及节点间的联系,所以至少需要设备实体表、关联关系表,且设备实体表具有单个主键,如果当前配电网的数据库不满足这些条件,则停止映射。When converting a relational database to a graph database, it is necessary to create equipment nodes and connections between nodes, so at least equipment entity tables and association relationship tables are required, and the equipment entity tables have a single primary key. If the current distribution network database does not satisfy These conditions stop mapping.

在本实施例中,根据主键将设备实体表依次在图像数据库中创建设备节点,包括:In this embodiment, according to the primary key, the device entity table is sequentially created in the image database to create device nodes, including:

获取设备实体表对应主键的若干键值;Obtain several key values corresponding to the primary key of the device entity table;

依据键值在设备实体表和关联关系表中查找设备信息;Find device information in the device entity table and association table according to the key value;

将查找到的设备信息作为设备节点nodei的属性,写入图像数据库中。Write the found device information into the image database as the attribute of the device node node i .

主键是一个或多个的组合,其值能唯一地标识表中的某一行,通过它可以强制表的实体完整性,主键主要是用与其他表的外键关联,以及文本记录的修改与删除。依据主键的键值,去查找设备信息,从而将查找到的设备信息作为图形数据库中的一个设备节点nodei的属性,将其写入图形数据库中。The primary key is a combination of one or more, whose value can uniquely identify a certain row in the table, through which the entity integrity of the table can be enforced, the primary key is mainly used to associate with foreign keys of other tables, and to modify and delete text records . According to the key value of the primary key, the device information is searched, so that the found device information is used as an attribute of a device node node i in the graph database, and written into the graph database.

作为上述实施例的优选,依据键值在设备实体表和关联关系表中查找设备信息,包括如下步骤:As a preferred embodiment of the foregoing, searching for device information in the device entity table and the association table according to the key value includes the following steps:

S100:根据设备实体表的主键id,创建键值对{ki:vi},其中ki为主键第i个键值的id,vi为第i个键值的标记值,且vi的初始值为0;S100: According to the primary key id of the device entity table, create a key-value pair {k i : v i }, where k i is the id of the i-th key value of the primary key, v i is the tag value of the i-th key value, and v i The initial value of is 0;

S110:创建集合map,将键值对{ki:vi}加入集合map中;S110: Create a collection map, and add the key-value pair {k i : v i } to the collection map;

S120:依次遍历集合map中标记值为0的键值对,查找设备信息;S120: traversing the key-value pairs with a tag value of 0 in the collection map in turn to find device information;

S130:令遍历的键值对的标记值vi的值为1;S130: Let the value of the tag value v i of the traversed key-value pair be 1;

S140:判断集合map中的标记值vi是否都为1;S140: Determine whether the tag values v i in the set map are all 1;

若否,则重复步骤S120至S130,若是,则完成查找。If not, repeat steps S120 to S130, and if yes, complete the search.

通过主键id创建键值对,通过标记值来判断这个键值对应的设备是否已在图形数据库中进行创建,所以在创建键值对时,将标记值的初始值都设为0,在遍历集合map中标记值为0的键值对时,将那个键值对对应的设备信息进行查找,再建立设备节点,同时,将这个键值对的标记值置为1,然后再查找下一个标记值为0的键值对,直至集合map中所有键值对的标记值都为1。Create a key-value pair through the primary key id, and use the tag value to judge whether the device corresponding to the key value has been created in the graph database, so when creating a key-value pair, set the initial value of the tag value to 0, and traverse the collection When a key-value pair with a mark value of 0 is found in the map, search for the corresponding device information of that key-value pair, and then create a device node. At the same time, set the mark value of this key-value pair to 1, and then search for the next mark value The key-value pairs of 0 until the tag values of all key-value pairs in the collection map are 1.

其中,根据设备节点,检索关联关系表中是否存在后继设备时,包括如下步骤:Among them, according to the device node, when retrieving whether there is a successor device in the association relationship table, the following steps are included:

S200:依据创建的设备节点nodei,设备节点nodei对应的键值对为{ki:1};S200: According to the created device node node i , the key-value pair corresponding to the device node node i is {k i : 1};

S210:将设备节点nodei加入前驱队列中;S210: adding the device node node i to the precursor queue;

S220:判断前驱队列是否为空;S220: Determine whether the precursor queue is empty;

S230:若否,则取出前驱队列的队首节点nodep,队首节点nodep对应的主键键值为kp;若是,则回到步骤S140;S230: If not, take out the leader node node p of the precursor queue, and the primary key value corresponding to the leader node node p is kp ; if yes, return to step S140;

S240:检索关联关系表中是否存在队首节点nodep的后续设备,后续设备键值为kj,且vj为0;S240: Retrieve whether there is a follow-up device of the head node node p in the association table, the key value of the follow-up device is k j , and v j is 0;

S250:若是,则在设备实体表中找到键值为kj的设备,创建新节点nodej;若否,则回到步骤S220;S250: If yes, find the device whose key value is k j in the device entity table, and create a new node node j ; if not, return to step S220;

S260:根据关联关系表为节点nodep和nodej创建关联关系;S260: Create an association relationship for node p and node j according to the association relationship table;

S270:将节点nodej放入前驱队列中,并回到步骤S240。S270: put the node node j into the precursor queue, and return to step S240.

通过上述步骤,在已创建出一个设备节点nodei后,此时nodei的键值对为{ki:1},将这个设备节点nodei加入前驱队列中,依据队列的性质,队列是一种特殊的线性表,只允许在表的前端进行删除操作,表的后端进行插入操作,进行插入操作的端称为队尾,进行删除操作的端称为队头,将前驱队列的队首取出,依照取出的节点nodep检索是否存在后续设备,如果存在键值对中标记值为0的后续设备,则说明这个后续设备还未在图形数据库中创建设备节点,此时创建新节点nodej,同时将vj置为1,再为nodep和nodej创建关联关系,此时,将nodej放入前驱队列中,重复检索nodej的后续设备及为nodej的后续设备创建节点和关联关系,直到没有后续设备,此时前驱队列为空,再回到检索集合map中键值对中标记值为0的键值对,再重复创建节点、检索后续设备、创建后续设备的节点、创建关联关系的步骤,直到集合map中所有键值对的标记值都为1,则这个设备实体表所对应的设备节点、后续设备的节点和关联关系都已创建完成。Through the above steps, after a device node i has been created, the key-value pair of node i is {k i : 1}, and this device node node i is added to the precursor queue. According to the nature of the queue, the queue is a A special linear table that only allows deletion operations at the front end of the table, and insertion operations at the back end of the table. The end of the insertion operation is called the tail of the queue, and the end of the deletion operation is called the head of the queue. Take it out, and search whether there is a follow-up device according to the taken-out node node p . If there is a follow-up device with a value of 0 in the key-value pair, it means that the follow-up device has not yet created a device node in the graph database. At this time, create a new node node j , and set v j to 1 at the same time, and then create an association relationship between node p and node j . At this time, put node j into the precursor queue, repeatedly retrieve the subsequent devices of node j and create nodes and associations for the subsequent devices of node j relationship, until there is no follow-up device, at this time the precursor queue is empty, and then return to the key-value pair whose tag value is 0 in the key-value pair in the search set map, and then repeatedly create nodes, retrieve follow-up devices, create nodes of follow-up devices, and create In the step of association relationship, until the flag value of all key-value pairs in the set map is 1, then the device node corresponding to the device entity table, the node of the subsequent device, and the association relationship have been created.

在本实施例中,还包括如下步骤:In this embodiment, the following steps are also included:

监测PMS系统中是否有设备变更;Monitor whether there is equipment change in the PMS system;

若是,则根据设备实体表和/或关联关系表,对设备节点和/或关联关系进行修改。If yes, modify the device node and/or the association relationship according to the device entity table and/or the association relationship table.

其中,设备变更包括:新增设备、设备退役、设备信息变化、设备间的关联信息变化中的任意一种或多种。Wherein, the equipment change includes: any one or more of new equipment, decommissioning of equipment, change of equipment information, and change of associated information between equipment.

新增设备时,根据设备实体表,创建新节点,根据关联关系表,创建新节点与原节点的关联关系。When adding new equipment, create a new node according to the equipment entity table, and create an association relationship between the new node and the original node according to the association relationship table.

设备退役时,删除设备对应的设备节点,将其余设备节点与设备节点间的关联关系删除。When a device is decommissioned, delete the device node corresponding to the device, and delete the association relationship between other device nodes and device nodes.

设备信息变化时,根据设备实体表,对设备节点属性信息进行修改。When the device information changes, modify the device node attribute information according to the device entity table.

设备间的关联信息变化时,根据关联关系表,将设备节点间的关联信息进行修改。When the association information between devices changes, the association information between device nodes is modified according to the association relationship table.

在将关系型数据库到图形数据库转化完成后,后续可能存在设备变更的情况,此时可以监测PMS系统中是否有设备变更,然后再根据设备变更的类型,自动映射到图形数据库中。After the transformation from the relational database to the graph database is completed, there may be subsequent device changes. At this time, it is possible to monitor whether there is a device change in the PMS system, and then automatically map to the graph database according to the type of device change.

其中,数据表信息还包括描述设备信息的设备记录表,在创建设备节点时,将设备记录表中设备信息作为设备节点的属性,写入到图像数据库中。Wherein, the data table information also includes a device record table describing device information. When creating a device node, the device information in the device record table is used as an attribute of the device node and written into the image database.

实施例2:Example 2:

如图2所示,与实施例1不同的是,在本实施例中,包括如下步骤:As shown in Figure 2, different from Embodiment 1, in this embodiment, the following steps are included:

步骤1:定义存储配电拓扑网中设备基本信息的设备实体表为entityTable,定义存储设备间连接关系的关联关系表为connectionTable,以及其他描述设备信息的设备记录表recordTables。Step 1: Define the device entity table that stores the basic information of the devices in the power distribution topology network as entityTable, define the association relationship table that stores the connection relationship between devices as connectionTable, and other device record tables recordTables that describe device information.

步骤2:待转化的配电拓扑网是否至少包含设备实体表entityTable和关联关系表connectionTable,且设备实体表具有单个主键;如果当前配电拓扑网不能满足上述条件则跳转到步骤15。Step 2: Whether the power distribution topology network to be converted contains at least the equipment entity table entityTable and the association relationship table connectionTable, and the equipment entity table has a single primary key; if the current power distribution topology network cannot meet the above conditions, skip to step 15.

步骤3:遍历设备实体表,根据表中的主键id建立键值对{id:0}并放入集合map中,其中{id:0}表示当前id对应的设备还未再图形数据库中建立对应节点。Step 3: Traverse the device entity table, create a key-value pair {id:0} according to the primary key id in the table and put it into the collection map, where {id:0} means that the device corresponding to the current id has not yet established a correspondence in the graph database node.

步骤4:按照集合map的遍历顺序从map中选择一个键值对{ki:vi},如果vi=0,记录起始节点主键为start=ki,并令vi=1,跳转到步骤5;否则跳转到步骤4重新选择下一个键值对。Step 4: Select a key-value pair {k i :v i } from the map according to the traversal order of the set map, if v i =0, record the primary key of the starting node as start=k i , and set v i =1, skip Go to step 5; otherwise, skip to step 4 to reselect the next key-value pair.

步骤5:在图形数据库中以start值为主键创建设备节点nodei,在设备实体表entityTable和设备记录表recordTables中查找主键值为start的设备信息,并将查找到的信息作为设备节点nodei的属性写入到图形数据库中,将创建完成的设备节点nodei放入前驱节点队列preNodeQueue中。Step 5: Create a device node node i in the graph database with the start value as the primary key, search for the device information whose primary key value is start in the device entity table entityTable and device record table recordTables, and use the found information as the device node node i Attributes are written into the graph database, and the created device node node i is put into the precursor node queue preNodeQueue.

步骤6:检查前驱节点队列preNodeQueue是否为空,如果前驱节点队列preNodeQueue为空则检查集合map,如果集合map中所有键值对的值都为1则跳转到步骤11;如果集合map中键值对的值不全为1则跳转到步骤4。Step 6: Check whether the precursor node queue preNodeQueue is empty, if the precursor node queue preNodeQueue is empty, check the set map, if the value of all key-value pairs in the set map is 1, then jump to step 11; if the key value in the set map If the value of the pair is not all 1, skip to step 4.

步骤7:如果前驱节点队列preNodeQueue不为空,则取出前驱节点队列preNodeQueue中的队首节点nodep,对应的节点主键记为kpStep 7: If the precursor node queue preNodeQueue is not empty, take out the head node node p in the precursor node queue preNodeQueue, and record the corresponding node primary key as k p .

步骤8:检查关联关系表connectionTable,如果存在与当前设备连接的后继设备,其主键为kj,且满足vj=0,则继续执行;否则跳转到步骤6。Step 8: Check the association table connectionTable, if there is a successor device connected to the current device, its primary key is k j and satisfies v j =0, continue to execute; otherwise, skip to step 6.

步骤9:在图形数据库中以kj值为主键创建设备节点nodej,在设备实体表entityTable和设备记录表recordTables中查找主键值为kj的设备信息,并将查找到的信息作为设备节点nodej的属性写入到图形数据库中。Step 9: Create a device node node j in the graph database with the value of k j as the primary key, look up the device information with the primary key value of k j in the device entity table entityTable and device record table recordTables, and use the found information as the device node The attributes of node j are written into the graph database.

步骤10:为设备节点nodei和设备节点nodej在图形数据库中创建关联关系,将创建完成的设备节点nodej放入前驱节点队列preNodeQueue中,跳转到步骤8。Step 10: Create an association relationship between device node i and device node j in the graph database, put the created device node node j into the precursor node queue preNodeQueue, and skip to step 8.

步骤11:监测PMS系统中收到的修改请求,如果收到的修改请求是设备连接变更则跳转到步骤12,如果收到的修改请求是设备属性变更则跳转到步骤14。Step 11: Monitor the modification request received in the PMS system, if the received modification request is a device connection change, then go to step 12, if the received modification request is a device attribute change, then go to step 14.

步骤12:如果收到的请求是新增设备请求则从请求中获取设备信息并创建新节点nodem,主键为km然后获取新设备的前驱设备的主键为kl,在图数据库中查找节点nodel,为节点nodel和nodem创建关联关系。Step 12: If the received request is a new device request, obtain the device information from the request and create a new node node m , the primary key is k m , then obtain the primary key of the precursor device of the new device as k l , and search for the node in the graph database node l , create an association relationship between node node l and node m .

步骤13:如果收到的请求是设备断开或设备退役请求则从请求中获取设备在图数据库中对应的节点主键kt,在图数据库中移除设备节点nodet与其他设备节点的关联关系。完成后跳转到步骤11.Step 13: If the received request is a device disconnection or device decommissioning request, obtain the node primary key k t corresponding to the device in the graph database from the request, and remove the association between the device node node t and other device nodes in the graph database . Skip to step 11 when done.

步骤14:从请求中设备在图数据库对应的节点主键ku,在图数据库中找到设备节点nodeu,根据请求字段更新设备节点nodeu的属性信息。完成后跳转到步骤11。Step 14: From the node primary key k u corresponding to the device in the graph database in the request, find the device node node u in the graph database, and update the attribute information of the device node node u according to the request field. Skip to step 11 when done.

步骤15:配电网拓扑到图形数据自动转化及映射执行失败,结束转换与映射。Step 15: The automatic conversion and mapping from distribution network topology to graphic data fails, and the conversion and mapping end.

本发明通过获取关系型数据库中数据表信息,然后根据设备实体表、关联关系表和主键,创建设备节点,依据已创建的设备节点,检索是否存在后继设备,若存在后继设备,则判断这个后继设备是否已创建设备节点,如果已创建设备节点,则创建节点间的关联关系,如果没有创建设备节点,则创建新节点,再创建节间的关联关系,最终将关系型数据库中的所有设备信息在图形数据库中生成设备节点,节点与节点间创建关联关系,从而在尽可能不更改现有只能电网系统的前提下,将关系型数据库中的配电网拓扑自动转化为图形数据库中的图形数据,并且能够完成自动映射,为后续关联分析、数据检索等提供了更高效直观的数据库。The present invention obtains the data table information in the relational database, then creates a device node according to the device entity table, the association relationship table and the primary key, and searches whether there is a successor device based on the created device node, and if there is a successor device, then judges the successor device Whether the device has created a device node, if the device node has been created, create an association between nodes, if not, create a new node, and then create an inter-node association, and finally all the device information in the relational database Device nodes are generated in the graph database, and association relationships are created between nodes, so that the distribution network topology in the relational database is automatically converted into a graph in the graph database without changing the existing smart grid system as much as possible data, and can complete automatic mapping, providing a more efficient and intuitive database for subsequent correlation analysis, data retrieval, etc.

请参见图3示出的本申请实施例提供的计算机设备的结构示意图。本申请实施例提供的一种计算机设备400,包括:处理器410和存储器420,存储器420存储有处理器410可执行的计算机程序,计算机程序被处理器410执行时执行如上的方法。Please refer to FIG. 3 which is a schematic structural diagram of a computer device provided by an embodiment of the present application. A computer device 400 provided in an embodiment of the present application includes: a processor 410 and a memory 420 , the memory 420 stores a computer program executable by the processor 410 , and the computer program executes the above method when executed by the processor 410 .

本申请实施例还提供了一种存储介质430,该存储介质430上存储有计算机程序,该计算机程序被处理器410运行时执行如上的方法。The embodiment of the present application also provides a storage medium 430, on which a computer program is stored, and when the computer program is run by the processor 410, the above method is executed.

其中,存储介质430可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(Static RandomAccess Memory,简称SRAM),电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,简称EEPROM),可擦除可编程只读存储器(Erasable Programmable Read Only Memory,简称EPROM),可编程只读存储器(Programmable Red-Only Memory,简称PROM),只读存储器(Read-OnlyMemory,简称ROM),磁存储器,快闪存储器,磁盘或光盘。Wherein, the storage medium 430 can be implemented by any type of volatile or non-volatile storage device or their combination, such as Static Random Access Memory (Static Random Access Memory, referred to as SRAM), electrically erasable and programmable Read memory (Electr i cally Erasable Programmable Read-Only Memory, EE P ROM for short ) , Erasable Programmable Read Only Memory (EPROM for short), Programmable Red-Only Memory (Programmable Red-Only Memory , referred to as PROM), read-only memory (Read-OnlyMemory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk.

在本发明的描述中,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。“多个”的含义是两个或两个以上,除非另有明确具体的限定。In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features. Thus, a feature defined as "first" and "second" may explicitly or implicitly include one or more of these features. "Plurality" means two or more, unless otherwise clearly and specifically defined.

在本发明中,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”、“固定”等术语应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或成一体;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通或两个元件的相互作用关系。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。In the present invention, unless otherwise clearly specified and limited, terms such as "installation", "connection", "connection" and "fixation" should be understood in a broad sense, for example, it can be a fixed connection or a detachable connection , or integrated; it can be mechanically connected or electrically connected; it can be directly connected or indirectly connected through an intermediary, and it can be the internal communication of two components or the interaction relationship between two components. Those of ordinary skill in the art can understand the specific meanings of the above terms in the present invention according to specific situations.

在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必针对相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。In the description of this specification, descriptions with reference to the terms "one embodiment", "some embodiments", "example", "specific examples", or "some examples" mean that specific features described in connection with the embodiment or example , structure, material or feature is included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the described specific features, structures, materials or characteristics may be combined in any suitable manner in any one or more embodiments or examples. In addition, those skilled in the art can combine and combine different embodiments or examples and features of different embodiments or examples described in this specification without conflicting with each other.

流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本发明的实施例所属技术领域的技术人员所理解。Any process or method descriptions in flowcharts or otherwise described herein may be understood to represent modules, segments or portions of code comprising one or more executable instructions for implementing specific logical functions or steps of the process , and the scope of preferred embodiments of the invention includes alternative implementations in which functions may be performed out of the order shown or discussed, including substantially concurrently or in reverse order depending on the functions involved, which shall It is understood by those skilled in the art to which the embodiments of the present invention pertain.

在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。就本说明书而言,“计算机可读介质”可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDROM)。另外,计算机可读介质甚至可以是可在其上打印所述程序的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述程序,然后将其存储在计算机存储器中。The logic and/or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced listing of executable instructions for implementing logical functions, can be embodied in any computer-readable medium, For use with instruction execution systems, devices, or devices (such as computer-based systems, systems including processors, or other systems that can fetch instructions from instruction execution systems, devices, or devices and execute instructions), or in conjunction with these instruction execution systems, devices or equipment used. For the purposes of this specification, a "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use in or in conjunction with an instruction execution system, device or device. More specific examples (non-exhaustive list) of computer-readable media include the following: electrical connection with one or more wires (electronic device), portable computer disk case (magnetic device), random access memory (RAM), Read Only Memory (ROM), Erasable Editable Read Only Memory (E P ROM or Flash Memory), Fiber Optic Devices, and Portable Compact Disc Read Only Memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program can be printed, since the program can be read, for example, by optically scanning the paper or other medium, followed by editing, interpretation or other suitable processing if necessary. The program is processed electronically and stored in computer memory.

应当理解,本发明的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。例如,如果用硬件来实现,和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。It should be understood that various parts of the present invention can be realized by hardware, software, firmware or their combination. In the embodiments described above, various steps or methods may be implemented by software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one or combination of the following techniques known in the art: Discrete logic circuits, ASICs with suitable combinational logic gates, Programmable Gate Arrays ( PGA ), Field Programmable Gate Arrays (FPGA), etc.

本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。Those of ordinary skill in the art can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. During execution, one or a combination of the steps of the method embodiments is included.

上述提到的存储介质可以是只读存储器,磁盘或光盘等。尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, and the like. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and those skilled in the art can make the above-mentioned The embodiments are subject to changes, modifications, substitutions and variations.

Claims (15)

1.一种关系型数据至图数据映射方法,其特征在于,包括如下步骤:1. A method for mapping relational data to graph data, comprising the steps of: 获取关系型数据库中数据表信息,所述数据表信息至少包括设备实体表、关联关系表和主键;Obtain data table information in a relational database, where the data table information at least includes a device entity table, an association table and a primary key; 遍历所述设备实体表,根据所述主键将所述设备实体表依次在图形数据库中创建设备节点;Traversing the device entity table, creating device nodes in the graph database sequentially from the device entity table according to the primary key; 根据所述设备节点,检索所述关联关系表中是否存在后继设备;Retrieving whether there is a successor device in the association table according to the device node; 若存在后继设备,检索后续设备的所述设备实体表,判断是否已在图形数据库中创建设备节点;If there is a subsequent device, retrieve the device entity table of the subsequent device, and determine whether the device node has been created in the graph database; 若未创建设备节点,则创建新节点,并根据所述关联关系表,创建节点间的关联关系;If no device node is created, a new node is created, and an association relationship between nodes is created according to the association relationship table; 若已创建设备节点,则根据所述关联关系表,创建节点间的关联关系。If the device nodes have been created, an association relationship between nodes is created according to the association relationship table. 2.根据权利要求1所述的关系型数据至图数据映射方法,其特征在于,所述获取关系型数据库中数据表信息时,判断是否至少包含所述设备实体表、关联关系表和主键;2. The method for mapping relational data to graph data according to claim 1, wherein when acquiring the data table information in the relational database, it is judged whether at least the device entity table, the associated relationship table and the primary key are included; 若否,则停止映射。If not, stop mapping. 3.根据权利要求2所述的关系型数据至图数据映射方法,其特征在于,所述获取关系型数据库中数据表信息时,判断所述设备实体表是否具有单个主键;3. The method for mapping relational data to graph data according to claim 2, wherein, when obtaining the data table information in the relational database, it is judged whether the device entity table has a single primary key; 若否,则停止映射。If not, stop mapping. 4.根据权利要求1所述的关系型数据至图数据映射方法,其特征在于,所述根据所述主键将所述设备实体表依次在图像数据库中创建设备节点,包括:4. The method for mapping relational data to graph data according to claim 1, wherein said creating device nodes sequentially in the image database from said device entity table according to said primary key, comprising: 获取所述设备实体表对应主键的若干键值;Obtain several key values corresponding to the primary key of the device entity table; 依据所述键值在所述设备实体表和所述关联关系表中查找设备信息;Searching for device information in the device entity table and the association relationship table according to the key value; 将查找到的所述设备信息作为设备节点node i 的属性,写入图像数据库中。The found device information is written into the image database as an attribute of the device node node i . 5.根据权利要求4所述的关系型数据至图数据映射方法,其特征在于,所述依据所述键值在所述设备实体表和所述关联关系表中查找设备信息,包括如下步骤:5. The method for mapping relational data to graph data according to claim 4, wherein the searching for device information in the device entity table and the association table according to the key value comprises the following steps: S100:根据所述设备实体表的主键id,创建键值对{k i :v i },其中k i 为主键第i个键值的idv i 为第i个键值的标记值,且v i 的初始值为0;S100: According to the primary key id of the device entity table, create a key-value pair { k i : v i }, where k i is the id of the i -th key value of the primary key, v i is the tag value of the i -th key value, and The initial value of v i is 0; S110:创建集合map,将所述键值对{k i v i }加入所述集合map中;S110: Create a collection map , and add the key-value pair { k i : v i } to the collection map ; S120:依次遍历所述集合map中所述标记值为0的所述键值对,查找所述设备信息;S120: traversing the key-value pairs whose tag values are 0 in the set map in sequence, and searching for the device information; S130:令遍历的所述键值对的所述标记值v i 的值为1;S130: Set the value of the tag value v i of the traversed key-value pair to 1; S140:判断所述集合map中的所述标记值v i 是否都为1;S140: judging whether the tag values v i in the set map are all 1; 若否,则重复所述步骤S120至S130,若是,则完成查找。If not, repeat steps S120 to S130, and if yes, complete the search. 6.根据权利要求5所述的关系型数据至图数据映射方法,其特征在于,所述根据所述设备节点,检索所述关联关系表中是否存在后继设备时,包括如下步骤:6. The method for mapping relational data to graph data according to claim 5, wherein, according to the device node, when retrieving whether there is a successor device in the association relationship table, the method comprises the following steps: S200:依据创建的所述设备节点node i ,所述设备节点node i 对应的所述键值对为{k i :1};S200: According to the created device node node i , the key-value pair corresponding to the device node node i is { k i : 1}; S210:将所述设备节点node i 加入前驱队列中;S210: Add the device node node i to the precursor queue; S220:判断所述前驱队列是否为空;S220: Determine whether the precursor queue is empty; S230:若否,则取出所述前驱队列的队首节点node p ,所述队首节点node p 对应的主键键值为k p ;若是,则回到所述步骤S140;S230: If not, take out the head node node p of the precursor queue, and the primary key value corresponding to the head node node p is kp ; if so, return to the step S140 ; S240:检索所述关联关系表中是否存在所述队首节点node p 的后续设备,所述后续设备键值为k j ,且v j 为0;S240: Retrieve whether there is a follow-up device of the head node node p in the association table, the key value of the follow-up device is k j , and v j is 0; S250:若是,则在所述设备实体表中找到键值为k j 的设备,创建新节点node j ;若否,则回到所述步骤S220;S250: If yes, then find the device whose key value is k j in the device entity table, and create a new node node j ; if not, return to the step S220; S260:根据所述关联关系表为节点node p node j 创建关联关系;S260: Create an association relationship for nodes node p and node j according to the association relationship table; S270:将所述节点node j 放入所述前驱队列中,并回到所述步骤S240。S270: Put the node node j into the precursor queue, and return to the step S240. 7.根据权利要求1至6任一项所述的关系型数据至图数据映射方法,其特征在于,还包括如下步骤:7. The method for mapping relational data to graph data according to any one of claims 1 to 6, further comprising the following steps: 监测PMS系统中是否有设备变更;Monitor whether there is equipment change in the PMS system; 若是,则根据所述设备实体表和/或所述关联关系表,对所述设备节点和/或关联关系进行修改。If so, modify the device node and/or the association relationship according to the device entity table and/or the association relationship table. 8.根据权利要求7所述的关系型数据至图数据映射方法,其特征在于,所述设备变更包括:新增设备、设备退役、设备信息变化、设备间的关联信息变化中的任意一种或多种。8. The method for mapping relational data to graph data according to claim 7, wherein the device change includes any one of: adding new devices, decommissioning devices, changing device information, and changing related information between devices or more. 9.根据权利要求8所述的关系型数据至图数据映射方法,其特征在于,所述新增设备时,根据所述设备实体表,创建新节点,根据所述关联关系表,创建所述新节点与原节点的关联关系。9. The method for mapping relational data to graph data according to claim 8, wherein when adding a new device, a new node is created according to the device entity table, and the new node is created according to the association relationship table. The relationship between the new node and the original node. 10.根据权利要求8所述的关系型数据至图数据映射方法,其特征在于,所述设备退役时,删除设备对应的所述设备节点,将其余设备节点与所述设备节点间的关联关系删除。10. The method for mapping relational data to graph data according to claim 8, wherein when the device is decommissioned, the device node corresponding to the device is deleted, and the association relationship between the remaining device nodes and the device node delete. 11.根据权利要求8所述的关系型数据至图数据映射方法,其特征在于,所述设备信息变化时,根据所述设备实体表,对所述设备节点属性信息进行修改。11. The method for mapping relational data to graph data according to claim 8, wherein when the device information changes, the attribute information of the device node is modified according to the device entity table. 12.根据权利要求8所述的关系型数据至图数据映射方法,其特征在于,所述设备间的关联信息变化时,根据所述关联关系表,将所述设备节点间的关联信息进行修改。12. The method for mapping relational data to graph data 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 relationship table . 13.根据权利要求1所述的关系型数据至图数据映射方法,其特征在于,所述数据表信息还包括描述设备信息的设备记录表,在创建所述设备节点时,将所述设备记录表中设备信息作为所述设备节点的属性,写入到图像数据库中。13. The method for mapping relational data to graph data 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 record The device information in the table is written into the image database as the attribute of the device node. 14.一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时,实现如权利要求1-13中任一项所述的方法。14. A computer device, comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, characterized in that, when the processor executes the computer program, the computer program according to claims 1-13 is realized any one of the methods described. 15.一种存储介质,其上存储有计算机程序,其特征在于,该计算机程序被处理器执行时实现如权利要求1-13中任一项所述的方法。15. A storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, the method according to any one of claims 1-13 is implemented.
CN202210891628.XA 2022-07-27 2022-07-27 Method, equipment and storage medium for mapping relational data to graph data Active CN115269745B (en)

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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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

Patent Citations (5)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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
JP4406609B2 (en) Techniques for managing multiple hierarchies of data from a single interface
US6292804B1 (en) Object relationship management system
US8341164B1 (en) Apparatus and methods for organizing data items having time of life intervals
US20010042059A1 (en) Inventory managing method for automatic inventory retrieval and apparatus thereof
US20050044070A1 (en) Apparatus and method for searching data of structured document
JP2004234567A (en) Transaction processing system, parallel control method and program
CN107704203A (en) It polymerize delet method, device, equipment and the computer-readable storage medium of big file
US8959096B2 (en) Apparatus and methods for organizing data items by directed acyclic graphs
CN112840334B (en) Method, device, management node and storage medium for managing data of partition table
US9262552B2 (en) Apparatus and methods for organizing data items by directed graph
CN114090784A (en) Entity tag clustering method and device for material domain knowledge graph
CN115269745B (en) Method, equipment and storage medium for mapping relational data to graph data
US8548980B2 (en) Accelerating queries based on exact knowledge of specific rows satisfying local conditions
WO2023083237A1 (en) Graph data management
CN111752941B (en) Data storage and access method and device, server and storage medium
Severance A parametric model of alternative file structures
CN117149777B (en) Data query method, device, equipment and storage medium
CN115718571B (en) Data management method and device based on multidimensional features
CN117472959A (en) Gskip list-based block chain efficient query system and dynamic construction method
CN112307272B (en) Method, device, computing equipment and storage medium for determining relation information between objects
CN117290353A (en) Data storage method, reading method, database system, device and medium
CN100472537C (en) A Storage and Access Method of Resource Space Model
TWI868770B (en) Data construction system and data construction method
KR101263583B1 (en) Meditoloy system for large ontology data and the method
US20240394307A1 (en) Data construction system and data construction method

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