A real-time community relationship construction method based on graph database and its related components

By using graph database in the community information management system, the relationship between community entities is constructed and updated in real time, the traditional system's shortcomings in storage capacity, access speed and scalability are solved, and efficient massive data processing and timeliness are achieved. manage.

CN111966870BActive Publication Date: 2024-11-05SHENZHEN ALL THINGS CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010819596.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-14
Publication Date
2024-11-05
Estimated Expiration
2040-08-14

AI Technical Summary

Technical Problem

When processing large community data, traditional community information management systems have problems such as limited storage capacity, slow access speed, poor scalability and insufficient timeliness of entity relationships.

Method used

Using a real-time community relationship construction method based on graph database, import entity data and relational data into graph database through data pipelines, create nodes and assign dynamic attributes. Dynamic attributes include the effective time and end time of the relationship, and update and delete relationships in real time to achieve timeliness sex.

Benefits of technology

It realizes efficient storage and rapid access of massive data, improves data scalability and timeliness of entity relationships, and meets the needs of rapid analysis of data in large communities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111966870B_ABST
    Figure CN111966870B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for building community relationships in real time based on a graph database and its related components. The method includes: collecting entity data of the community and relationship data between entities and importing them into the graph database through a data pipeline, creating nodes according to the entity data; associating the relationship between nodes according to the relationship data between entities and assigning dynamic attributes; when the relationship data between entities changes, updating or deleting the relationship between nodes according to the relationship data between entities, and updating the dynamic attributes of the relationship; when a query request is received, obtaining the target entity data to be queried, querying in the graph database according to the target entity data, and obtaining the historical relationship state and real-time relationship state of the target entity. The present invention is based on the fact that the graph database can dynamically reflect the real and implicit connections between entities in real time, and uses the graph database to complete the distributed and reliable storage of data, and the query analysis is more efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of graph data processing technology, and in particular to a method, device, computer equipment and storage medium for real-time building of community relations based on a graph database. Background Art

[0002] In the new era, all sectors of society have put forward new requirements for the planning, development and maintenance of communities. Taking the construction of smart communities as the guide, improving the quality of new urbanization is the consensus for building modern communities. The property community information management system is a management platform built based on community scenarios for owners, visitors, vehicles, real estate and other entities, providing digital support for promoting the level of community public services and planning and construction.

[0003] With the acceleration of urbanization, the dimension and total amount of human-object information maintained in information systems have increased rapidly, and the frequency of interaction between human-object entities has accelerated. The data storage method of traditional community information management systems is based on the relational model, which is suitable for storing structured data and provides convenient data query methods through SQL query language. It is mainly used for operational processing of transactions, but it is difficult to meet the needs of fast access and analysis involved in the digital operation of large communities in the context of the big data era. It is subject to great limitations, mainly including: 1. Limited storage capacity. Relational databases can effectively process TB-level data (TB is a unit of computer storage capacity, which is equal to 2 to the 40th power of bytes, or close to one trillion bytes), but it is currently difficult to process PB-level data (PB is a unit of computer storage capacity, which is equal to 2 to the 50th power of bytes, or close to 1000TB); 2. The characteristics of relational models accessing by content restrict the ability to quickly access massive data; 3. Poor scalability. The design characteristics for specific applications make it difficult to deal with massive and complex data; 4. It is impossible to effectively determine the timeliness of relationships. Summary of the invention

[0004] The purpose of the present invention is to provide a method, device, computer equipment and storage medium for real-time construction of community relationships based on a graph database, aiming to solve the problems of limited storage capacity, slow access speed, poor scalability and lack of timeliness of relationships between entities in existing community data storage methods.

[0005] An embodiment of the present invention provides a method for real-time building of community relations based on a graph database, which includes:

[0006] Collecting entity data and relationship data between entities in the community, importing the entity data and relationship data between entities into a graph database through a data pipeline, and creating nodes of the graph database based on the entity data;

[0007] The relationship between nodes is created according to the relationship data between the entities, and dynamic attributes are assigned to the relationship; the relationship includes homogeneous relationships and heterogeneous relationships; the dynamic attributes include: relationship effective time and relationship end time;

[0008] When the relationship data between entities changes, the relationship between nodes is updated according to the new relationship data between entities, and new dynamic attributes are given to the relationship;

[0009] When the relationship data between entities is invalid, the relationship between nodes is deleted according to the current relationship data between entities, and the dynamic attributes of the invalid relationship are updated;

[0010] When a query request is received, the target entity data to be queried is obtained, and a query is performed in the graph database based on the target entity data to obtain the historical relationship state and the real-time relationship state of the target entity.

[0011] Preferably, collecting entity data and relationship data between entities of the community, importing the entity data and relationship data between entities into a graph database through a data pipeline, and creating nodes of the graph database according to the entity data, includes:

[0012] Collect entity data of the community and relationship data between entities, and store them in a relational database;

[0013] Building a data pipeline to import entity data and relationship data between entities stored in the relational database into the graph database;

[0014] A node of a graph database is created according to the entity data, and a corresponding type and attribute are assigned to the node based on predefined configuration information.

[0015] Preferably, the creating of the relationship between nodes according to the relationship data between the entities and assigning dynamic attributes to the relationship includes:

[0016] According to the relationship data between the entities, a batch of node pairs to be operated are selected from a candidate pool, and relationships between the node pairs are created;

[0017] According to the relationship data between the entities, dynamic attributes are assigned to the relationship between the node pairs.

[0018] Preferably, when the relationship data between entities changes, the relationship between nodes is updated according to the new relationship data between entities, and new dynamic attributes are assigned to the relationship, including:

[0019] When the relationship data between entities changes, the node pairs to be operated are selected from the candidate pool;

[0020] Determine whether the node pair has a relationship in the graph database;

[0021] If there is a relationship, the relationship of the node pair is updated according to the new relationship data between the entities, and a new dynamic attribute is assigned to the relationship;

[0022] If no relationship exists, a relationship between the node pair is created, and a dynamic attribute is assigned to the relationship between the node pair.

[0023] Preferably, the updating of the relationship between nodes according to the new relationship data between entities and assigning new dynamic attributes to the relationship includes:

[0024] Setting the relationship end time of the previous relationship of the node pair to the current time;

[0025] A new relationship is created for the node pair, and the node effective time of the new relationship is set to the current time according to the new relationship data between entities, and other dynamic attributes of the new relationship are set.

[0026] Preferably, when the relationship data between entities is invalid, the relationship between nodes is deleted according to the current relationship data between entities, and the dynamic attributes of the invalid relationship are updated, including:

[0027] When the relationship data between entities is invalid, select the node pair to be operated from the candidate pool;

[0028] Delete the relationship between nodes according to the relationship data between the current entities, and update the dynamic attributes of the invalid relationship.

[0029] Preferably, when a query request is received, the target entity data to be queried is obtained, and a query is performed in the graph database according to the target entity data to obtain the historical relationship state and the real-time relationship state of the target entity, including:

[0030] When a query request is received, the target entity data to be queried is obtained;

[0031] Querying, in the graph database, related entities related to the target entity according to the target entity data;

[0032] Querying the relationship between the target entity and the associated entity in the graph database;

[0033] If the relationship includes multiple relationships, the current relationship is returned as the real-time relationship state, and all relationships before the current relationship are returned as the historical relationship state.

[0034] The embodiment of the present invention provides a real-time community relationship construction device based on a graph database, which includes:

[0035] An entity data collection unit, used to collect entity data and relationship data between entities of the community, import the entity data and relationship data between entities into a graph database through a data pipeline, and create nodes of the graph database according to the entity data;

[0036] A node relationship creation unit is used to create a relationship between nodes according to the relationship data between the entities, and to assign dynamic attributes to the relationship; the relationship includes a homogeneous relationship and a heterogeneous relationship; the dynamic attributes include: a relationship effective time and a relationship end time;

[0037] A node relationship updating unit, used to update the relationship between nodes according to the new relationship data between entities when the relationship data between entities changes, and to assign new dynamic attributes to the relationship;

[0038] A node relationship deletion unit is used to delete the relationship between nodes according to the current relationship data between entities when the relationship data between entities is invalid, and to update the dynamic attributes of the invalid relationship;

[0039] The entity data query unit is used to obtain the target entity data to be queried when a query request is received, and to query the graph database according to the target entity data to obtain the historical relationship status and real-time relationship status of the target entity.

[0040] An embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for real-time building of community relationships based on a graph database as described above is implemented.

[0041] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for real-time building of community relationships based on a graph database as described above is implemented.

[0042] The embodiment of the present invention provides a method, device, computer equipment and storage medium for real-time construction of community relations based on a graph database, wherein the method includes: collecting entity data and relationship data between entities of the community, importing the entity data and relationship data between entities into the graph database through a data pipeline, and creating nodes of the graph database according to the entity data; creating relationships between nodes according to the relationship data between entities, and assigning dynamic attributes to the relationships; the relationships include homogeneous relationships and heterogeneous relationships; the dynamic attributes include: relationship effective time and relationship end time; when the relationship data between entities changes, the relationship between nodes is updated according to the new relationship data between entities, and new dynamic attributes are assigned to the relationships; when the relationship data between entities is invalid, the relationship between nodes is deleted according to the current relationship data between entities, and the dynamic attributes of the invalid relationship are updated; when a query request is received, the target entity data to be queried is obtained, and the target entity data is queried in the graph database according to the target entity data, and the historical relationship state and real-time relationship state of the target entity are obtained. The embodiment of the present invention realizes the storage of massive data by storing entity data and relationship data between entities in a graph database, and can realize fast access, has strong scalability in the face of massive and complex data, and has high timeliness of entity data and relationship data between entities. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0044] Figure 1 A flowchart of a method for real-time building of community relations based on a graph database provided by an embodiment of the present invention;

[0045] Figure 2 A relationship topology diagram is created for a method for building community relationships in real time based on a graph database provided by an embodiment of the present invention;

[0046] Figure 3 An updated relationship topology diagram of a community relationship real-time construction method based on a graph database provided by an embodiment of the present invention;

[0047] Figure 4 A deletion relationship topology diagram of a community relationship real-time construction method based on a graph database provided by an embodiment of the present invention;

[0048] Figure 5A new relationship topology diagram is created for a method for real-time building of community relationships based on a graph database provided in an embodiment of the present invention;

[0049] Figure 6 A schematic block diagram of a device for real-time building of community relations based on a graph database provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] It should be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0052] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0053] See also Figure 1 , Figure 1 A flowchart of a method for real-time community relationship construction based on a graph database provided by an embodiment of the present invention, the method may include steps S101 to S105:

[0054] S101, collecting entity data and relationship data between entities in the community, importing the entity data and relationship data between entities into a graph database through a data pipeline, and creating nodes of the graph database according to the entity data;

[0055] In this step, the entity data of entities in the community are collected, and nodes of the graph database are created based on the entity data. In subsequent steps, the nodes can be connected to form edges between the nodes, thereby completing the construction of the graph database.

[0056] The entity data is imported into the graph database as nodes in the graph database, and each node represents a different entity. The graph database is a NoSQL database that uses graph theory to describe the relationship information between entities. The data is stored in the form of nodes and edges. Each node represents an entity, and each edge is a "relationship" between entities, thereby constructing a relationship network graph.

[0057] In one embodiment, the step S101 includes:

[0058] Collect entity data of the community and relationship data between entities, and store them in a relational database;

[0059] Building a data pipeline to import entity data and relationship data between entities stored in the relational database into the graph database;

[0060] A node of a graph database is created according to the entity data, and a corresponding type and attribute are assigned to the node based on predefined configuration information.

[0061] In this embodiment, after collecting the entity data and the relationship data between entities, these data are usually stored in a relational database for easy access at any time; when building a graph database, the entity data needs to be imported as nodes and these data are transported to the graph database through the constructed data pipeline. Due to the diversity of the collected entity data, it is necessary to define them in advance and give these nodes corresponding types (which can be called node types) and attributes (which can be called node attributes).

[0062] Specifically, by establishing a data model and defining the types and properties of vertices (i.e., nodes) in a graph database, the storage and query of entity data such as people, movables, immovables, and organizations in the graph database can be run according to the model configuration information predefined by the user, which greatly simplifies the creation and application of the graph database, thereby improving the usability and versatility of graph database applications. Model configuration information is stored in yaml format (yaml is an intuitive data serialization format that can be recognized by computers. It is a highly readable and easy-to-read programming language for humans, easy to interact with scripting languages, and used to express data sequences). Based on the configuration file, a data pipeline can be built to import data from a relational database into a graph database and create nodes in the graph database.

[0063] S102, creating a relationship between nodes according to the relationship data between the entities, and assigning dynamic attributes to the relationship; the relationship includes a homogeneous relationship and a heterogeneous relationship; the dynamic attributes include: relationship effective time and relationship end time;

[0064] In the above steps, the nodes are created based on the entity data, and in this step, the relationships between the nodes are created based on the relationship data between the entities. In this embodiment, the relationship between the nodes is time-sensitive. For example, if the relationship between the nodes is a lease relationship, then this relationship has an effective period. Therefore, after the relationship between the nodes is associated, it is necessary to assign dynamic attributes to the relationship. The dynamic attributes include: a universal unique identification code (i.e., ID code), relationship effective time, relationship end time, and relationship type. The relationship type can be divided into homogeneous relationships and heterogeneous relationships.

[0065] Of course, there can be only one relationship between two nodes, or there can be multiple relationships between two nodes at the same time. For example, there is a lease relationship between node A and node B, and there is also a relative relationship. These relationships can be directed or undirected. When building a graph database, it is necessary to associate all the relationships between nodes to obtain more comprehensive data.

[0066] In this step, the corresponding association components (components used for relationship association) are mainly constructed around entities such as people, movables, immovables, and organizations, and are divided into homogeneous relationships and heterogeneous relationships according to the relationship type. Among them, homogeneous relationship association components include: interpersonal relationship components, organizational relationship components, immovable relationship components, and movable relationship components. Heterogeneous relationship association components include: person-movable relationship components, person-immovable relationship components, person-organization relationship components, organization-movable relationship components, organization-immovable relationship components, and movable-immovable relationship components.

[0067] Specifically, the operational scope of the interpersonal relationship component includes: legally recognized kinship relationships such as father and son, mother and son, husband and wife, brother and sister; short-term non-commercial relationships such as visitor-resident; short-term commercial activity relationships such as domestic service personnel (nanny, cleaner, maintenance and installation), agent-employer; medium- and long-term commercial activity relationships such as tenant-landlord.

[0068] Specifically, the operational scope of the person-real estate relationship association component includes: ownership, residence, leasing, short-term visits, services and other relationships between people and houses; purchase, leasing, short-term use and other relationships between people and parking spaces.

[0069] Specifically, the scope of operation of the person-property relationship association component includes: temporary use rights, ownership rights and other relationships.

[0070] In a specific embodiment, the creating of the relationship between nodes according to the relationship data between the entities and assigning dynamic attributes to the relationship includes:

[0071] According to the relationship data between the entities, a batch of node pairs to be operated are selected from a candidate pool, and relationships between the node pairs are created;

[0072] According to the relationship data between the entities, dynamic attributes are assigned to the relationship between the node pairs.

[0073] In this embodiment, the candidate pool stores all the nodes in the graph database. First, the node pairs with relationships are selected from the candidate pool according to the relationship data between entities. This step can be performed in batches. The selection method can be batch selection based on time periods or batch selection based on relationship types. Then, relationships between node pairs are created for the selected node pairs. When a node pair is selected from the candidate pool, the node pair in the candidate pool should be marked to indicate that the node pair has been selected and there is no need to repeat the selection next time. Then, dynamic attributes are assigned to the relationships between the node pairs according to the relationship data between entities.

[0074] S103, when the relationship data between entities changes, the relationship between nodes is updated according to the new relationship data between entities, and new dynamic attributes are assigned to the relationship;

[0075] In this step, the relationship data between the entities is not fixed, so it is necessary to update the relationship data between the entities in a timely manner, so as to update the relationship between the nodes in the graph database and assign new dynamic attributes.

[0076] For example, if two nodes represent a landlord and a tenant respectively, the relationship between the node pair is a lease relationship, and the dynamic attributes of the node pair relationship include the lease effective time and the lease end time. If the tenant's lease time has reached the lease end time, this relationship will be terminated, and there will be no other relationship between the tenant and the landlord nodes, and there will be no relationship between the node pair. At this time, the relationship between the two nodes needs to be updated and a new dynamic attribute needs to be given to the relationship between the nodes.

[0077] In one embodiment, the step S103 includes:

[0078] When the relationship data between entities changes, the node pairs to be operated are selected from the candidate pool;

[0079] Determine whether the node pair has a relationship in the graph database;

[0080] If there is a relationship, the relationship of the node pair is updated according to the new relationship data between the entities, and a new dynamic attribute is assigned to the relationship;

[0081] If no relationship exists, a relationship between the node pair is created, and a dynamic attribute is assigned to the relationship between the node pair.

[0082] In this embodiment, the relationship between the node pairs changes with the relationship data between the entities. When the relationship data between the entities changes, the corresponding node pairs are placed in a candidate pool so that their relationships can be updated later. The node pairs to be operated are selected from the candidate pool, and it is determined whether there is a relationship between the node pairs. If there is a relationship, the relationship between the node pairs is updated and assigned new dynamic attributes. If there is no relationship, a relationship is created for the node pairs and assigned dynamic attributes.

[0083] Specifically, a node pair to be operated is selected from the candidate pool. If there is no association relationship between the selected node pairs, that is, a relationship needs to be created, then a relationship between the nodes is created in the graph database. Among them, the default value of the relationship end time in the relationship creation operation is None. If there is a connection between the selected node pairs, the relationship needs to be updated and assigned new dynamic attributes.

[0084] In a specific embodiment, updating the relationship between nodes according to the new relationship data between entities and assigning new dynamic attributes to the relationship includes:

[0085] Setting the relationship end time of the previous relationship of the node pair to the current time;

[0086] A new relationship is created for the node pair, and the node effective time of the new relationship is set to the current time according to the new relationship data between entities, and other dynamic attributes of the new relationship are set.

[0087] In this embodiment, if a new relationship exists between the node pairs, the relationship between the node pairs is updated, and the relationship effective time of the new relationship between the node pairs is the relationship end time of the previous relationship between the node pairs.

[0088] For example, landlord A rents house C to tenant B. At this time, the node pairs are landlord A and tenant B, and the relationship between the node pairs is a lease relationship. During the lease process, tenant B is very satisfied with the house C he lives in, so he renews the lease after the lease expires. At this time, the previous lease relationship between landlord A and tenant B ends, and the end time of this relationship is the expiration time of the lease contract. The new relationship between landlord A and tenant B is created based on the new lease contract.

[0089] Specifically, the previous relationship E k(n-1) The relationship end time is set to t n , create a new relationship E kn , set a new relationship E kn The effective time of the relationship is t n , the relationship end time of the new relationship is the default value None. In particular, in this embodiment, all relationships between two nodes are stored in the form of an ordered queue.

[0090] Of course, since each relationship has dynamic properties, when the previous relationship ends, the new relationship may not have been created yet. In this case, the end time of the previous relationship cannot be equal to the effective time of the new relationship. k(n-1) The relationship end time is set to t n , create a new relationship E after a period of time kn , then the new relationship E kn The effective time of the relationship is not t n . For example: in the previous relationship, the two nodes of the node pair represent landlord A and tenant B respectively. At this time, the relationship represented by the node pair is a lease relationship. When the lease contract of tenant B expires, tenant B moves out because he cannot find a new house. One day after the lease contract expires, tenant B signs a new lease contract with landlord A. At this time, the effective time of the new relationship between landlord A and tenant B is not the same as the end time of the previous relationship between landlord A and tenant B.

[0091] Correspondingly, before the previous relationship ends, the new relationship may have been established in advance. In this case, the end time of the previous relationship cannot be equal to the effective time of the new relationship. k(n-1) The relationship end time is set to t n , in the relationship E k(n-1) Create a new relationship E before the relationship end time kn , then the new relationship E kn The effective time of the relationship is not t n For example: in the previous relationship, the two nodes of the node pair represent landlord A and tenant B respectively. At this time, the relationship represented by the node pair is a lease relationship. After tenant B finds that the lease contract is about to expire, he negotiates with landlord A and re-signs a lease contract with landlord A before the contract expires. At this time, the effective time of the new relationship between landlord A and tenant B is not the same as the end time of the previous relationship between landlord A and tenant B.

[0092] By updating the relationship between node pairs, the graph database is made more timely and better reflects the changes in the relationship between entities.

[0093] S104, when the relationship data between entities is invalid, the relationship between nodes is deleted according to the current relationship data between entities, and the dynamic attributes of the invalid relationship are updated;

[0094] In this step, the relationship between the node pairs changes as the relationship data between the entities becomes invalid, the relationship between the corresponding node pairs is deleted, and the current time is used as the end time of the relationship between the node pairs.

[0095] That is to say, the deletion operation of the relationship in this step does not directly delete the relationship in the graph database, but updates the relationship E kn to ensure the timeliness of the relationship in this embodiment.

[0096] In one embodiment, the step S104 includes:

[0097] When the relationship data between entities is invalid, select the node pair to be operated from the candidate pool;

[0098] Delete the relationship between nodes according to the relationship data between the current entities, and update the dynamic attributes of the invalid relationship.

[0099] In this embodiment, a node pair whose relationship is invalid is found in the candidate pool, and the relationship end time of the node pair is set as the current time.

[0100] For example, the entities corresponding to the node pair represent the landlord and the tenant respectively. In the previous relationship, the tenant rented the landlord's room A, and the relationship between the landlord and the tenant was a lease relationship. Due to the expiration of the lease, the lease relationship ended. The tenant found a more satisfactory room B in advance before the lease expired and did not renew the lease contract with the landlord. At this time, there was no new relationship between the landlord and the tenant. Therefore, the relationship end time in the previous relationship is set to the current time. This relationship effective time and relationship end time are both represented by specific time, which means that this relationship has expired.

[0101] S105. When a query request is received, the target entity data to be queried is obtained, and a query is performed in the graph database according to the target entity data to obtain the historical relationship status and the real-time relationship status of the target entity.

[0102] In this step, when a query is required, the target entity data to be queried is queried in the graph database, which is a more efficient query method. The query scope can be the real-time relationship status of the target entity or the historical relationship status of a specific time period. The historical relationship status and real-time relationship status are determined by the start and end timestamps of the relationship (timestamps are the most basic time series data, used to associate values ​​with time points), so the query function is more customized.

[0103] In this step, the target entity data may be data of one target entity, data of two target entities, or data of multiple target entities. When the target entity data is data of one target entity, all historical relationship states and all real-time relationship states of the target entity are queried in the graph database, that is, all relationships between other entities and the target entity.

[0104] When the target entity data is data of two target entities or data of multiple target entities, all historical relationship states and all real-time relationship states between the two target entities, or all historical relationship states and all real-time relationship states between multiple target entities are queried in the graph database.

[0105] This step is based on graph theory and analysis algorithms for querying, and the analysis algorithms include at least one of a breadth-first search algorithm, a depth-first search algorithm, a K-step connected subgraph, a topological sorting algorithm, a critical path algorithm, and a shortest path algorithm.

[0106] In one embodiment, the step S105 includes:

[0107] When a query request is received, the target entity data to be queried is obtained;

[0108] Querying, in the graph database, related entities related to the target entity according to the target entity data;

[0109] Querying the relationship between the target entity and the associated entity in the graph database;

[0110] If the relationship includes multiple relationships, the current relationship is returned as the real-time relationship state, and all relationships before the current relationship are returned as the historical relationship state.

[0111] In this embodiment, when performing a query, when the target entity has an associated entity with a relationship in the graph database, the relationship between the target entity and the associated entity can be found in the graph database, and the current relationship can be returned as a real-time relationship status. If there is a historical relationship between the target entity and the associated entity, all relationships before the current relationship are returned as historical relationship states.

[0112] Specifically, according to the requirements of the query request, the real-time relationship status can be obtained by filtering out the entity relationship data whose relationship end time with the target entity is None. The query of the historical relationship status compares the query timestamp with the end time of the entity relationship data, and selects the entity relationship data of a specific time period that meets the screening conditions.

[0113] The target entity may have one associated entity in the graph database. For example, A and B are both tenants in the same house C. The relationship between A and B is a roommate relationship. After living in the house for a period of time, A feels that the house C meets his housing requirements and buys the house C. A still lives in the house C with B. At this time, the relationship between A and B is transformed into a rental relationship. At this time, the rental relationship is the current relationship between A and B, and the roommate relationship is the historical relationship between A and B.

[0114] If the target entity may have multiple associated entities in the graph database, then all associated entities that have relationships with the target entity are queried, and the current relationships between these associated entities and the target entity are returned one by one. For example: the target entity is House A, and the associated entities that have relationships with it are Landlord B and Tenant C. At this time, the relationship between Landlord B and House A is an ownership relationship, and the relationship between Tenant C and House A is a residence relationship. Tenant C moves out after a period of time, and Tenant D moves into House A after Tenant C moves out. Tenant D and House A are in a residence relationship. The results returned at this time are that the relationship between Landlord B and House A is an ownership relationship, and the relationship between Tenant D and House A is a residence relationship. These are the current relationships of House A. The residence relationship between Tenant C and House A is the historical relationship of House A.

[0115] Specifically, Figure 2 As shown, the owner Zhang San owns two houses: Unit 3 1101 and Unit 3 1201. Zhang San lives in Unit 3 1101 with his wife Li Si and son Xiao Zhang. Since Unit 3 1201 is idle, the owner Zhang San leases the idle house Unit 3 1201 to Wang Wu, and the two parties signed a lease contract on February 1, 2019. After the lease contract takes effect, real-time relationship creation is performed through the method described in the present invention. Query the node pairs (Zhang San and Wang Wu) and related character relationship topology involved in this business, create the character relationship of the node pair (Zhang San and Wang Wu), and define attributes such as relationship type, relationship effective time, and relationship end time. Specifically, set the character relationship to a unidirectional relationship: rental relationship; the relationship effective time is February 1, 2019; the relationship end time is None.

[0116] On the day the lease contract takes effect, Wang Wu moves into Unit 3, Room 1201, and a one-way relationship is established between Wang Wu and the house: a residential relationship. The effective date of this relationship is set to February 1, 2019, and the end date is None.

[0117] like Figure 3 As shown in the figure, during the effective period of the lease contract, Wang Wu does not live in the leased house from October 1, 2019. Based on this transaction, the dynamic attributes of the most recent person-house relationship are updated. Wang Wu returns to live in the leased house after November 11, 2019. Based on this transaction, a new person-house relationship is created. The relationship effective date is November 11, 2019, and the relationship end date is None.

[0118] like Figure 4 As shown, after the current lease contract ends (end time is February 1, 2020), the owner Zhang San and the tenant Wang Wu did not renew the lease contract. Based on this transaction, the lease relationship between the owner Zhang San and Wang Wu is deleted. Specifically, the end time of the lease relationship between Zhang San and Wang Wu is set to February 1, 2020.

[0119] like Figure 5 As shown, the owner Zhang San and the new tenant Zhao Liu signed a lease contract on February 1, 2020. For this business, a new node pair relationship is created. The new node pair relationship takes effect on February 1, 2020, and ends on None.

[0120] See also Figure 6 , Figure 6 A schematic block diagram of a real-time community relationship construction device based on a graph database provided by an embodiment of the present invention. The real-time community relationship construction device 200 based on a graph database includes:

[0121] The entity data collection unit 201 is used to collect entity data and relationship data between entities in the community, import the entity data and relationship data between entities into the graph database through a data pipeline, and create nodes of the graph database according to the entity data;

[0122] A node relationship creation unit 202 is used to create a relationship between nodes according to the relationship data between the entities, and to assign dynamic attributes to the relationship; the relationship includes a homogeneous relationship and a heterogeneous relationship; the dynamic attributes include: a relationship effective time and a relationship end time;

[0123] A node relationship updating unit 203 is used to update the relationship between nodes according to the new relationship data between entities when the relationship data between entities changes, and to assign new dynamic attributes to the relationship;

[0124] A node relationship deletion unit 204 is used to delete the relationship between nodes according to the current relationship data between entities when the relationship data between entities is invalid, and to update the dynamic attributes of the invalid relationship;

[0125] The entity data query unit 205 is used to obtain the target entity data to be queried when a query request is received, and to query the graph database according to the target entity data to obtain the historical relationship status and real-time relationship status of the target entity.

[0126] In one embodiment, the entity data collection unit 201 includes:

[0127] A collection and storage unit, used to collect entity data of the community and relationship data between entities, and store them in a relational database;

[0128] A data pipeline construction unit, used to construct a data pipeline to import entity data and relationship data between entities stored in a relational database into the graph database;

[0129] A node creation unit is used to create nodes of a graph database according to the entity data, and assign corresponding types and attributes to the nodes based on predefined configuration information.

[0130] In one embodiment, the node relationship associating unit 202 includes:

[0131] A relationship creation unit, configured to select a batch of node pairs to be operated from a candidate pool according to the relationship data between the entities, and to create relationships between the node pairs;

[0132] The dynamic attribute assigning first unit is used to assign dynamic attributes to the relationship between the node pairs according to the relationship data between the entities.

[0133] In one embodiment, the node relationship updating unit 203 includes:

[0134] A first node pair selection unit, used to select a node pair to be operated from a candidate pool when the relationship data between entities changes;

[0135] A relationship determination unit, used to determine whether the node pair has a relationship in the graph database;

[0136] A dynamic attribute updating unit, used for updating the relationship of the node pair according to the new relationship data between entities if there is a relationship, and assigning a new dynamic attribute to the relationship;

[0137] The dynamic attribute is assigned to the second unit, which is used to create a relationship between the node pairs if no relationship exists, and assign a dynamic attribute to the relationship between the node pairs.

[0138] In one embodiment, the dynamic attribute updating unit includes:

[0139] A first current time setting unit, used to set the relationship end time of the previous relationship of the node pair to the current time;

[0140] The node pair relationship creation unit is used to create a new relationship for the node pair, set the node effective time of the new relationship to the current time according to the new relationship data between entities, and set other dynamic attributes of the new relationship.

[0141] In one embodiment, the node relationship deleting unit 204 includes:

[0142] A second node pair selection unit, used to select a node pair to be operated from a candidate pool when the relationship data between entities is invalid;

[0143] The invalid relationship deletion unit is used to delete the relationship between nodes according to the relationship data between the current entities and update the dynamic attributes of the invalid relationship.

[0144] In one embodiment, the entity data query unit 205 includes:

[0145] A query request acquisition unit, used to acquire target entity data to be queried when a query request is received;

[0146] A first query unit, configured to query, in the graph database, related entities related to the target entity according to the target entity data;

[0147] A second query unit, configured to query the graph database for a relationship between the target entity and the associated entity;

[0148] The query returning unit is used to return the current relationship as the real-time relationship state if the relationship contains multiple relationships, and return all relationships before the current relationship as the historical relationship state.

[0149] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for real-time building of community relationships based on a graph database as described above is implemented.

[0150] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for real-time building of community relationships based on a graph database as described above is implemented.

[0151] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.

[0152] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

Claims

1. A method for real-time community relationship construction based on a graph database, characterized in that: include: Collecting entity data and relationship data between entities in the community, importing the entity data and relationship data between entities into a graph database through a data pipeline, and creating nodes of the graph database based on the entity data; Creating relationships between nodes according to the relationship data between the entities, and assigning dynamic attributes to the relationships; The relationship includes a homogeneous relationship and a heterogeneous relationship, and the homogeneous relationship includes a lease relationship; The dynamic attributes include: relationship effective time and relationship end time; When the relationship data between entities changes, the relationship between nodes is updated according to the new relationship data between entities, and new dynamic attributes are given to the relationship; When the relationship data between entities is invalid, the relationship between nodes is deleted by updating the effective time of the relationship according to the current relationship data between entities, and the dynamic attributes of the invalid relationship are updated; When a query request is received, the target entity data to be queried is obtained, and a query is performed in the graph database according to the target entity data to obtain the historical relationship state and the real-time relationship state of the target entity; When the relationship data between entities changes, the relationship between nodes is updated according to the new relationship data between entities, and new dynamic attributes are given to the relationship, including: When the relationship data between entities changes, the node pairs to be operated are selected from the candidate pool; Determine whether the node pair has a relationship in the graph database; If there is a relationship, the relationship of the node pair is updated according to the new relationship data between the entities, and a new dynamic attribute is assigned to the relationship; If no relationship exists, creating a relationship between the node pairs and assigning dynamic attributes to the relationship between the node pairs; The updating of the relationship between nodes according to the new relationship data between entities and assigning new dynamic attributes to the relationship includes: Setting the relationship end time of the previous relationship of the node pair to the current time; Creating a new relationship for the node pair, setting the node effective time of the new relationship to the current time according to the new relationship data between entities, and setting other dynamic attributes of the new relationship; When the relationship data between entities is invalid, the relationship between nodes is deleted by updating the effective time of the relationship according to the current relationship data between entities, and the dynamic attributes of the invalid relationship are updated, including: When the relationship data between entities is invalid, select the node pair to be operated from the candidate pool; Delete the relationship between nodes according to the relationship data between the current entities, and update the dynamic attributes of the invalid relationship.

2. The method for real-time building of community relations based on a graph database according to claim 1, characterized in that: The collecting of entity data and relationship data between entities in the community, importing the entity data and relationship data between entities into a graph database through a data pipeline, and creating nodes of the graph database according to the entity data, includes: Collect entity data of the community and relationship data between entities, and store them in a relational database; Building a data pipeline to import entity data and relationship data between entities stored in the relational database into the graph database; A node of a graph database is created according to the entity data, and a corresponding type and attribute are assigned to the node based on predefined configuration information.

3. The method for real-time building of community relations based on a graph database according to claim 2 is characterized in that: The creating of the relationship between the nodes according to the relationship data between the entities and assigning dynamic attributes to the relationship includes: According to the relationship data between the entities, a batch of node pairs to be operated are selected from a candidate pool, and relationships between the node pairs are created; According to the relationship data between the entities, dynamic attributes are assigned to the relationship between the node pairs.

4. The method for real-time building of community relations based on a graph database according to claim 1, characterized in that: When a query request is received, the target entity data to be queried is obtained, and a query is performed in the graph database according to the target entity data to obtain the historical relationship state and the real-time relationship state of the target entity, including: When a query request is received, the target entity data to be queried is obtained; Querying, in the graph database, related entities related to the target entity according to the target entity data; Querying the relationship between the target entity and the associated entity in the graph database; If the relationship includes multiple relationships, the current relationship is returned as the real-time relationship state, and all relationships before the current relationship are returned as the historical relationship state.

5. A real-time community relationship construction device based on a graph database, characterized in that: include: An entity data collection unit, used to collect entity data and relationship data between entities of the community, import the entity data and relationship data between entities into a graph database through a data pipeline, and create nodes of the graph database according to the entity data; A node relationship creation unit, used to create a relationship between nodes according to the relationship data between the entities, and to assign dynamic attributes to the relationship; The relationship includes a homogeneous relationship and a heterogeneous relationship, and the homogeneous relationship includes a lease relationship; The dynamic attributes include: relationship effective time and relationship end time; A node relationship updating unit, used to update the relationship between nodes according to the new relationship data between entities when the relationship data between entities changes, and to assign new dynamic attributes to the relationship; A node relationship deletion unit is used to delete the relationship between nodes according to the current relationship data between entities when the relationship data between entities is invalid, and to update the dynamic attributes of the invalid relationship; An entity data query unit, configured to obtain target entity data to be queried when a query request is received, query the graph database according to the target entity data, and obtain the historical relationship state and real-time relationship state of the target entity; The node relationship updating unit comprises: A first node pair selection unit, used to select a node pair to be operated from a candidate pool when the relationship data between entities changes; A relationship determination unit, used to determine whether the node pair has a relationship in the graph database; A dynamic attribute updating unit, used for updating the relationship of the node pair according to the new relationship data between entities if there is a relationship, and assigning a new dynamic attribute to the relationship; A dynamic attribute assigning second unit is used to create a relationship between the node pairs if no relationship exists, and assign a dynamic attribute to the relationship between the node pairs; The dynamic attribute updating unit comprises: A first current time setting unit, used to set the relationship end time of the previous relationship of the node pair to the current time; A node pair relationship creation unit, used to create a new relationship for the node pair, and set the node effective time of the new relationship to the current time according to the new relationship data between entities, and set other dynamic attributes of the new relationship; The node relationship deletion unit includes: A second node pair selection unit, used to select a node pair to be operated from a candidate pool when the relationship data between entities is invalid; The invalid relationship deletion unit is used to delete the relationship between nodes according to the relationship data between the current entities and update the dynamic attributes of the invalid relationship.

6. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for real-time building of community relations based on a graph database as described in any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the method for real-time building of community relations based on a graph database as described in any one of claims 1 to 4 is implemented.