A construction method and query method for relational database version snapshot

By using the content addressing algorithm and tree directory structure in the relational database, system-level version snapshot control and query are realized, which solves the problem in the existing technology that the overall version history of the system and multi-object correlation query cannot be traced, and improves data efficiency. Change the efficiency and speed of difference queries.

CN114385587BActive Publication Date: 2024-09-27NO 709 RES INST OF CHINA SHIPBUILDING IND CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111556000.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2024-09-27
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

The existing technology is difficult to implement the historical tracing of version snapshots of the entire system and the correlation query of historical information between multiple objects in a relational database, and cannot meet the needs of obtaining historical versions of business objects and their version information.

Method used

The version snapshot construction method for relational databases is adopted, the object content is keyed through the content addressing algorithm, a tree directory structure is established, the object identifier and the content addressing identifier are stored, and the snapshot information is stored in the database table through recursive operations, achieving Snapshot control and query of all versions of the system.

Benefits of technology

It achieves the ability to quickly trace system change history while retaining the relationship query function. It can understand the status of business objects and other objects through version tracing, improves the speed of object change difference query, and reduces the time to obtain version snapshots.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385587B
    Figure CN114385587B
Patent Text Reader

Abstract

The present invention discloses a construction method and query method for relational database version snapshots. The construction method includes extracting objects from a database, obtaining object identifiers and object contents; keying the object contents through a content addressing algorithm to obtain the object content addressing identifier; establishing an object tree directory; inserting the object identifier and the object content addressing identifier on a leaf node, and obtaining the current version snapshot by recursively going up to the root node; when data changes, obtaining a new version snapshot, and combining all version snapshots into a snapshot library, and associating and storing the object identifier, submission information, and object content addressing identifier in a database table. The version submission number corresponding to the object is queried through the object identifier, and the corresponding version snapshot and each leaf node information in the snapshot are obtained through the version submission number, and the object content information associated with the content addressing identifier is used to obtain the content of other associated objects in the version snapshot.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a construction method and a query method for a relational database version snapshot. Background Art

[0002] In application systems, we often need to trace the historical information of data changes. For example, a design drawing may have been modified in multiple versions. When all historical versions of this design drawing are needed, we need to track the version of the design drawing object.

[0003] At present, application systems in the industry usually use a similar event tracing architecture to implement version tracking of data objects. The principle is not that the database directly stores the historical information of the object, but that it tracks the event sequence of all change operations of the stored object. Specifically, each change event contains the ID and change content of the changed object. The historical information of a version of the object is generated by superimposing the change event sequence of the object.

[0004] However, this event tracing method can only track the version of a single business object, and cannot trace the historical information of multiple objects at the same time, that is, it is impossible to obtain the snapshot history of the entire system. When we need to obtain not only the historical version of the business object, but also the version information corresponding to the historical version of the business object, we cannot achieve our goal through the existing methods. Therefore, what we need is to control the snapshots of all versions of the entire system, rather than version tracking of a single object data.

[0005] Traditional snapshot-level version control implementation technologies include SVN and Git. SVN is an incremental version control system that does not retain each version in its entirety but instead records the differences between versions. Git stores the entire snapshot based on content addressing. Although this type of technology has the ability to perform snapshot-level version control, it is unable to implement associated queries of version snapshots between data objects because its underlying layer is the file system.

[0006] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in the field of this technology. Summary of the invention

[0007] The technical problem to be solved by the present invention is how to retain the relationship query function while having the ability to quickly trace the system change history, and also to understand the status of other objects associated with the business object through version tracing.

[0008] The present invention adopts the following technical solution:

[0009] In a first aspect, the present invention provides a method for constructing a version snapshot for a relational database, comprising:

[0010] Extract objects in the database and obtain the object's identifier and content;

[0011] The content of the object is keyed by the content addressing algorithm to obtain the content addressing identifier of the object;

[0012] Establish a tree directory of objects: The tree directory is layered into the first layer, the second layer, ... and the nth layer, where n is an integer greater than or equal to 3. The category of the database object determines the number of layers of the tree directory. The root node is the first layer of the tree directory, which is used to distinguish different snapshot versions; the nth layer is the leaf node layer, which is used to store object identifiers and content addressing identifiers of objects, and each node in the n-1th layer corresponds to 256 leaf nodes and is numbered 0, 1, 2...255;

[0013] The leaf node storage location corresponding to the object is obtained through the category to which the object belongs and the object identifier, and then stored. The content addressing identifier corresponding to the node at the n-1th layer is obtained through the content addressing algorithm, and then the root node is obtained through recursive upward operation to submit and obtain the submission information. The object identifier, submission information and the object's content addressing identifier are associated and stored in a relational database table to obtain the current version snapshot;

[0014] When the content of the object of the current snapshot changes, the current version snapshot library is copied, and the content of the changed object data is obtained through the addressing algorithm to obtain the content addressing identifier, and then the key-value pair information consisting of the object identifier and the obtained content addressing identifier is replaced with the leaf node at the corresponding position of the copy, and then the root node is obtained through recursive upward operation to submit, and the object identifier, submission information and the object's content addressing identifier are associated and stored in the relational database table to obtain a new version snapshot;

[0015] All versions of snapshots are gathered together to form a snapshot library for object data identification retrieval.

[0016] Preferably, before establishing the tree directory of objects, the process also includes grouping of database objects, specifically, obtaining the categories of the objects, and grouping the objects in the database according to the categories to which the objects belong.

[0017] Preferably, obtaining the leaf node storage location corresponding to the object according to the category to which the object belongs and the identifier of the object specifically includes:

[0018] According to the category to which the object belongs, determine the n-1 layer of nodes associated with the object;

[0019] The content addressing identifier of the object is modulo 256, and the remainder obtained corresponds to the leaf node number under the node at the n-1th level associated with the object.

[0020] Preferably, the content corresponding to the node of the n-1th layer is all leaf node information stored corresponding to the node, and the leaf node information stored corresponding to the node is converted into a content addressing identifier corresponding to the node of the n-1th layer using a content addressing algorithm.

[0021] Preferably, the change of an object includes not only a change in the content of the object, but also a change in the addition and deletion of an object, specifically:

[0022] When a new object is added, the current snapshot is copied, and the category to which the new object belongs and the identifier of the new object are used to obtain the leaf node storage location corresponding to the object. The identifier and content addressing identifier of the new object are then stored in the corresponding leaf node. The root node is obtained through recursive upward operations to submit the object, obtain the submission information, and store the object identifier, submission information, and the content addressing identifier of the object in a relational database table.

[0023] When deleting an object, copy the current snapshot and delete the identifier and content addressing identifier corresponding to the object. Then, recursively operate upward to obtain the root node for submission, obtain the submission information, and store the object's identifier, submission information and the object's content addressing identifier in a relational database table.

[0024] Preferably, the recursive upward operation method to obtain the root node for submission is specifically as follows: taking the lower-level node information associated with the upper-level node as the content of the upper-level node, obtaining the key-value pair consisting of the upper-level node identifier and the content addressing identifier, and storing it on the corresponding node; starting from the leaf node, operating upward in sequence until the root node identifier and content addressing identifier are obtained, and stored on the root node.

[0025] Preferably, the storage relational database table that associates the object identifier, submission information, and the object content addressing identifier is specifically:

[0026] When obtaining the first version snapshot of the database, it is necessary to store the identification, submission information and content addressing identification of all database objects in a relational database table;

[0027] When obtaining a snapshot of the database other than the first version, it is only necessary to store the identifier of the changed object, the commit information, and the content addressing identifier of the object in an associated storage relational database table.

[0028] Preferably, there may be one or more objects whose contents change simultaneously.

[0029] Preferably, the submission information specifically includes: the submission number of the version, the submitter and the submission time.

[0030] In a second aspect, the present invention provides a query method for relational database version snapshots based on the snapshot library constructed in the first aspect, specifically comprising:

[0031] Get the ID of the object to be queried;

[0032] Using the object identifier, query all submission information associated with the object identifier in the database table, and obtain the submission number in all submission information;

[0033] Use the commit number to find the corresponding version snapshot in the snapshot repository, as well as the key-value pair information consisting of the object identifier and content addressing identifier on the leaf node contained in the snapshot;

[0034] Use content addressing to identify the content information of the associated object and obtain the content of other associated objects in the version snapshot.

[0035] The present invention obtains all version snapshots of an object through a construction method of a relational data version snapshot, associates the object with the object through an object identifier and an object content addressing identifier, obtains a version snapshot through recursion, and stores the object identifier, the version submission number, and the object content addressing identifier in a relational database table. When querying business object association information, the corresponding version submission number in the object database is queried through the object identifier, and the corresponding version snapshot and each leaf node information on the snapshot are obtained through the version submission number, and then the other object data content associated with the business object is obtained through the reverse algorithm of the content addressing reverse algorithm. The present invention only needs to compare the content identifier of the business data to determine whether the data record has been modified, thereby improving the speed of object change difference query; the present invention constructs a tree directory structure based on content addressing, which can realize tracking all version snapshots of the entire system through the information of the submission node; in addition, in the process of obtaining the root node through recursion, only the node branch corresponding to the object that has changed needs to be updated, and other unchanged ones are directly copied, thereby reducing the time spent on obtaining the version snapshot. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0037] Figure 1 It is a flow chart of a method for constructing a version snapshot of a relational database provided by an embodiment of the present invention;

[0038] Figure 2It is a flow chart of a method for constructing a version snapshot of a relational database provided by an embodiment of the present invention;

[0039] Figure 3 It is a schematic diagram of a recursive process of a construction method for a relational database version snapshot provided by an embodiment of the present invention;

[0040] Figure 4 It is a flow chart of a method for constructing a version snapshot of a relational database provided by an embodiment of the present invention;

[0041] Figure 5 It is a flow chart of a method for constructing a version snapshot of a relational database provided by an embodiment of the present invention;

[0042] Figure 6 It is a schematic diagram of a query method for relational database version snapshots provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0044] In the description of the present invention, the terms "inside", "outside", "longitudinal", "lateral", "up", "down", "top", "bottom" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and do not require that the present invention must be constructed and operated in a specific orientation. Therefore, they should not be understood as limitations on the present invention.

[0045] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0046] Embodiment 1:

[0047] Embodiment 1 of the present invention provides a method for constructing a version snapshot of a relational database, such as Figure 1 As shown, specifically including:

[0048] Step 201: extract the content object from the database, and obtain the object identifier and the content of the object.

[0049] The database involved in the embodiment of the present invention is a relational database. In a relational database, the content of an object is also called the information of the object, which is information describing different types of objects, including metadata information of the object itself, link relationship information between the object and other objects, and other types of information data. The identification of an object is similar to a human fingerprint. For an object, modifying its content will not cause a change in the object identification. For example, the price of pork in market A is 10 yuan / jin, and in market B it is 11 yuan / jin. At this time, the object is pork, and the price corresponds to the content of the object. No matter how the price changes, pork as an identification will not change.

[0050] Step 202: key-value the content of the object through a content addressing algorithm to obtain a content addressing identifier of the object.

[0051] Among them, when constructing the version snapshot of the present invention, if the content of the object is stored in the version snapshot, the storage overhead of the snapshot version will be too large, and it will be difficult to implement the object content tracking and subsequent query process of related objects. The present invention converts the content of the object into a content addressing identifier through a content addressing algorithm key, and stores the content addressing identifier on the corresponding node. The content addressing identifier is actually a character string translated by the computer from the object content, so that in the query process, it is only necessary to track the object content identifier and the object identifier of the object to see whether the object has been modified in all versions. When the content of the object is modified, the object identifier will not change, but the object content addressing identifier will change. By tracking the object identifier and comparing the object content identifier with the same object identifier, it is possible to find out how many times the object has been modified.

[0052] Step 203: The tree directory is layered, in order of the first layer, the second layer... and the nth layer, where n is an integer greater than or equal to 3, wherein the category of the database object determines the number of layers of the tree directory, the root node is the first layer of the tree directory, and is used to distinguish different snapshot versions; the nth layer is the leaf node layer, and is used to store object identifiers and content addressing identifiers of objects, and each node of the n-1th layer corresponds to 256 leaf nodes and is numbered 0, 1, 2...255.

[0053] Among them, this step is a step of establishing a tree directory of objects. After obtaining the objects and the contents of the objects in the relational database and converting the objects and the contents of the objects into identifiers that are easy to store, the objects of the relational version database need to be stored according to certain rules to form a version snapshot. The present invention defines a structural storage model for a tree directory, which sets the number of tree layers according to the structure of the tree. The corresponding number of layers is objectized by the type of relational database object, and the first layer is defined as the root layer, and the last layer is defined as the leaf layer. The middle layer can be understood as the trunk of the tree corresponding to the category node of the database. The category to which the object belongs can be determined from the composition of the content of the object, such as Figure 2 As shown, it is assumed that the tree directory established has only 4 layers. Excluding the root node and leaf nodes, there are only two middle layers. Assuming that the categories of the middle layer are year and project, considering that there is only one root node, the leaf nodes are set to at least 256. According to the amount of data, the data and years with less data are usually set in the second layer, and the data with more data are set in the third layer. Computers use binary algorithms, and object identifiers are usually represented by hexadecimal GUIDs (Globally Unique Identifiers). In order to facilitate computer operations, the leaf node tree corresponding to each node in the n-1 layer is set to 256. The value range of the last two digits of the object's GUID string is 00 to ff, where the digits and the tens digit are in hexadecimal. The numbers on each digit are arranged as follows: 0, 1, 2, ..., 9, a, ..., f. Convert the letters to numbers, a corresponds to 10, b corresponds to 11, ..., f corresponds to 15. For example, the leaf number corresponding to a GUID with the last two digits af is a×16+f, where a corresponds to 10 and f corresponds to 15. Then the leaf node number corresponding to the GUID is 175. This method is used to match the object's identifier. When using methods other than GUID to define the identifier of the object in the database, the corresponding leaf node under each node of the n-1 layer will also change. For example, when using decimal identifiers, 100 nodes are usually set under each node of the n-1 layer, and the remainder obtained by taking the remainder is stored in the corresponding leaf node.

[0054] Step 204: Obtain the leaf node storage location corresponding to the object through the category to which the object belongs and the object's identifier, and store it. Obtain the content addressing identifier corresponding to the node of the n-1th layer through the content addressing algorithm, and then obtain the root node through recursive upward operations to submit, obtain the submission information, and store the object identifier, submission information and the object's content addressing identifier in a relational database table to obtain a snapshot of the current version.

[0055] Among them, after completing the construction of the object tree directory, the database object identifier and the object content addressing identifier need to be inserted into the leaf node. The category of the object can be known from the object content information. The object identifier is obtained by the remainder operation to obtain the object identifier and the content addressing identifier should be stored in the leaf node position. A leaf node does not uniquely store the identifier of an object. When two objects are of the same category and the calculated remainders are the same, the identifiers and content addressing identifiers of the two objects will be stored in the leaf node with the same number, and are usually stored as a key-value pair consisting of the object identifier and the object content addressing identifier. After the key-value pairs consisting of the object identifier and the object addressing identifier of all objects are stored in the tree directory structure, when operating the nodes of the n-1th layer, the leaf node information contained under the nodes of the n-1th layer is regarded as the content, and the identifier and content addressing identifier of each node of the n-1th layer are obtained by the content addressing algorithm. The identifier and content addressing identifier of the root node can be obtained by recursively using the same method in turn. When the acquisition is completed, it is submitted, and the submission information will be recorded at this time. The commit information includes the time of submission, the submitter (modifier) ​​and the commit number. The commit information is mainly used to distinguish different version snapshots. In order for the query process to use objects for associated queries, the object identifier, the version submission number and the content addressing identifier are bound and stored in a table in the relational database. When performing an object snapshot query, all the submission numbers associated with the object identifier can be queried in the relational database through the object identifier. Each submission number corresponds to a version. Among these versions, by comparing the content addressing identifiers of data objects in different versions and the time of version submission, you can know how many versions the object has been modified. When the content of the associated object of a certain version is needed, after obtaining the tree directory of the version, the content addressing identifier on the corresponding leaf node is translated into the content of the object and output, and the content information of other objects associated with the object can be known.

[0056] Step 205: When the content of the object of the current snapshot changes, the current version snapshot library is copied, and the content of the changed object data is obtained through the addressing algorithm to obtain the content addressing identifier, and then the key-value pair information consisting of the object identifier and the obtained content addressing identifier is replaced to the leaf node at the corresponding position of the copy, and then the root node is obtained through recursive upward operation to submit, and the object identifier, submission information and the object's content addressing identifier are associated and stored in a relational database table to obtain a new version snapshot.

[0057] The embodiment of the present invention uses object tracking as an object, and needs to obtain all version snapshots of the relational database. That is to say, as long as the content of the object in the database changes, and new or deleted objects appear in the database, a version snapshot library will be established to record the change process of the relational database objects. In actual situations, there may be one or more objects with content changes. When the content of an object changes, the content identifier of the object will also change accordingly, but the identifier of the object will never change. The content addressing identifier of the changed object is modified recursively and replaced on the corresponding branch. The content addressing identifiers of all nodes associated with the change in the object content (including the addition or deletion of the data) will change accordingly, and a new version snapshot of the object after the change is obtained through recursion. Figure 3 As shown, it is a diagram showing the process of recursively obtaining the root node from the leaf node. The object identifier and object content addressing identifier in the figure are specifically presented using the code code and sha1 value respectively.

[0058] Step 206: All versions of snapshots are gathered together to form a snapshot library for object data identifier retrieval.

[0059] The construction method of the embodiment of the present invention is mainly to present all versions of objects and object content changes. From the perspective of storage, tracking objects and object data may cause excessive storage overhead. Through the corresponding algorithm, the content of the object is converted into a uniquely identified content addressing identifier (actually a string) for tracking, which not only solves the overhead problem, but also enables accurate tracking. A storage model of an object-relational database is constructed, and the identifier of the object and the content addressing identifier of the object are stored in the model according to the rules set for storage to obtain a version snapshot; all version snapshots of each object content change are collected together to form a snapshot library. The present invention constructs a tree directory structure based on content addressing, which can track all version snapshots of the entire system by submitting node information; in addition, in the process of recursively obtaining the root node, only the node branch corresponding to the object that has changed needs to be updated, and the other unchanged ones are directly copied, which reduces the time spent on obtaining version snapshots.

[0060] In order to illustrate the details of the relational database version snapshot construction method according to the embodiment of the present invention, the embodiment of the present invention is further described below.

[0061] Before establishing the object tree directory, the grouping of database objects should also be included, specifically: obtaining the category of the object, and grouping the objects in the database according to the category to which the object belongs.

[0062] Among them, in relational databases, the content of an object inherently contains a description of the category to which the object belongs. Generally speaking, for relational database objects, the classification of the object has been clarified before taking a snapshot. The category of the object determines the branch to which the object affects, that is, the type of the object directly determines the association node between the object and the n-1th level of the tree directory, and then the leaf node position of the key-value pair composed of the object identifier and the object's content addressing identifier can be determined through the object identifier.

[0063] Furthermore, the leaf node storage location corresponding to the object is obtained by the category to which the object belongs and the identifier of the object, such as Figure 4 As shown, specifically including:

[0064] Step 301: Determine the n-1-layer nodes associated with the object according to the category to which the object belongs.

[0065] Step 302: The content addressing identifier of the object is modulo 256, and the obtained remainder corresponds to the leaf node number under the node at the n-1th level associated with the object.

[0066] Among them, except for the root node layer and the leaf node layer, the other layers of the tree directory of the object can be understood as category layers. The category of the object can directly clarify the specific branch from the root node to the leaf node that the object affects. The branch represents a node line composed of associated nodes from the root node to the leaf node. When the object identifier and the object content addressing identifier are stored in the leaf node of the corresponding branch, since the upper layer node of the object will regard the next layer node information associated with it as the content of this node, when the object content changes, the object content addressing identifier of the branch from the leaf node to the root node affected by the corresponding object will also change accordingly.

[0067] The embodiments of the present invention do not clearly give the specific method used for object identification. Any identification that can distinguish different objects can be applied here. However, one point worth considering is that the present invention needs to correspond the object identification to the number of the leaf node, and the corresponding object identification needs to be convertible into a number, and the range of the converted number is usually greater than the number of leaf nodes corresponding to each node in the n-1 layer. In order to unify all the methods of identifying objects that meet the conditions, after converting the object identification into a number, divide it by 256 to obtain the remainder, and the remainder corresponds to the corresponding leaf node number. For computers, object identification is generally encoded in binary or hexadecimal, and the number corresponding to the object identification can usually be easily obtained.

[0068] Furthermore, the object identifier, submission information and content addressing identifier of the object are associated and stored in a relational database table, such as Figure 5 Specifically,

[0069] Step 401: when obtaining the first version snapshot of the database, it is necessary to store the identifiers of all database objects, the submission information and the content addressing identifiers of the objects in a relational database table in association;

[0070] Step 402: When obtaining a snapshot of the database other than the first version, it is only necessary to store the identifier of the changed object, the submission information, and the content addressing identifier of the object in association in a relational database table.

[0071] Among them, when searching for a snapshot of an object using the storage model constructed by the embodiment of the present invention, it is necessary to use the object identifier in the table in the relational database to search for the submission number associated with the object. In order to ensure the comprehensiveness of the query, the table of the relational database needs to contain the object identifier, submission information and content addressing identifier association information of all objects. When the first version snapshot of the database is obtained, the object identifier, submission information and content addressing identifier association information of all objects are stored in the database table. When the data changes later, it is only necessary to add a row in the database table to store the identifier, submission information and object content addressing identifier information of the changed object.

[0072] Furthermore, in a relational database, the content change of an object includes not only the change of the content of the object, but also the addition and deletion of an object.

[0073] When a new object is added, the current snapshot is copied, and the category of the newly added object and the identifier of the newly added object are used to obtain the leaf node storage location corresponding to the object. The identifier and content addressing identifier of the newly added object are then stored in the corresponding leaf node. The root node is obtained through recursive upward operations to submit the submission information. The object identifier, submission information and content addressing identifier of the object are associated and stored in a relational database table to obtain the corresponding version snapshot.

[0074] When deleting an object, copy the current snapshot and delete the identifier and content addressing identifier corresponding to the object. Then, recursively operate upward to obtain the root node for submission, obtain the submission information, and associate the object's identifier, submission information, and the object's content addressing identifier in a storage relational database table to obtain the corresponding version snapshot.

[0075] Example 2

[0076] like Figure 6As shown, the query method flow of the relational database version snapshot of the embodiment of the present invention is shown. The query method of the embodiment of the present invention is based on the version snapshot library of the relational database constructed in Example 1. The object identifier is obtained through a given object, and then the version snapshot submission number associated with the object identifier is queried in the table of the relational database through the object identifier, and then the corresponding version snapshot is found through the submission number, and the content addressing identifiers of other objects associated with the given object are restored to the content of the object.

[0077] Step 501: Obtain the identifier of the object to be queried;

[0078] Step 502: using the object identifier, query all submission information associated with the object identifier in the table of the database, and obtain the submission number in all submission information;

[0079] Step 503: Use the commit number to find the corresponding version snapshot in the snapshot library, as well as the key-value pair information consisting of the object identifier and the content addressing identifier on the leaf node contained in the snapshot;

[0080] Step 504: Use content addressing to identify the associated object content information and obtain the content of other associated objects in the version snapshot.

[0081] The query method of the embodiment of the present invention is based on the construction of the snapshot library of the embodiment, and realizes querying all historical version snapshots associated with the object through a given object. The content addressing identifier on the leaf node of the version snapshot is converted into the content of the object for output, so that the content of the object associated with the given object can be obtained; not only that, by comparing the content addressing identifiers and submission information in different snapshots of the object, it can be known how many times the object has been modified and who made the corresponding modifications and when. By associating the object content and the submission number of the version snapshot, the object association query is realized. While retaining the relationship query function, it can also have the ability to quickly trace the system change history, and can also understand the situation of other objects associated with the business object through version tracing.

[0082] A person skilled in the art may understand that all or part of the steps in the various methods of the embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

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

Claims

1. A method for constructing a version snapshot of a relational database, characterized in that: include: Extract objects in the database and obtain the object's identifier and content; The content of the object is keyed by the content addressing algorithm to obtain the content addressing identifier of the object; Establish a tree directory of objects: The tree directory is layered into the first layer, the second layer, ... and the nth layer, where n is an integer greater than or equal to 3. The category of the database object determines the number of layers of the tree directory. The root node is the first layer of the tree directory, which is used to distinguish different snapshot versions; the nth layer is the leaf node layer, which is used to store object identifiers and content addressing identifiers of objects, and each node in the n-1th layer corresponds to 256 leaf nodes and is numbered 0, 1, 2...255; The leaf node storage location corresponding to the object is obtained through the category to which the object belongs and the object identifier, and then stored. The content addressing identifier corresponding to the node at the n-1th layer is obtained through the content addressing algorithm, and then the root node is obtained through recursive upward operation to submit and obtain the submission information. The object identifier, submission information and the object's content addressing identifier are associated and stored in a relational database table to obtain the current version snapshot; When the content of the object of the current snapshot changes, the current version snapshot library is copied, and the content of the changed object data is obtained through the addressing algorithm to obtain the content addressing identifier, and then the key-value pair information consisting of the object identifier and the obtained content addressing identifier is replaced with the leaf node at the corresponding position of the copy, and then the root node is obtained through recursive upward operation to submit, and the object identifier, submission information and the object's content addressing identifier are associated and stored in the relational database table to obtain a new version snapshot; All versions of snapshots are gathered together to form a snapshot library for object data identification retrieval; The method of obtaining the root node for submission by recursive upward operation is specifically as follows: taking the lower-level node information associated with the upper-level node as the content of the upper-level node, obtaining the key-value pair consisting of the upper-level node identifier and the content addressing identifier, and storing it on the corresponding node; starting from the leaf node, operating upward in sequence until the root node identifier and content addressing identifier are obtained, and stored on the root node.

2. The method for constructing a version snapshot for a relational database according to claim 1, characterized in that: Before establishing the object tree directory, the database objects are grouped, specifically, obtaining the categories of the objects and grouping the objects in the database according to the categories to which the objects belong.

3. The method for constructing a version snapshot for a relational database according to claim 2, characterized in that: The obtaining of the leaf node storage location corresponding to the object by the category to which the object belongs and the identifier of the object specifically includes: According to the category to which the object belongs, determine the n-1 layer of nodes associated with the object; The content addressing identifier of the object is modulo 256, and the remainder obtained corresponds to the leaf node number under the node at the n-1th level associated with the object.

4. The method for constructing a version snapshot for a relational database according to claim 1, characterized in that: The content corresponding to the node of the n-1th layer is all leaf node information stored corresponding to the node, and the leaf node information stored corresponding to the node is converted into the content addressing identifier corresponding to the node of the n-1th layer using a content addressing algorithm.

5. The method for constructing a version snapshot for a relational database according to claim 1, characterized in that: Object changes include not only changes in the content of the object, but also the addition and deletion of objects, specifically: When a new object is added, the current snapshot is copied, and the category to which the new object belongs and the identifier of the new object are used to obtain the leaf node storage location corresponding to the object. The identifier and content addressing identifier of the new object are then stored in the corresponding leaf node. The root node is obtained through recursive upward operations to submit the object, obtain the submission information, and store the object identifier, submission information, and the content addressing identifier of the object in a relational database table. When deleting an object, copy the current snapshot and delete the identifier and content addressing identifier corresponding to the object. Then, recursively operate upward to obtain the root node for submission, obtain the submission information, and store the object's identifier, submission information and the object's content addressing identifier in a relational database table.

6. The method for constructing a version snapshot for a relational database according to claim 1, characterized in that: The storage relational database table that associates the object identifier, submission information, and the object content addressing identifier is specifically: When obtaining the first version snapshot of the database, it is necessary to store the identification, submission information and content addressing identification of all database objects in a relational database table; When obtaining a snapshot of the database other than the first version, it is only necessary to store the identifier of the changed object, the commit information, and the content addressing identifier of the object in an associated storage relational database table.

7. The method for constructing a version snapshot for a relational database according to claim 1, characterized in that: There are one or more objects whose contents change at the same time.

8. The method for constructing a version snapshot for a relational database according to claim 1, characterized in that: The submission information specifically includes: the submission number, submitter and submission time of the version.

9. A query method for relational database version snapshots, characterized in that: The construction is completed by the construction method for relational database version snapshot according to any one of claims 1 to 8, and the query method includes: Get the ID of the object to be queried; Using the object identifier, query all submission information associated with the object identifier in the database table, and obtain the submission number in all submission information; Use the commit number to find the corresponding version snapshot in the snapshot repository, as well as the key-value pair information consisting of the object identifier and content addressing identifier on the leaf node contained in the snapshot; Use content addressing to identify the content information of the associated object and obtain the content of other associated objects in the version snapshot.