Operation method for graph database and related equipment

By implementing a separate locking mechanism for nodes, edges and their attributes in the graph database, the problem of multiple operations conflicts is solved, and the database performance and user experience are improved.

CN119166648AActive Publication Date: 2024-12-20ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411680248.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2024-12-20
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

In the graph database, conflicts are prone to occur when multiple people operate the same node or edge and its attributes at the same time, resulting in a decline in user experience and a decrease in database performance. The existing technology unified locking method leads to user blockage and performance losses.

Method used

In the graph database, nodes, edges and their attributes can be locked separately. Operation is prohibited when a node or edge is locked. All attributes of nodes or edges are also locked to avoid conflicts and allow multiple users to operate differently at the same time. property.

Benefits of technology

It effectively avoids multi-person operation conflicts, reduces user blockage, and improves the performance and user experience of graph database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166648A_ABST
    Figure CN119166648A_ABST
Patent Text Reader

Abstract

The invention provides an operation method for a graph database and related equipment. The graph database comprises nodes, edges and attributes of the nodes and the edges; wherein when the node or the edge is locked, operation of the node or the edge and all attributes of the node or the edge is forbidden, and when any attribute in all the attributes of the node or the edge is locked, operation of the attribute and the node or the edge is forbidden. The method comprises the following steps: acquiring an operation statement initiated by a user for the graph database; analyzing the operation statement, and determining a to-be-operated object of the operation statement according to an analysis result; wherein the object to be operated comprises any one of a target node, a target edge, a target attribute of the target node and a target attribute of the target edge; and determining whether the operation of the to-be-operated object is prohibited or not, if not, locking the to-be-operated object, and after locking is completed, executing a plurality of operations contained in the operation statement on the to-be-operated object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of database technology, and in particular, to an operation method and related equipment for a graph database. Background Art

[0002] Graph Database is a database system specially designed for storing and querying graph data. Graph data mainly includes nodes, edges, and properties of nodes and edges. Nodes represent entities, edges represent the relationship between entities, and properties are usually key-value pairs attached to nodes or edges to describe the characteristics of nodes or edges.

[0003] In many cases, multiple people will perform operations on the same node or edge and its attributes in the graph database at the same time. For example, user A is deleting a node X in the graph database, and user B wants to modify an attribute of node X. There is a conflict between the two. If user A's operation is submitted first, user B's operation will fail because it cannot find node X in the graph database, which seriously affects the user experience and reduces database performance. Summary of the invention

[0004] In view of this, one or more embodiments of the present specification provide an operation method and related equipment for a graph database.

[0005] In a first aspect, the present specification provides an operation method for a graph database, wherein the graph database includes nodes and edges, and attributes of the nodes and edges; wherein when the node or edge is locked, operation of the node or edge and all attributes of the node or edge is prohibited, and when any attribute of all attributes of the node or edge is locked, operation of the attribute and the node or edge is prohibited; the method comprises: Obtaining an operation statement initiated by a user for the graph database; Parsing the operation statement, and determining the object to be operated of the operation statement according to the parsing result; wherein the object to be operated includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge; Determine whether the object to be operated is prohibited from operation. If not, lock the object to be operated. After locking, perform several operations included in the operation statement on the object to be operated.

[0006] In a second aspect, the present specification provides an operation device for a graph database, wherein the graph database includes nodes and edges, and attributes of the nodes and edges; wherein when the node or edge is locked, operation of the node or edge and all attributes of the node or edge is prohibited, and when any attribute of all attributes of the node or edge is locked, operation of the attribute and the node or edge is prohibited; the device comprises: An acquisition unit, used to acquire an operation statement initiated by a user for the graph database; A determination unit, configured to parse the operation statement and determine an object to be operated of the operation statement according to the parsing result; wherein the object to be operated includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge; The operation execution unit is used to determine whether the object to be operated has been prohibited from operation. If not, the object to be operated is locked, and after the locking is completed, the operation included in the operation statement is executed on the object to be operated.

[0007] Accordingly, this specification also provides a computing device, including: a memory and a processor; the memory stores computer programs / instructions that can be executed by the processor; when the processor runs the computer program / instructions, it executes the operation method for the graph database described in the first aspect above.

[0008] Accordingly, the present specification also provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the operation method for the graph database as described in the first aspect above is executed.

[0009] Accordingly, the present specification also provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the operation method for the graph database as described in the first aspect above is performed.

[0010] In summary, the present application first allows the nodes, edges, node attributes and edge attributes in the graph database to be locked separately, and when a node or edge is locked, it is prohibited to operate the node or edge and all the attributes of the node or edge. When any attribute of all the attributes of the node or edge is locked, it is prohibited to operate the attribute and the node or edge. Based on this, when the graph database receives an operation statement initiated by a user, it can first determine whether the object to be operated in the operation statement is prohibited from operation. If the operation is not prohibited, the object to be operated can be locked and the corresponding operation can be performed to prohibit other users from performing operations on the object to be operated at the same time. In this way, conflicts and confusion caused by multiple people operating the same node or edge and its attributes of the graph database at the same time are avoided, and since each attribute of the node or edge can be locked separately, multiple different users are allowed to perform operations on different attributes of the same node or edge at the same time, reducing multi-user blocking and improving the performance of the graph database. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 is a schematic diagram of a system architecture provided by an exemplary embodiment; Figure 2 It is a flowchart of an operation method for a graph database provided by an exemplary embodiment; Figure 3 It is a schematic diagram of a process of a multi-person editing graph model provided by an exemplary embodiment; Figure 4 It is a structural schematic diagram of an operating device for a graph database provided by an exemplary embodiment; Figure 5 It is a structural diagram of a computing device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0012] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0013] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0014] It should be noted that the “plurality” mentioned in this application refers to two or more than two.

[0015] In addition, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0016] As mentioned above, in many cases, there are often multiple people operating on the same node or edge and its attributes in the graph database at the same time. For example, user A is deleting a node X in the graph database, and user B wants to modify an attribute of node X. There is a conflict between the two. If user A's operation is submitted first, then user B's operation will fail because it cannot find node X in the graph database, which seriously affects the user's use effect and reduces database performance.

[0017] In addition, it should be noted that in conventional graph databases, nodes, edges and their attributes are usually managed in a unified manner because they together constitute the complete structure of the graph data. This unified management method simplifies the data model and makes queries and operations more intuitive and efficient. For example, a node and all its attributes are stored in the same data row of a data table. Based on this, in some possible implementations, in order to avoid conflicts caused by different users performing operations on the same node or edge and its attributes at the same time, the node or edge and its attributes can be locked in a unified manner. For example, the above-mentioned user A can first lock node X and its attributes in a unified manner (for example, use a row-level lock to lock the data row where node X and its attributes are located), thereby prohibiting other users from operating on node X and its attributes.

[0018] However, nodes and edges usually have multiple attributes, and different users may want to perform operations on different attributes of the same node. There is no conflict between the two and they can be performed simultaneously. If the nodes and their attributes are directly locked uniformly at this time, it will cause user congestion and reduce database performance.

[0019] Based on this, this specification provides a technical solution, so that the nodes, edges, node attributes and edge attributes in the graph database can be locked separately, and when the node or edge is locked, it is prohibited to operate the node or edge and all the attributes of the node or edge. When any attribute of all the attributes of the node or edge is locked, it is prohibited to operate the attribute and the node or edge. Based on this, when the graph database receives an operation statement initiated by a user, it can first determine whether the object to be operated of the operation statement is prohibited from operation. If the operation is not prohibited, the object to be operated can be locked and several operations contained in the operation statement can be executed to prohibit other users from performing operations on the object to be operated at the same time. In this way, conflicts and confusion caused by multiple people operating the same node or edge and its attributes of the graph database at the same time are avoided, and because each attribute of the node or edge can be locked separately, multiple different users are allowed to perform operations on different attributes of the same node or edge at the same time, reducing multi-user blocking and improving the performance of the graph database.

[0020] See also Figure 1 , Figure 1 This is a schematic diagram of a system architecture provided by an exemplary embodiment. One or more embodiments provided in this specification may be Figure 1 The system architecture shown in the figure or a similar system architecture is specifically implemented. Figure 1 As shown, the system architecture may include a computing device 100 and a computing device 200 , wherein the computing device 100 is equipped with a graph database server, and the computing device 200 is equipped with a graph database client.

[0021] In an illustrated embodiment, the graph database client in the computing device 200 may provide a visualization interface related to the graph database. The visualization interface may display a graph model of the graph database, wherein the graph model is the basis of the graph database, and the graph model defines the nodes, edges, and properties of the nodes and edges in the graph database.

[0022] In an illustrated embodiment, the nodes and edges defined in the graph model, as well as the attributes of the nodes and edges, can be stored and managed separately and independently, that is, the nodes and edges are stored in one location and managed independently, and the attributes of the nodes and edges are stored in another location and managed independently. For example, a node exists in one data row, and multiple attributes of the node are stored in another multiple data rows, and the same is true for the point and its attributes.

[0023] Alternatively, in an illustrated embodiment, nodes, edges, node attributes, and edge attributes can all be stored and managed separately and independently, that is, nodes are stored in one location and managed independently, edges are stored in another location and managed independently, node attributes are stored in another location and managed independently, and edge attributes are also stored in another location and managed independently, and this specification does not specifically limit this.

[0024] In this way, the nodes, edges, node attributes and edge attributes in the graph database can all be locked individually. In addition, in order to prevent operation conflicts, when a node or edge is locked, operations on the node or edge and all attributes of the node or edge can be prohibited. When any attribute of all attributes of a node or edge is locked, operations on the attribute and the node or edge can be prohibited.

[0025] In one illustrated embodiment, a user may edit a graph model displayed in a visualization interface provided by a graph database client through an input device (such as a mouse, keyboard, or touch screen) provided by the computing device 200. Specifically, the user may edit nodes, edges, node attributes, or edge attributes defined in the graph model.

[0026] Exemplarily, the editing operation on the graph model may be deleting a node or edge defined in the graph model, or modifying the originally defined node type, or adding a new attribute of the node or edge, or modifying the data type of an existing attribute, etc. This specification does not make any specific limitations on this.

[0027] Furthermore, the graph database client in the computing device 200 may generate a corresponding operation statement in response to the editing operation input by the user for the graph model, and send the operation statement to the graph database server (i.e., graph engine) in the computing device 100. In an illustrated embodiment, the operation statement may be a data definition language (DDL) statement, which is not specifically limited in this specification.

[0028] Correspondingly, the graph database server in the computing device 100 can obtain the operation statement sent by the graph database client, and then the graph database server can parse the operation statement and determine the object to be operated of the operation statement based on the parsing result. Among them, the object to be operated can be any one of the target node, target edge, target attribute of the target node and target attribute of the target edge among the several nodes, edges and their attributes defined by the graph model. It should be noted that the target attribute of the target node refers to one of the several attributes of the target node. Similarly, the target attribute of the target edge refers to one of the several attributes of the target edge. The two target attributes are not the same.

[0029] Furthermore, the graph database server can determine whether the object to be operated has been prohibited from operation. If the object to be operated has been prohibited from operation, the operation cannot be performed. If the object to be operated has not been prohibited from operation, the graph database server can lock the object to be operated, and after locking, perform several operations contained in the operation statement on the object to be operated. For details, please refer to Figure 2 The description in the corresponding embodiment will not be repeated here.

[0030] In this way, the present application stores and manages the nodes and edges in the graph database, as well as the attributes of the nodes and edges separately and independently, so that the nodes and edges can be locked individually, and each attribute of the nodes and edges can also be locked individually. This not only avoids the conflicts and confusion caused by multiple people operating on the same node or edge and its attributes of the graph database at the same time, but also because each attribute can be locked individually, it allows multiple different users to perform operations on different attributes of the same node or edge at the same time, reducing multi-user blocking and improving the performance of the graph database.

[0031] In one illustrated embodiment, Figure 1 The computing device 100 shown can be a server with the above functions, or a server cluster composed of multiple servers; the computing device 200 can be a smart wearable device, a smart phone, a tablet computer, a laptop computer and a desktop computer with the above functions, etc., and this manual does not make specific limitations on this.

[0032] It should be understood that Figure 1 The system architecture shown is for illustrative purposes only. In some possible implementations, the system architecture may also include other devices, for example, multiple computing devices 200 used by multiple other users, etc. This specification does not specifically limit this.

[0033] See also Figure 2 , Figure 2 This is a flowchart of an operation method for a graph database provided by an exemplary embodiment. This method can be applied to Figure 1 The system architecture shown can be applied to Figure 1 The graph database server in the system architecture shown in the figure. The graph database contains nodes and edges, as well as the properties of nodes and edges; nodes and edges, as well as the properties of nodes and edges, are stored and managed independently. Figure 2 As shown, the method may specifically include the following steps S201 to S203.

[0034] Step S201, obtaining an operation statement initiated by a user for a graph database; the graph database contains nodes and edges, as well as attributes of the nodes and edges; wherein, when a node or edge is locked, operations on the node or edge, as well as all attributes of the node or edge, are prohibited; and when any attribute among all attributes of a node or edge is locked, operations on the attribute, as well as the node or edge, are prohibited.

[0035] In an illustrated embodiment, as described above, the graph database server can obtain an operation statement for the graph database initiated by the user through the graph database client, which can be an operation statement for the graph model in the graph database. For details, please refer to the above Figure 1 The description in the corresponding embodiment will not be repeated here.

[0036] As described above, nodes, edges, and properties of nodes and edges are defined in the graph model, and nodes and edges, as well as properties of nodes and edges, are stored and managed independently, and can be locked individually; and when a node or edge is locked, operations on the node or edge, as well as all properties of the node or edge, are prohibited; when any of all properties of a node or edge are locked, operations on the property, as well as the node or edge, are prohibited.

[0037] In an illustrated embodiment, nodes and edges may be stored in a first data table, and the attributes of nodes and edges may be stored in a second data table. Alternatively, in an illustrated embodiment, nodes may be stored in a first data table, edges may be stored in a second data table, the attributes of nodes may be stored in a third data table, and the attributes of edges may be stored in a fourth data table, which is not specifically limited in this specification.

[0038] It should be noted that the first data table, the second data table, the third data table and the fourth data table may be different data tables or different partitions of the same data table, and this specification does not make any specific limitation on this.

[0039] Specifically, the graph model may include metadata of nodes and edges, as well as metadata of attributes of nodes and edges, which metadata constitute the definition of nodes, edges and their attributes. Among them, nodes and edges, as well as the attributes of nodes and edges are stored and managed independently, which may mean that the metadata of nodes and edges, as well as the metadata of attributes of nodes and edges are stored and managed independently. Correspondingly, nodes and edges are stored in a first data table, which may mean that the metadata of nodes and edges are stored in the first data table, and metadata of different nodes and edges may be located in different data rows of the first data table. Correspondingly, the attributes of nodes and edges are stored in a second data table, which may mean that the metadata of attributes of nodes and edges are stored in the second data table, and metadata of different attributes of nodes and edges may be located in different data rows of the second data table.

[0040] Accordingly, the above-mentioned prohibition of operating the node or edge, as well as all the attributes of the node or edge, when the node or edge is locked may mean that when the data row where the metadata of the node or edge is located is locked, the data row where the node or edge is located, as well as the data row where all the attributes of the node or edge are located are prohibited from operating. Accordingly, the above-mentioned prohibition of operating the attribute, as well as the node or edge, when any attribute among all the attributes of a node or edge is locked may mean that when the data row where the metadata of any attribute among all the attributes of a node or edge is locked, the data row where the metadata of the attribute is located, as well as the data row where the metadata of the node or edge is located are prohibited from operating.

[0041] In an illustrated embodiment, the metadata of a node may include a node type, such as a company node, an employee node, a user node, or a commodity node, etc.

[0042] In an illustrated embodiment, the metadata of an edge may include an edge type, a starting point type of the edge (eg, the user node or commodity node, etc.) and an end point type (eg, the user node or commodity node, etc.).

[0043] In one illustrated embodiment, the metadata of a node's attributes may include attribute types (or attribute names), such as name, position, and length of service, and may also include data types of attribute values. For example, the data type of a name may be a string, the data type of a position may also be a string, the data type of length of service may be an integer, such as Integer or long, and so on. This specification does not make any specific limitations on this.

[0044] In one illustrated embodiment, the metadata of the edge attributes may include attribute types, such as superior-subordinate relationships, friend relationships, purchase relationships, and relationship start time, and may also include data types of attribute values. For example, the data types of superior-subordinate relationships, friend relationships, and purchase relationships may be Boolean, and the data type of the relationship start time may be date, etc. This specification does not make specific limitations on this.

[0045] For example, a code example of a graph model can be as follows: "node": [{ "typeName":"person" "properties":{ "name":"string" } }] "edge": [{ "type":"edge1" "src_type":"person" "dst_type":"person" "properties":{ "friends": boole } }] As shown above, the graph model defines the node type as person, the node attribute type includes name, and the data type of the attribute value of this attribute type is string; the edge type is edge1, the starting point type (src_type) of the edge is person, the end point type (dst_type) is also person, the edge attribute type includes friend relationship, and the data type of the attribute value of this attribute type is boolean.

[0046] In an illustrated embodiment, assuming that the metadata of nodes and edges are stored in the first data table, and the metadata of the attributes of nodes and edges are stored in the second data table, the node "person" can be stored in a data row of the first data table, and the attribute "name": "string" can be stored in a data row of the second data table and can be associated with the node "person". Similarly, the edge "edge1" can be stored in a data row of the first data table, and "friend": boole can be stored in a data row of the second data table and can be associated with the edge "edge1".

[0047] Step S201, parse the operation statement, and determine the object to be operated of the operation statement according to the parsing result; wherein the object to be operated includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge.

[0048] Furthermore, the graph database server can parse the acquired operation statement, and determine the object to be operated of the operation statement according to the parsing result. Among them, the object to be operated may be any one of the target node, target edge, target attribute of the target node and target attribute of the target edge among the several nodes, edges and their attributes defined by the graph model, and this specification does not make specific restrictions on this. Alternatively, in some possible implementations, the object to be operated may also be any multiple of the target node, target edge, target attribute of the target node and target attribute of the target edge, and may also be multiple target nodes, multiple target edges, or multiple target attributes of the target node, or may be multiple target attributes of the target edge, etc. This specification does not make specific restrictions on this.

[0049] Step S203, determining whether the object to be operated is prohibited from operation, if not, locking the object to be operated, and after locking, executing several operations included in the operation statement on the object to be operated.

[0050] Furthermore, after determining the object to be operated, the graph database server can further determine whether the object to be operated has been prohibited from operation. In an illustrated embodiment, if the object to be operated has been prohibited from operation, this operation cannot be performed. In an illustrated embodiment, if the object to be operated has not been prohibited from operation, the graph database server can lock the object to be operated, and after locking, perform several operations included in the operation statement on the object to be operated. Further, after the execution of the several operations is completed, the graph database server can release the lock of the object to be operated.

[0051] In one illustrated embodiment, assuming that the object to be operated is a target node, the graph database server determines whether the operation of the object to be operated has been prohibited. If not, the object to be operated is locked. Specifically, it may include: determining whether the target node has been locked; if the target node is not locked, further determining whether several attributes of the target node have been locked; if several attributes (or all attributes) of the target node are not locked, it can be determined that the target node is not prohibited, and then the target node can be locked to prohibit other users from performing operations on the target node and all attributes of the target node.

[0052] Furthermore, after locking is completed, the graph database server can perform several operations contained in the operation statement on the target node, such as deleting the target node, or modifying the node type of the target node, etc. This specification does not make specific limitations on this.

[0053] Furthermore, after the execution of several operations included in the operation statement is completed, the graph database server can release the lock of the target node to facilitate subsequent operations by other users.

[0054] In one illustrated implementation, assuming that the object to be operated is a target edge, the graph database server determines whether the operation of the object to be operated has been prohibited. If not, the object to be operated is locked. Specifically, it may include: determining whether the target edge has been locked; if the target edge is not locked, further determining whether several attributes of the target edge have been locked; if several attributes (or all attributes) of the target edge are not locked, it can be determined that the target edge is not prohibited, and then the target edge can be locked to prohibit other users from performing operations on the target edge and all attributes of the target edge.

[0055] Furthermore, after locking is completed, the graph database server can perform several operations contained in the operation statement on the target edge, such as modifying the edge type of the target edge, modifying the starting point type of the target edge, or modifying the end point type of the target edge, etc. This specification does not make specific limitations on this.

[0056] Furthermore, after the execution of several operations included in the operation statement is completed, the graph database server can release the lock of the target edge to facilitate subsequent operations by other users.

[0057] In an illustrated embodiment, assuming that the object to be operated is the target attribute of the target node, the graph database server determines whether the operation of the object to be operated has been prohibited. If not, the object to be operated is locked. Specifically, it may include: determining whether the target node has been locked; if the target node is not locked, further determining whether the target attribute of the target node has been locked; if the target attribute of the target node is not locked, it can be determined that the target attribute of the target node is not prohibited, and then the target attribute of the target node can be locked to prohibit other users from performing operations on the target node and the target attribute of the target node.

[0058] Furthermore, after locking is completed, the graph database server can perform several operations contained in the operation statement on the target attribute of the target node, such as deleting the target attribute, adding the target attribute, or modifying the data type of the attribute value of the target attribute, etc. This specification does not make specific limitations on this.

[0059] Furthermore, after the execution of several operations included in the operation statement is completed, the graph database server can release the lock of the target attribute of the target node to facilitate subsequent operations by other users.

[0060] In one illustrated embodiment, assuming that the object to be operated is the target attribute of the target edge, the graph database server determines whether the operation of the object to be operated has been prohibited. If not, the object to be operated is locked. Specifically, it may include: determining whether the target edge has been locked; if the target edge is not locked, further determining whether the target attribute of the target edge has been locked; if the target attribute of the target edge is not locked, it can be determined that the target attribute of the target edge is not prohibited, and then the target attribute of the target edge can be locked to prohibit other users from performing operations on the target edge and the target attribute of the target edge.

[0061] Furthermore, after locking is completed, the graph database server can perform several operations contained in the operation statement on the target attribute of the target edge, such as deleting the target attribute, adding the target attribute, or modifying the data type of the attribute value of the target attribute, etc. This specification does not make specific limitations on this.

[0062] Furthermore, after the execution of several operations included in the operation statement is completed, the graph database server can release the lock of the target attribute of the target edge to facilitate subsequent operations by other users.

[0063] It should be noted that this specification does not specifically limit the specific implementation of the locking process. In an illustrated implementation, the graph database server may use row-level locks when performing the locking process.

[0064] In one illustrated embodiment, assuming that the nodes and edges defined in the graph model are stored in a first data table, and the metadata of the target node or target edge is located in the corresponding first data row in the first data table, then when the above-mentioned graph database server determines whether the target node or target edge has been locked, it may specifically include: determining whether the first data row where the metadata of the target node or target edge is located has been locked.

[0065] It should be noted that the first data row described in the embodiments of this specification is used to refer to the data row where the target node or target edge is located, and does not specifically refer to a fixed data row.

[0066] In one illustrated embodiment, assuming that the metadata of the attributes of the nodes and edges defined in the graph model are stored in a second data table, and the metadata of several attributes of the target node or target edge are stored in several corresponding data rows in the second data table, when the graph database server determines whether several attributes of the target node or target edge have been locked, it can specifically include: determining whether the several data rows where the metadata of several attributes of the target node or target edge are located have been locked.

[0067] In one illustrated embodiment, assuming that the metadata of the target attribute of the target node or target edge is stored in the corresponding second data row in the second data table, when the graph database server determines whether the target attribute of the target node or target edge has been locked, it can specifically include: determining whether the second data row where the metadata of the target attribute of the target node or target edge is located has been locked.

[0068] It should be noted that the second data row described in the embodiments of this specification is used to refer to the data row where the target attribute of the target node or target edge is located, and does not specifically refer to a fixed data row.

[0069] Accordingly, when the graph database server performs locking processing on the target node or target edge, it may specifically include: locking the first data row where the metadata of the target node or target edge is located. Furthermore, after the locking is completed, the metadata of the target node or target edge recorded in the first data row may be subjected to several operations included in the above operation statement. Furthermore, after the operation is executed, the lock of the first data row may be released.

[0070] Accordingly, when the graph database server performs locking processing on the target attribute of the target node or target edge, it may specifically include: locking the second data row where the metadata of the target attribute of the target node or target edge is located. Furthermore, after locking is completed, the metadata of the target attribute of the target node or target edge recorded in the second data row may be subjected to several operations included in the above operation statement. Furthermore, after the operation is executed, the lock of the second data row may be released.

[0071] In one illustrated implementation, after locking is completed, the graph database server may also notify other users that the current object to be operated has been locked, and send an updated version of the current graph model to other users, etc. This specification does not make specific limitations on this.

[0072] For example, see Figure 3 , Figure 3 FIG. 1 is a flow chart of a multi-person editing graph model provided by an exemplary embodiment. Figure 3 As shown in , the graph model defines several nodes and edges and their attributes, and the graph model is divided into two parts, one part is the nodes and edges, and the other part is the attributes of the nodes and edges. That is to say, the nodes and edges in the graph model, as well as the attributes of the nodes and edges, are stored and managed independently. Specifically, Figure 3 As shown, the graph model includes: node x, 2 attributes of node x (x1: long, x2: string respectively), node y, 2 attributes of node y (y1: long, y2: string respectively), edge z, 2 attributes of edge z (z1: boole, z2: string).

[0073] like Figure 3 As shown, the graph model can be output and displayed to the user in a visual interface so that the user can edit and modify any node and edge in the graph model and its attributes.

[0074] like Figure 3 As shown in the figure, when user A edits the graph model, he wants to modify node x in the graph model, specifically, to add a new attribute x3: long to node x. Figure 3As shown, after receiving the operation statement initiated by user A for the graph model, the graph database server can parse the operation statement to determine that the object to be operated is the attribute x3:long of node x. Further, after determining that the node x is not locked and the attribute x3:long is not locked, the graph database server can lock the attribute x3:long to smoothly add the attribute x3:long. In addition, other users can also receive the new version of the graph model with the attribute x3:long added sent by the graph database server.

[0075] like Figure 3 As shown in the figure, when user B edits the graph model, he also wants to modify the node x in the graph model, specifically, to change the data type of the attribute x1:long of node x from long to string. Figure 3 As shown, after receiving the operation statement initiated by user B for the graph model, the graph database server can parse the operation statement to determine that the object to be operated is the attribute x1: long of node x. Further, after determining that the node x is not locked and the attribute x1: long is not locked, the graph database server can lock the attribute x1: long and change its data type to string. In addition, other users can also receive a new version of the graph model sent by the graph database server containing the modified attribute x1: string.

[0076] like Figure 3 As shown, after the operations of user A and user B are submitted, that is, after the above modifications are formally written to the disk, the attributes of node x in the graph model may include: x1: string, x2: string, x3: long.

[0077] like Figure 3 As shown in Figure 1, when user C edits the graph model, he wants to modify node y in the graph model, specifically, to add a new attribute y3: long to node y. Figure 3 As shown, after receiving the operation statement initiated by user C for the graph model, the graph database server can parse the operation statement to determine that the object to be operated is the attribute y3:long of node y. Further, after determining that the node y is not locked and the attribute y3:long is not locked, the graph database server can lock the attribute y3:long to smoothly add the attribute y3:long. In addition, other users can also receive the new version of the graph model sent by the graph database server with the attribute y3:long added.

[0078] like Figure 3As shown, after the operation of user C is submitted, that is, after the above modification is formally written to the disk, the attributes of the node y in the graph model may include: y1: long, y2: string, y3: long.

[0079] In this way, the present application stores and manages the nodes and edges in the graph model, as well as the properties of the nodes and edges, separately, so that the nodes and edges, as well as the properties of the nodes and edges, can be locked separately, which makes Figure 3 As shown, users A, B, and C can edit the graph model at the same time. They can not only edit nodes x and y at the same time, but also edit different attributes of node x (x1 and x3) at the same time without any conflict. This meets the user's usage needs and greatly improves the performance of the graph database.

[0080] Corresponding to the implementation of the above method flow, the embodiment of this specification also provides an operating device for a graph database. Figure 4 , Figure 4 is a schematic diagram of a structure of an operating device for a graph database provided by an exemplary embodiment. The device 40 can be applied to Figure 1 The system architecture shown can be applied to Figure 1 The graph database server in the system architecture shown in the figure contains nodes and edges, as well as the properties of nodes and edges. When a node or edge is locked, operations on the node or edge and all the properties of the node or edge are prohibited. When any of the properties of a node or edge is locked, operations on the property and the node or edge are prohibited. Figure 4 As shown, the device 40 includes: An acquisition unit 401 is used to acquire an operation statement initiated by a user for a graph database; A determination unit 402 is used to parse the operation statement and determine the object to be operated of the operation statement according to the parsing result; wherein the object to be operated includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge; The operation execution unit 403 is used to determine whether the object to be operated has been prohibited from operation. If not, the object to be operated is locked, and after locking, several operations included in the operation statement are executed on the object to be operated.

[0081] In an illustrated embodiment, the device 40 further comprises a lock release unit 404 for: After the execution of the plurality of operations is completed, the lock of the object to be operated is released.

[0082] In an illustrated embodiment, the object to be operated is the target node or the target edge; the operation execution unit 403 is specifically used to: Determine whether the target node or the target edge has been locked; If the target node or the target edge is not locked, further determining whether all attributes of the target node or the target edge are locked; If all attributes of the target node or the target edge are not locked, it is determined that the target node or the target edge is not prohibited from operation, and a locking process is performed on the target node or the target edge.

[0083] In an illustrated embodiment, the object to be operated is a target attribute of the target node or the target edge; the operation execution unit 403 is specifically used to: Determine whether the target node or the target edge has been locked; If the target node or the target edge is not locked, further determining whether the target attribute of the target node or the target edge is locked; If the target attribute of the target node or the target edge is not locked, it is determined that the target attribute of the target node or the target edge is not prohibited from operation, and the target attribute of the target node or the target edge is locked.

[0084] In one illustrated embodiment, the metadata of the nodes and edges, and the metadata of the attributes of the nodes and edges are defined in the graph model of the graph database; wherein the metadata of the nodes and edges, and the metadata of the attributes of the nodes and edges are independently stored and managed.

[0085] In one illustrated embodiment, the metadata of the node includes the node type, the metadata of the edge includes the edge type, the start point type and the end point type of the edge; the metadata of the attribute includes the attribute type and the data type of the attribute value.

[0086] In an illustrated embodiment, the metadata of the nodes and edges are stored in a first data table, and the metadata of the target node or the target edge is located in a corresponding first data row in the first data table; The operation execution unit 403 is specifically used for: Locking the first data row where the metadata of the target node or the target edge is located; Several operations included in the operation statement are performed on metadata of the target node or the target edge.

[0087] In an illustrated embodiment, the metadata of the attributes of the nodes and edges are stored in a second data table, and the metadata of the target attribute of the target node or the target edge is located in a corresponding second data row in the second data table; The operation execution unit 403 is specifically used for: Locking the second data row where the metadata of the target attribute of the target node or the target edge is located; Several operations included in the operation statement are performed on metadata of the target attribute of the target node or the target edge.

[0088] In an illustrated embodiment, the operation statement is an operation statement for the graph model generated by a client of the graph database in response to an edit operation input by a user for the graph model displayed in a visualization interface provided by the client; The acquisition unit 401 is specifically used to receive an operation statement for the graph model sent by the client.

[0089] In an illustrated implementation, the operation statement is a DDL statement.

[0090] The implementation process of the functions and effects of each unit in the above-mentioned device 40 is specifically described in the above-mentioned embodiment, and will not be repeated here. It should be understood that the above-mentioned device 40 can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor (CPU) of the device where it is located reading the corresponding computer program instructions into the memory and running them. From the hardware level, in addition to the CPU and memory, the device where the above-mentioned device is located usually also includes other hardware such as chips for wireless signal transmission and reception, and / or other hardware such as boards and cards for realizing network communication functions.

[0091] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the units or modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. Those of ordinary skill in the art may understand and implement it without creative work.

[0092] The devices, units, and modules described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device, a vehicle-mounted computer, or a combination of any of these devices.

[0093] Corresponding to the above method embodiment, the embodiment of this specification also provides a computing device. Figure 5 , Figure 5 It is a structural diagram of a computing device provided by an exemplary embodiment. Figure 5 The computing device shown may be Figure 1 The system architecture shown is a computing device 100 equipped with a graph database server, wherein the graph database contains nodes and edges, as well as the attributes of the nodes and edges; wherein, when a node or edge is locked, operations on the node or edge, as well as all the attributes of the node or edge, are prohibited; and when any attribute of all the attributes of a node or edge is locked, operations on the attribute, as well as the node or edge, are prohibited. Figure 5 As shown, the computing device includes a processor 1001 and a memory 1002, and may further include an input device 1004 (such as a keyboard, etc.) and an output device 1005 (such as a display, etc.). The processor 1001, the memory 1002, the input device 1004, and the output device 1005 may be connected via a bus or other means. Figure 5 As shown, the memory 1002 includes a computer-readable storage medium 1003, which stores a computer program that can be run by the processor 1001. The processor 1001 can be a CPU, a microprocessor, or an integrated circuit for controlling the execution of the above method embodiment. When the processor 1001 runs the stored computer program, it can execute the various steps of the operation method for the graph database in the embodiment of this specification, including: obtaining an operation statement initiated by a user for the graph database; parsing the operation statement, and determining the object to be operated of the operation statement according to the parsing result; wherein the object to be operated includes any one of the target node, the target edge, the target attribute of the target node and the target attribute of the target edge; determining whether the object to be operated has been prohibited from operation, if not, locking the object to be operated, and after the locking is completed, performing several operations contained in the operation statement on the object to be operated, and so on.

[0094] For a detailed description of each step of the above-mentioned operation method for the graph database, please refer to the previous content and will not be repeated here.

[0095] Corresponding to the above method embodiment, the embodiment of this specification also provides a computer-readable storage medium, on which a computer program is stored. When these computer programs are executed by a processor, they execute the various steps of the method for operating a graph database in the embodiment of this specification. Please refer to the description of the above embodiment for details, which will not be repeated here.

[0096] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

[0097] In a typical configuration, a terminal device includes one or more CPUs, input / output interfaces, network interfaces, and memory.

[0098] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0099] Computer readable media include permanent and non-permanent, removable and non-removable media and can store information by any method or technology. The information can be computer readable instructions, data structures, program modules or other data.

[0100] Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0101] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0102] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

Claims

1. A method for operating a graph database, characterized in that: The graph database includes nodes and edges, and attributes of the nodes and edges; when the node or edge is locked, operation of the node or edge and all attributes of the node or edge is prohibited; when any attribute of all attributes of the node or edge is locked, operation of the attribute and the node or edge is prohibited; the method includes: Obtaining an operation statement initiated by a user for the graph database; Parsing the operation statement, and determining the object to be operated of the operation statement according to the parsing result; wherein the object to be operated includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge; Determine whether the object to be operated is prohibited from operation. If not, lock the object to be operated. After locking, perform several operations included in the operation statement on the object to be operated.

2. The method according to claim 1, characterized in that The method further comprises: After the execution of the plurality of operations is completed, the lock of the object to be operated is released.

3. The method according to claim 1, characterized in that The object to be operated is the target node or the target edge; and determining whether the object to be operated has been prohibited from operation, and if not, locking the object to be operated, includes: Determine whether the target node or the target edge has been locked; If the target node or the target edge is not locked, further determining whether all attributes of the target node or the target edge are locked; If all attributes of the target node or the target edge are not locked, it is determined that the target node or the target edge is not prohibited from operation, and a locking process is performed on the target node or the target edge.

4. The method according to claim 3, characterized in that The object to be operated is a target attribute of the target node or the target edge; and determining whether the object to be operated has been prohibited from operation, and if not, locking the object to be operated, includes: Determine whether the target node or the target edge has been locked; If the target node or the target edge is not locked, further determining whether the target attribute of the target node or the target edge is locked; If the target attribute of the target node or the target edge is not locked, it is determined that the target attribute of the target node or the target edge is not prohibited from operation, and the target attribute of the target node or the target edge is locked.

5. The method according to claim 4, characterized in that The metadata of the nodes and edges, and the metadata of the attributes of the nodes and edges are defined in the graph model of the graph database; wherein the metadata of the nodes and edges, and the metadata of the attributes of the nodes and edges are independently stored and managed.

6. The method according to claim 5, characterized in that The metadata of the node includes the node type, the metadata of the edge includes the edge type, the start point type and the end point type of the edge; the metadata of the attribute includes the attribute type and the data type of the attribute value.

7. The method according to claim 5, characterized in that The metadata of the nodes and edges are stored in a first data table, and the metadata of the target node or the target edge is located in a corresponding first data row in the first data table; The locking process of the target node or the target edge includes: Locking the first data row where the metadata of the target node or the target edge is located; The performing of the operations contained in the operation statement on the object to be operated includes: Several operations included in the operation statement are performed on metadata of the target node or the target edge.

8. The method according to claim 5, characterized in that The metadata of the attributes of the nodes and edges are stored in a second data table, and the metadata of the target attribute of the target node or the target edge is located in a corresponding second data row in the second data table; The locking process of the target attribute of the target node or the target edge includes: Locking the second data row where the metadata of the target attribute of the target node or the target edge is located; The performing of the operations contained in the operation statement on the object to be operated includes: Several operations included in the operation statement are performed on metadata of the target attribute of the target node or the target edge.

9. The method according to claim 5, characterized in that The operation statement is an operation statement for the graph model generated by the client of the graph database in response to an editing operation input by a user for the graph model displayed in the visual interface provided by the client; The obtaining of the operation statement initiated by the user for the graph database includes: receiving the operation statement sent by the client for the graph model.

10. The method according to any one of claims 1 to 9, characterized in that: The operation statement is a DDL statement.

11. An operating device for a graph database, characterized in that: The graph database includes nodes and edges, and attributes of the nodes and edges; when the node or edge is locked, operation of the node or edge and all attributes of the node or edge is prohibited; when any attribute of all attributes of the node or edge is locked, operation of the attribute and the node or edge is prohibited; the device includes: An acquisition unit, used to acquire an operation statement initiated by a user for the graph database; A determination unit, configured to parse the operation statement and determine an object to be operated of the operation statement according to the parsing result; wherein the object to be operated includes any one of a target node, a target edge, a target attribute of a target node, and a target attribute of a target edge; The operation execution unit is used to determine whether the object to be operated has been prohibited from operation. If not, the object to be operated is locked, and after the locking is completed, the operation included in the operation statement is executed on the object to be operated.

12. A computing device, characterized in that: include: Memory and processor; The memory has stored thereon computer programs / instructions executable by the processor; When the processor runs the computer program / instructions, it performs the method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: A computer program / instruction is stored thereon, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 10 is implemented.

14. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Tense graph database distributed transaction solution system

    CN112214649A

  • Method and device for processing data in tree structure, equipment and storage medium

    CN112306991A

  • Graph data writing method and device

    CN113672636A

  • Data processing method and device, readable storage medium and electronic equipment

    CN115982416A

  • Deadlock detection method and device, equipment and storage medium

    CN117076147A