A method and system for attribute management in a graph database

By adopting a dual default value mechanism in the graph database and separating the default value logic of read and write operations, the conflict between default value modification and historical data constraints is resolved, flexible default value management and data consistency are achieved, and system performance and data stability are improved.

CN120492690BActive Publication Date: 2025-09-23杭州悦数科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510984319.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2025-09-23
Estimated Expiration
2045-07-17

AI Technical Summary

Technical Problem

When adding new fields with default values ​​in graph databases, existing technologies suffer from performance degradation and inconsistent historical data constraints, and cannot effectively resolve the conflict between the dynamic modification requirements of default values ​​and the stability of historical data constraints.

Method used

A dual default value mechanism is adopted to separate the logic of reading and writing default values ​​of attributes. Default values ​​are managed through metadata to avoid full backfill, ensure the stability of indexes and foreign key constraints, and support iterative updates of business logic.

Benefits of technology

It achieves flexible modification of default values ​​and compatibility with historical data constraints, avoids the problems of full data backfill and index data inconsistency, and ensures system performance and data consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492690B_ABST
    Figure CN120492690B_ABST
Patent Text Reader

Abstract

The present application relates to a graph database attribute management method and system. The beneficial effects of the present application are: by setting a dual default value mechanism, separating the logic of reading and writing default values ​​of attributes, flexible modification of default values ​​and compatibility with historical data constraints are achieved. Data backfilling is avoided, and default values ​​are managed through metadata, avoiding full table scans and batch updates; dynamic flexibility is provided, and iterative updates of business logic are supported by modifying and writing default values; it has good compatibility, is transparent to the application layer, and does not require modification of existing query statements. The present invention successfully solves the problem of conflicts between default value modifications and historical data constraints, avoids inconsistencies between index data and original data, prevents the problem of inconsistent data queried with and without indexes, and prevents the problem of metadata modifications affecting original data values.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of graph database management, and in particular to a graph database attribute management method and system. Background Art

[0002] With the rapid development of information technology, graph databases, a type of database that efficiently processes complex, connected data, have been widely used in areas such as social networks, knowledge graphs, and recommendation systems. Dynamic adjustment of data structures is a common requirement when using graph databases, especially the frequent addition of new fields to existing tables.

[0003] In traditional database management systems, adding new fields to a table typically involves modifying the table structure. In relational databases, standardized management is achieved by checking and correcting field configuration types. In graph databases, some existing technologies focus on locking mechanisms for nodes, edges, and their attributes to ensure data security. Some technologies also provide methods for updating table structures by comparing data tables with pre-defined models and generating DDL (Data Definition Language) statements.

[0004] However, existing technologies still have significant shortcomings in managing default values ​​for graph database fields. When adding new fields with default values ​​to existing tables in a graph database, there are two main traditional solutions: immediate backfill and delayed backfill. While the immediate backfill solution ensures data consistency, it can lead to severe performance degradation in large data volumes and may even cause system unavailability. While the delayed backfill solution avoids performance issues, when the default value changes, historical data that has not been backfilled will automatically inherit the new default value. This can cause the data to violate existing constraints (such as index constraints and foreign key constraints), leading to data logic errors.

[0005] Especially in graph database environments, the complex relationships between nodes and edges make changes to default values ​​have a wider impact. Existing technologies cannot effectively resolve the conflict between the need for dynamic modification of default values ​​and the stability of historical data constraints, a contradiction that is particularly prominent in large-scale graph database processing scenarios. Furthermore, existing solutions lack mechanisms for differentiated default value behavior in read and write operations, failing to meet the flexible default value management requirements of different business scenarios.

[0006] Therefore, there is an urgent need for a technical solution that can effectively manage the default values ​​of graph database fields while ensuring system performance and solve the compatibility issues between default value changes and historical data constraints. Summary of the Invention

[0007] Embodiments of the present application provide a method, apparatus, system, computer device, and computer-readable storage medium for attribute management in a graph database to at least resolve the conflict between the dynamic modification requirements of default values ​​and the stability of historical data constraints in related technologies.

[0008] In a first aspect, an embodiment of the present application provides a method for managing attributes in a graph database, characterized in that the method is applied to a graph database and includes:

[0009] When a new attribute is added to an element in the graph database, initializing the element with equal first and second default values;

[0010] Recording the current configuration values ​​of the first default value and the second default value in metadata, and configuring the backfill state of the attribute to disable triggering;

[0011] In response to the default value modification instruction, the first default value is updated, and data separation reading and writing based on attribute dual default values ​​is performed according to the first default value and the second default value.

[0012] In some embodiments, the first default value is a write default value, and the second default value is a read default value. The first default value is used to fill in the value corresponding to the attribute in the metadata of the graph database when data is written, and the second default value is used to query the query results containing the attribute from the graph database when data is read.

[0013] In some embodiments, in response to a default value modification instruction, when the first default value is updated, the second default value remains unchanged.

[0014] In some embodiments, performing attribute dual default value-based data separation reading and writing according to the first default value and the second default value includes:

[0015] When adding or updating an element, responding to a write instruction, determining whether the attribute of the element is explicitly assigned a value; if not, temporarily logically filling the attribute with the first default value; and if so, actually filling the attribute with the result of the explicit assignment;

[0016] When querying data, responding to a data read instruction, determining whether the attribute of any element is empty, if so, returning the second default value, if not, returning the actual value corresponding to the attribute.

[0017] In some embodiments, after returning the actual value corresponding to the attribute, the method further includes:

[0018] For the record to be verified, check whether the attribute corresponds to the actual stored value, and if not, use the second default value as the logical value;

[0019] Substitute the obtained logical value into the index and foreign key constraint rules to verify whether the updated attribute meets the preset constraint conditions. If so, output the query result.

[0020] In some embodiments, the elements are nodes and edges in the graph database, the nodes represent data in the graph database, and the edges are relationships between the data.

[0021] In a second aspect, an embodiment of the present application provides a graph database attribute management system, the system comprising: a configuration module and a read-write module, wherein:

[0022] The configuration module is configured to, when a new attribute is added to an element in the graph database, initialize a first default value and a second default value equal to the element, record current configuration information of the first default value and the second default value in metadata, and configure the data backfill state of the element to disable triggering;

[0023] The read-write module is used to respond to a default value modification instruction, update the first default value, and perform data separation reading and writing based on attribute dual default values ​​according to the first default value and the second default value.

[0024] In some embodiments, the first default value is a write default value, and the second default value is a read default value. The first default value is used to fill in the value corresponding to the attribute in the graph database when data is written, and the second default value is used to query the query results containing the attribute from the graph database when data is read.

[0025] In a third aspect, an embodiment of the present application provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect above when executing the computer program.

[0026] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method of the first aspect described above.

[0027] Compared with related technologies, the graph database attribute management method provided by the embodiment of the present application realizes the compatibility of flexible modification of default values ​​with historical data constraints by setting a dual default value mechanism and separating the logic of reading and writing default values ​​of attributes. Avoiding full backfill of data and managing default values ​​through metadata, full table scans and batch updates are avoided, and constraint stability is guaranteed. The read default value (Read Default) of historical data is fixed to ensure that constraints such as indexes and foreign keys are always valid; in addition, dynamic flexibility is provided to support iterative updates of business logic by modifying the write default value, with good compatibility, and transparent to the application layer, without the need to modify existing query statements. The solution of this application successfully solves the problem of conflicts between default value modifications and historical data constraints, avoids inconsistencies between index data and original data, prevents inconsistencies between data queried with and without indexes, and prevents the problem of metadata modifications affecting the original data values. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0029] Figure 1 is a flowchart of a graph database attribute management method according to an embodiment of the present application;

[0030] Figure 2 This is a structural block diagram of a graph database attribute management system according to an embodiment of the present application;

[0031] Figure 3 Schematic diagram of the internal structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is described and illustrated below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely used to explain this application and are not intended to limit this application. Based on the embodiments provided in this application, all other embodiments obtained by those of ordinary skill in the art without making any creative efforts are within the scope of protection of this application.

[0033] Obviously, the drawings described below are merely examples or embodiments of the present application. Those skilled in the art can, without inventive effort, apply the present application to other similar scenarios based on these drawings. Furthermore, it is also understood that, although the effort involved in such a development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, changes in design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as an insufficiency of the content disclosed in this application.

[0034] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it refer to independent or alternative embodiments that are mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments unless there is a conflict.

[0035] Unless otherwise defined, technical or scientific terms used herein shall have the ordinary meaning as understood by persons of ordinary skill in the art to which this application belongs. The terms "a," "an," "an," "the," and similar expressions used herein do not denote quantitative limitations and may refer to either the singular or the plural. The terms "comprise," "include," "have," and any variations thereof, used herein, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or modules (units) is not limited to the listed steps or units but may also include steps or units not listed, or may include other steps or units inherent to the process, method, product, or apparatus. The terms "connected," "connected," "coupled," and similar expressions used herein are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. As used herein, "plurality" means two or more. "And / or" describes an association between associated objects, indicating that three possible relationships exist. For example, "A and / or B" may mean: A exists alone; A and B exist simultaneously; or B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.

[0036] This embodiment provides a graph database attribute management method, which is applied to a graph database. Figure 1 This is a flowchart of a graph database attribute management method according to an embodiment of the present application. Figure 1As shown, the method includes the following steps:

[0037] S101, when a new attribute is added to an element in the graph database, initializing the element to have equal first and second default values;

[0038] Specifically, in this embodiment, when a new attribute is added to an element such as a node or relationship in a graph database, two default values ​​are automatically set for that attribute: a first default value and a second default value. Initially, these two default values ​​are set to the same value. For example, when adding an "Age" attribute to a "Person" node type, the system sets both the first and second default values ​​to "18." This initialization ensures data consistency and integrity during the initial attribute creation process.

[0039] S102, recording the current configuration information of the first default value and the second default value in metadata, and configuring the data backfill state of the element to be trigger disabled;

[0040] After setting the default values, these configurations are persistently stored in the graph database's metadata. It should be noted that metadata is data that describes the data and includes information about the data structure, attribute definitions, default values, and more.

[0041] For example, for the "Age" attribute of the "Person" node, the metadata records both its first and second default values ​​as "18." At the same time, the data backfill status for this element is set to "Disable Trigger," meaning the system won't automatically backfill existing data, thus avoiding performance issues and data consistency risks that may arise from large-scale data modifications.

[0042] S103, responding to the default value modification instruction, updating the first default value, and performing data separation reading and writing based on attribute dual default values ​​according to the first default value and the second default value.

[0043] Specifically, this step includes the following subdivision steps:

[0044] Write: When adding or updating an element, respond to the write instruction and determine whether the attribute of the element is explicitly assigned a value. If not, use the first default value to temporarily logically fill the attribute. If so, use the explicit assignment result to actually fill the attribute.

[0045] Reading: When querying data, respond to the data reading instruction and determine whether the attribute of any element is empty. If so, return the second default value; if not, return the actual value corresponding to the attribute.

[0046] When a user or system administrator needs to modify the default value, he or she can send a default value modification instruction. After receiving the instruction, the first default value will be updated.

[0047] For example, an administrator might decide to change the default value of the "Age" attribute of a "Person" node from "18" to "20." In response to this instruction, the corresponding configuration information is updated in the metadata. This design allows the system to flexibly adjust the default value settings for new data without affecting existing data.

[0048] Furthermore, when a user or application sends a data read instruction, the system checks whether the attributes of the queried element are empty. If the attribute value is empty (for example, the "age" attribute of a "person" node is unset), the system returns a secondary default value (for example, "18") as the attribute value. If the attribute value is not empty, the system returns the actual stored value of the attribute. This mechanism ensures that query results remain consistent and complete even if null values ​​exist in the database, improving the convenience of data use.

[0049] It can be understood that in this embodiment, the first default value is the write default value, and the second default value is the read default value. The first default value is used to fill in the value corresponding to the attribute in the metadata of the graph database when data is written, and the second default value is used to query the query results containing the attribute from the graph database when data is read.

[0050] Specifically, the first default value (write default value) plays a role in data write operations. When a user creates a new node or relationship but doesn't explicitly specify values ​​for certain properties, the write default value automatically populates those properties. For example, when creating a new "Person" node, if the user doesn't specify a value for "Age," the system automatically populates that property with the write default value of "20."

[0051] The second default value (read default value) is used during data read operations. When query results contain elements with empty attributes, the system replaces these empty values ​​with the read default value. For example, when querying all "Person" nodes, for those nodes with an empty "Age" attribute, the system will display the read default value of "18" in the results instead of null or empty values.

[0052] Furthermore, in this embodiment, when the first default value is updated in response to a default value modification instruction, the second default value remains unchanged. This design allows the system to maintain a consistent processing of historical data while modifying the default value of new data (writing the default value).

[0053] For example, if an administrator changes the write default value of the "Age" attribute of a "Person" node from "18" to "20," the read default value remains "18." This means that newly created "Person" nodes without a specified "Age" will use "20" as the default value, while nodes with an empty "Age" in historical data returned by queries will still display "18." This mechanism effectively avoids data inconsistencies caused by default value changes, especially when processing historical data.

[0054] Specifically, when a user or application sends a write instruction to create a new element or update an existing one, the system checks whether the attribute has been explicitly assigned a value. If the user does not explicitly specify a value for the attribute, the attribute is temporarily logically filled with the current first default value (the write default value). This filling does not involve actual storage and is performed only at the metadata level, avoiding backfilling of the original data, ensuring data integrity, and preventing potential constraint conflicts later.

[0055] For example, when a new "person" node is created but the "age" value is not specified, the "age" attribute is logically filled at the metadata level using the current write default value "20" before being written to the database.

[0056] In this embodiment, in response to a data read instruction, it is determined whether the attribute of any element is empty. If so, a second default value is returned; if not, the actual value corresponding to the attribute is returned. The method also includes: for records to be verified, checking the actual stored value of the attribute, and if it is empty, using the read default value as the logical value; substituting the obtained attribute value into index, foreign key and other constraint rules to verify whether it meets the preset conditions to ensure that the historical data is compatible with the constraints.

[0057] Specifically, during the data read process, not only will the appropriate value (actual value or read default value) be returned, but further processing will also be performed on records that require verification. First, the actual stored value of the attribute is checked. If the value is found to be empty, the read default value (Read Default) is used as the logical value of the attribute for subsequent processing.

[0058] The retrieved attribute values ​​(whether actual values ​​or read default values) are then substituted into constraints such as indexes and foreign keys to verify that they meet the pre-set conditions. This step ensures that even historical data using read default values ​​remains compatible with the various constraints in the system, avoiding data integrity issues caused by improperly set default values.

[0059] For example, if the "Age" attribute of a "Person" node is used as part of an index, ensure that after using the read default value "18" instead of null values, the node can still participate in the index operation correctly and will not cause index invalidation or query errors due to null values.

[0060] Example 2

[0061] This application also provides a graph database attribute management system. Figure 2 This is a structural block diagram of a graph database attribute management system according to an embodiment of the present application. Figure 2 As shown, the system includes: a configuration module 20 and a read-write module 21, wherein:

[0062] The configuration module 20 is used to initialize the element with equal first default value and second default value when a new attribute is added to the element in the graph database;

[0063] Specifically, the configuration module is responsible for setting initial default values ​​for newly added properties for elements (such as nodes or relationships) in the graph database. When a system administrator or user adds a new property through the graph database management interface, the configuration module automatically initializes two identical default values ​​for that property: a primary default value and a secondary default value. For example, when adding a "Year of Establishment" property to the "Company" node type, the configuration module sets both the primary and secondary default values ​​to "2000."

[0064] Record the current configuration information of the first default value and the second default value in the metadata, and configure the data backfill state of the element to disable triggering;

[0065] After setting default values, the configuration module 20 persistently stores this configuration information in the graph database's metadata table. The metadata table contains records of data structure, attribute definitions, default values, and other information. For example, for the "Year of Establishment" attribute of the "Company" node, the system creates a record in the metadata table, indicating that both the first and second default values ​​are "20." The configuration module also marks the data backfill status of this element as disabled, meaning that the system will not automatically backfill existing data, thus avoiding performance issues and data consistency risks that may arise from large-scale data modifications.

[0066] Read / Write Module 21 is used to respond to a default value modification instruction, update the first default value, and perform data separation reading and writing based on the first and second default values ​​of the attribute. Read / Write Module 21 is responsible for handling default value updates. When the system receives a default value modification instruction, Read / Write Module 21 updates the first default value (writes the default value) and simultaneously updates the corresponding configuration record in the metadata table. For example, if an administrator decides to change the first default value of the "Year of Establishment" attribute of the "Company" node from "2000" to "2010", Read / Write Module 21 will execute this update and ensure that the record in the metadata table is updated accordingly.

[0067] The read / write module 21 is further configured to respond to a data read instruction and determine whether an attribute of any element is empty. If so, the second default value is returned; otherwise, the actual value corresponding to the attribute is returned.

[0068] The read / write module 21 is responsible for processing data queries and read operations. When the system receives a data read instruction, the read / write module checks whether the attributes of the queried element are empty. If the attribute value is empty (for example, the "Year of Establishment" attribute of a "Company" node is unset), the read / write module returns a second default value (for example, "2000") as the attribute value. If the attribute value is not empty, the read / write module returns the actual stored value of the attribute. This mechanism ensures that query results remain consistent and complete even if null values ​​exist in the database, improving data usability.

[0069] In this embodiment, the first default value is the write default value, and the second default value is the read default value. The first default value is used to fill in the value corresponding to the attribute in the graph database when writing data, and the second default value is used to query the query results containing the attribute from the graph database when reading data.

[0070] Specifically, the system's first default value (write default) is used exclusively for data write operations. When a user or application creates a new node or relationship but doesn't explicitly specify values ​​for certain properties, the system automatically populates those properties with the write default value. For example, when creating a new "Company" node, if the user doesn't specify a value for "Year of Establishment," the system automatically populates that property with the write default value of "2010."

[0071] The second default value (read default value) is specifically used for data read operations. When query results contain elements with empty properties, the system replaces these empty values ​​with the read default value. For example, when querying all "Company" nodes, for those nodes with an empty "Year of Establishment" property, the system will display the read default value "2000" in the results instead of an empty or null value.

[0072] In this embodiment, when the read / write module 21 updates the first default value in response to the default value modification instruction, it keeps the second default value unchanged.

[0073] This design ensures that when the read-write module 21 updates the write default value, the read default value will not be modified at the same time. This mechanism allows the system to maintain a consistent processing method for historical data while modifying the default value of new data. For example, when an administrator changes the write default value of the "Year of Establishment" attribute of the "Company" node from "2000" to "2010", the read default value remains "2000". This means that newly created "Company" nodes that do not specify an "Year of Establishment" will use "2010" as the default value, while nodes with an empty "Year of Establishment" in the historical data returned by the query will still be displayed as "2000". This mechanism effectively avoids data inconsistencies caused by changes in default values, especially when processing historical data.

[0074] It should be noted that both Example 1 and Example 2 are a method for managing graph database attributes.

[0075] In one embodiment, a computer device is provided, which may be a terminal. The computer device includes a processor, memory, a network interface, a display screen, and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements a method for attribute management in a graph database. The display screen of the computer device may be a liquid crystal display or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a key, trackball, or touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse.

[0076] In one embodiment, Figure 3 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, such as Figure 3 As shown, an electronic device is provided, which may be a server, and its internal structure diagram may be as shown in FIG. Figure 3 As shown. The electronic device includes a processor, a network interface, an internal memory, and a non-volatile memory connected via an internal bus, wherein the non-volatile memory stores an operating system, a computer program, and a database. The processor is used to provide computing and control capabilities, the network interface is used to communicate with external terminals via a network connection, the internal memory is used to provide an environment for the operation of the operating system and the computer program, and when the computer program is executed by the processor, it implements a graph database attribute management method, and the database is used to store data.

[0077] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0078] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0079] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it refer to independent or alternative embodiments that are mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments unless there is a conflict.

[0080] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0081] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. A method for attribute management in a graph database, characterized in that: Applied to a graph database, the method includes: When a new attribute is added to an element in the graph database, initializing the element with equal first and second default values; Recording the current configuration values ​​of the first default value and the second default value in metadata, and configuring the backfill state of the attribute to disable triggering; In response to a default value modification instruction, the first default value is updated, and data separation reading and writing based on attribute dual default values ​​is performed according to the first default value and the second default value; The first default value is a write default value, and the second default value is a read default value. The first default value is used to fill in the value corresponding to the attribute in the metadata of the graph database when writing data, and the second default value is used to query the query result containing the attribute from the graph database when reading data; In response to a default value modification instruction, when updating the first default value, the second default value remains unchanged; Performing data separation reading and writing based on attribute dual default values ​​according to the first default value and the second default value includes: When adding or updating an element, responding to a write instruction, determining whether the attribute of the element is explicitly assigned a value; if not, temporarily logically filling the attribute with the first default value; and if so, actually filling the attribute with the result of the explicit assignment; When querying data, responding to a data read instruction, determining whether the attribute of any element is empty, if so, returning the second default value, if not, returning the actual value corresponding to the attribute.

2. The method according to claim 1, characterized in that After returning the actual value corresponding to the attribute, the method further includes: For the record to be verified, check whether the attribute corresponds to the actual stored value, and if not, use the second default value as the logical value; Substitute the obtained logical value into the index and foreign key constraint rules to verify whether the updated attribute meets the preset constraint conditions. If so, output the query result.

3. The method according to claim 1, characterized in that The elements are nodes and edges in the graph database, the nodes represent data in the graph database, and the edges are relationships between data.

4. A graph database attribute management system, characterized in that: The system includes: a configuration module and a read-write module, wherein: The configuration module is configured to, when a new attribute is added to an element in the graph database, initialize a first default value and a second default value equal to the element, record current configuration information of the first default value and the second default value in metadata, and configure the data backfill state of the element to disable triggering; The read / write module is used to respond to the default value modification instruction, update the first default value, and perform data separation reading and writing based on the attribute dual default value according to the first default value and the second default value; The first default value is a write default value, and the second default value is a read default value. The first default value is used to fill in the value corresponding to the attribute in the metadata of the graph database when writing data, and the second default value is used to query the query result containing the attribute from the graph database when reading data; In response to a default value modification instruction, when updating the first default value, the second default value remains unchanged; Performing data separation reading and writing based on attribute dual default values ​​according to the first default value and the second default value includes: When adding or updating an element, responding to a write instruction, determining whether the attribute of the element is explicitly assigned a value; if not, temporarily logically filling the attribute with the first default value; and if so, actually filling the attribute with the result of the explicit assignment; When querying data, responding to a data read instruction, determining whether the attribute of any element is empty, if so, returning the second default value, if not, returning the actual value corresponding to the attribute.

5. A computer device comprising 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 according to any one of claims 1 to 3 is implemented.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.

Citation Information

Patent Citations

  • Graph index configuration method and device, storage medium and computer equipment

    CN116431201A

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

    CN119758899A