A Method and System for Traceability Code Migration and Status Management Based on Relational Databases
By generating migration fingerprint request data, reconstructing the parent-child connection path, and performing state linkage updates, the problems of hierarchical relationship offset and state inconsistency in multi-level relationship chain migration in existing technologies are solved, achieving accuracy and consistency in relationship reconstruction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING BAINAFU BIOTECHNOLOGY CO LTD
- Filing Date
- 2026-04-28
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies struggle to accurately reflect the dynamic relationship paths between original data when handling multi-level relationship chain migrations, leading to shifts in parent-child hierarchical relationships or incomplete reconstruction during the migration process.
By collecting migration request data, generating migration fingerprint request data, performing operation fingerprint matching and historical record retrieval, constructing a snapshot of the relationship before migration, reconstructing the parent-child attachment path, and using a state linkage algorithm to update the state identifier from bottom to top, the relationship reconstruction and state consistency verification are completed.
It achieves complete structural representation and state consistency control of multi-level relationships during the migration process, avoiding hierarchical misalignment and state breakage, and improving the accuracy and consistency of the migration results.
Smart Images

Figure CN122309487A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data migration management technology, and in particular to a method and system for traceability code migration and status management based on relational databases. Background Technology
[0002] With the continuous improvement of information management, traceability code management methods based on relational databases have been widely used in food traceability, pharmaceutical distribution, and industrial manufacturing, and are gradually being integrated with industrial data storage systems. Existing methods typically construct multi-table association structures between traceability codes and product batches, production processes, and distribution nodes using relational databases, and leverage transaction mechanisms to maintain data consistency. Simultaneously, data is centrally managed and organized within the industrial data storage environment. During migration, common methods include batch data migration based on primary key mapping, incremental synchronization combined with log recording, and maintaining data relationships through foreign key constraints. These methods enable the migration and continuation of traceability code data in industrial data storage scenarios across different database environments or business stages.
[0003] In practical applications, as the relationships between traceability codes become increasingly complex and the hierarchical structure continues to expand, existing technologies, when handling the migration of multi-level relationship chains, typically rely on static foreign key constraints or simple sequential migration strategies. This makes it difficult to accurately reflect the dynamic relationship paths between the original data, resulting in offsets or incomplete reconstruction of parent-child hierarchical relationships during the migration process. Summary of the Invention
[0004] In view of the aforementioned existing problems, the present invention is proposed.
[0005] Therefore, this invention provides a traceability code migration and state management method based on relational databases, which solves the problems of difficulty in accurately restoring associated paths and incomplete reconstruction of parent-child hierarchical relationships.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0007] In a first aspect, this invention provides a traceability code migration and status management method based on a relational database, comprising: collecting migration request data and extracting and associating elements from the migration request data to generate migration fingerprint request data; performing operation fingerprint matching and historical record retrieval on the migration fingerprint request data to obtain valid migration candidate data, and performing relation chain reading and version isolation on the valid migration candidate data to construct a pre-migration relation snapshot; reconstructing the parent-child connection path and synchronously correcting the hierarchical position on the pre-migration relation snapshot using a path backtracking and rearrangement algorithm to generate relation reconstruction data; employing a status linkage algorithm to write the relation reconstruction data back to the current state node by node and synchronously update the upper-level status identifier in a bottom-up order according to the parent-child hierarchy to generate status linkage data; performing version consistency verification on the status linkage data to obtain consistency-passing data, writing the consistency-passing data into the status table and synchronously updating it to generate a migration management scheme.
[0008] As a preferred embodiment of the traceability code migration and status management method based on a relational database described in this invention, the specific steps for collecting migration request data and extracting and associating elements from the migration request data are as follows:
[0009] Collect migration request data and perform field parsing and format specification to obtain standardized request data. Then, perform field decomposition and semantic mapping on the standardized request data to generate element decomposition data.
[0010] Hierarchical binding is performed on the element decomposition data to obtain behavior association identification data, and time series association relationships are established based on the behavior association identification data. The time series association relationships are then subjected to unified encoding processing to generate feature encoding data.
[0011] As a preferred embodiment of the traceability code migration and status management method based on relational database described in this invention, the generation of migration fingerprint request data refers to performing fingerprint identifier generation on feature encoding data, obtaining unique fingerprint identifier data, and associating and encapsulating the unique fingerprint identifier data with the feature encoding data.
[0012] As a preferred embodiment of the traceability code migration and status management method based on relational databases described in this invention, the specific steps for performing operation fingerprint matching and historical record retrieval on migration fingerprint request data to obtain valid migration candidate data are as follows:
[0013] The fingerprint retrieval features in the migration fingerprint request data are analyzed and combined according to the retrieval key rules to generate fingerprint retrieval constraint data;
[0014] Locate the corresponding data entity identifier of the fingerprint retrieval constraint data, read the associated link record data according to the data entity identifier, merge and organize it, and generate candidate data to be compared.
[0015] Perform operation fingerprint matching and consistency determination on the candidate data to be compared, and filter out candidate records that meet the full fingerprint matching conditions and candidate records whose conflict relationships are eliminated, and generate valid migration candidate data.
[0016] As a preferred embodiment of the traceability code migration and status management method based on relational databases described in this invention, the specific steps for reading the relational chain and isolating versions of valid migration candidate data to construct a pre-migration relational snapshot are as follows:
[0017] Read parent and child node records from valid migration candidate data and arrange them in a chained manner according to the parent-before-child order to generate a relationship chain to read the data.
[0018] Perform version isolation on the data read from the relationship chain, obtain version determination identifier data, filter the target version range based on the version determination identifier data and remove non-target version records, and generate version isolation relationship data;
[0019] Perform hierarchical restoration and content encapsulation on version isolation relationship data, obtain structural version association data, reorganize the structural version association data according to the hierarchical path order and write it into a unified structure, and generate a pre-migration relationship snapshot.
[0020] As a preferred embodiment of the traceability code migration and status management method based on relational databases described in this invention, the specific steps for generating relational reconstruction data are as follows:
[0021] The path backtracking and rearrangement algorithm is used to perform node relationship parsing and ancestor chain backtracking on the pre-migration relationship snapshot to obtain node association identification data. Based on the node association identification data, the parent node is traced back level by level and the parent-child link structure is constructed.
[0022] The parent-child link structure is reordered to obtain candidate attachment nodes. The candidate attachment nodes are then reattached to the corresponding parent node positions according to the hierarchical order in the parent-child link structure, and the order relationship of sibling nodes is adjusted to generate parent-child reconstruction path data.
[0023] Perform hierarchical position synchronization correction on the parent-child reconstruction path data, obtain hierarchical correction association data, perform structural consistency verification on the hierarchical correction association data, and generate relationship reconstruction data.
[0024] As a preferred embodiment of the traceability code migration and status management method based on relational databases described in this invention, the method employs a status linkage algorithm, which, in a bottom-up manner according to the parent-child hierarchy, reconstructs the relational data node by node, writes back the current status, and synchronously updates the status identifier of the superior level to generate status linkage data. The specific steps are as follows:
[0025] A state linkage algorithm is used to arrange the relationship reconstruction data in a bottom-up parent-child hierarchical order according to the hierarchical positioning identifier, generating hierarchical recursive node data;
[0026] Within the child node group corresponding to the same parent node, the state consistency of the hierarchical recursive node data is determined, the state consistency data is obtained, and the state consistency data is associated with the corresponding parent node to establish state transmission data.
[0027] The state in the state-transfer associated data is written back to the corresponding parent node level by level, and then used as input for the upper-level node to continue to push upwards until the top-level node, generating state linkage data.
[0028] As a preferred embodiment of the traceability code migration and status management method based on relational database described in this invention, the specific steps of performing version consistency verification on status linkage data, obtaining consistency-passing data, writing the consistency-passing data into the status table, and synchronously updating it are as follows:
[0029] Extract state version feature data from the state linkage data and match it with historical version records to generate version verification benchmark data;
[0030] Filter out the status records that meet the consistency conditions and have no conflicts from the version verification benchmark data, and generate consistency passed data.
[0031] As a preferred embodiment of the traceability code migration and status management method based on relational database described in this invention, the generation of migration management scheme refers to writing and updating the status table of consistency-passing data, obtaining migration update record data, combining the migration update record data with the associated link identifier, and performing synchronous update.
[0032] Secondly, the present invention provides a traceability code migration and status management system based on a relational database, including: a fingerprint generation module, used to collect migration request data and extract and associate elements from the migration request data to generate migration fingerprint request data;
[0033] The matching and retrieval module is used to perform operation fingerprint matching and historical record retrieval on migration fingerprint request data, obtain valid migration candidate data, and read the relationship chain and isolate the version of the valid migration candidate data to build a pre-migration relationship snapshot.
[0034] The relationship construction module is used to reconstruct the parent-child connection path and synchronously correct the hierarchical position of the relationship snapshot before migration through the path backtracking and rearrangement algorithm, and generate relationship reconstruction data.
[0035] The path reconstruction module is used to use a state linkage algorithm to write back the current state of the relationship reconstruction data node by node and update the status identifier of the upper level in a bottom-up manner according to the parent-child hierarchy, thereby generating state linkage data.
[0036] The status verification module is used to verify the version consistency of status linkage data, obtain consistency pass data, write the consistency pass data into the status table and update it synchronously, and generate a migration management plan.
[0037] The beneficial effects of this invention are as follows: Through the path backtracking and rearrangement algorithm steps, the reconstruction of parent-child connection paths and hierarchical position correction in industrial data storage scenarios are completed, so that multi-level relationships maintain complete structural expression during migration, thereby restoring complex association links and avoiding hierarchical misalignment; Through the state linkage algorithm steps, bottom-up state recursion and cross-level synchronous updates are completed in industrial data storage scenarios, so that the state of each node maintains consistent evolution, thereby ensuring the consistency control of the entire link state, improving the accuracy of relationship reconstruction and enhancing the consistency of migration results. Attached Figure Description
[0038] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart of a traceability code migration and status management method based on a relational database.
[0040] Figure 2 Flowchart for matching retrieval and relationship snapshot construction.
[0041] Figure 3 This is a flowchart for path backtracking and rearrangement.
[0042] Figure 4 This is a flowchart for state linkage processing. Detailed Implementation
[0043] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0044] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0045] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0046] Reference Figures 1-4 This is one embodiment of the present invention, which provides a method for traceability code migration and status management based on a relational database, including the following steps:
[0047] S1. Collect migration request data and extract and associate elements from the migration request data to generate migration fingerprint request data.
[0048] S1.1 Collect migration request data and perform field parsing and format specification to obtain standardized request data. Then, perform field decomposition and semantic mapping on the standardized request data to generate feature decomposition data.
[0049] It should be noted that the migration request data is collected and parsed item by item according to field type, field length, field order, and field value format. Missing fields are removed, abnormal formats are corrected, and a unified expression format is used to obtain standardized request data. From the standardized request data, the migration object, hierarchical source, operation type, time information, and status information are extracted, and the field content is mapped to clear business meaning according to the preset semantic correspondence rules to generate element decomposition data.
[0050] It should also be noted that the semantic correspondence rules extract stable correspondences between field names, field values, and context positions by performing field semantic classification and statistical analysis on historical migration request data, and establish a one-to-one mapping relationship between fields and semantic tags in combination with business meanings. In application, the field content in the standardized request data is matched with the semantic tags item by item, and the corresponding semantics are determined by keyword comparison, position constraints, and value range verification, thereby obtaining the semantic correspondence rules.
[0051] Element decomposition data is a structured representation of standardized request data obtained through field decomposition and semantic mapping. It separates migration objects, hierarchical sources, operation types, time information, and status information from the original fields one by one and transforms them into independent elements with clear business semantics, thus transforming the data from a mixed state to a parsable state. By forming element decomposition data, a unified and standardized input foundation can be provided for subsequent hierarchical binding, time series association construction, and fingerprint identification generation, thereby ensuring the consistency and comparability of data from different sources at the semantic level and improving the accuracy and stability of subsequent matching judgment and relationship reconstruction processes.
[0052] S1.2 Perform hierarchical binding on the element decomposition data, obtain behavior association identification data, establish time series association relationships based on the behavior association identification data, perform unified encoding processing on the time series association relationships, and generate feature encoding data.
[0053] It should be noted that when performing hierarchical binding on the element decomposition data, the migration object identifier is used as the positioning benchmark. The corresponding parent and child identifiers are matched item by item, and the parent identifier is written to the upper level position and the child identifier is written to the lower level position to form a parent-child belonging chain. Records under the same parent identifier are arranged in chronological order according to the order of operations, and the order is written to the previous and next related positions. The order is verified to be consistent with the parent-child relationship, thereby obtaining the behavior association identifier data. The time information and operation order in the behavior association identifier data are used as the basis to establish the time series association relationship between the previous and next, and all kinds of elements in the time series association relationship are uniformly converted into a fixed encoding format to generate feature encoding data.
[0054] S1.3. Perform fingerprint identification generation on the feature encoding data to obtain unique fingerprint identification data, and associate and encapsulate the unique fingerprint identification data with the feature encoding data to generate migration fingerprint request data.
[0055] It should be noted that the object encoding, hierarchy encoding, operation encoding, and time encoding in the feature encoding data are combined in a preset concatenation order, and characters at fixed positions are extracted and digest calculation is performed to obtain unique fingerprint identification data. The unique fingerprint identification data is written into the associated header of the feature encoding data, and the feature source, hierarchy position, and operation trajectory content are encapsulated to form a one-to-one correspondence between the unique fingerprint identification data and the feature encoding data, thereby generating migration fingerprint request data.
[0056] S2. Perform operation fingerprint matching and historical record retrieval on the migration fingerprint request data to obtain valid migration candidate data, and perform relationship chain reading and version isolation on the valid migration candidate data to build a pre-migration relationship snapshot.
[0057] S2.1. Parse the fingerprint retrieval features in the migration fingerprint request data and combine them according to the retrieval key rules to generate fingerprint retrieval constraint data.
[0058] It should be noted that the unique fingerprint identifier data, hierarchical position code, operation type code, and time range code are read from the migration fingerprint request data, and field positioning and value extraction are performed for each feature to form a feature sequence to be combined. According to the field priority and combination order in the retrieval key rules, the unique fingerprint identifier data is first selected as the main retrieval key to establish a unique positioning condition. The hierarchical position code and operation type code are concatenated in the order of association to form an auxiliary retrieval key to limit the hierarchical range and operation semantics. The time range code is converted into an interval constraint condition as a conflict exclusion key to filter records that do not meet the time continuity requirement. According to the execution order of primary retrieval key priority matching, auxiliary retrieval key convergence step by step, and conflict exclusion key screening, all types of retrieval keys are written into a unified query expression structure to generate fingerprint retrieval constraint data.
[0059] It should also be noted that the retrieval key rules are derived from the statistical analysis of high-frequency query paths and unique positioning field combinations in historical related records. By extracting the frequency of use and judgment role of unique fingerprint identification data, hierarchical position codes, time interval features, and operation type codes in the retrieval process, key fields that can stably locate data entity identifiers are selected, and retrieval key rules are formed by combining the uniqueness constraints and conflict elimination logic of field combinations.
[0060] S2.2 Locate the corresponding data entity identifier of the fingerprint retrieval constraint data, read the associated link record data according to the data entity identifier, merge and organize it to generate candidate data to be compared.
[0061] It should be noted that historical associated records are retrieved based on unique fingerprint identification data. The encoding value, hierarchical value, and time value corresponding to the fingerprint retrieval constraint data are compared in the historical associated records to locate the matching data entity identifier. The associated link record data is read based on the data entity identifier, and the associated link record data is merged, deduplicated, and sorted according to entity affiliation, hierarchical order, and time sequence to generate candidate data to be compared.
[0062] S2.3 Perform operation fingerprint matching and consistency determination on the candidate data to be compared, and filter out candidate records that meet the full fingerprint matching conditions and candidate records that have eliminated conflict relationships, and generate valid migration candidate data.
[0063] It should be noted that the object code, hierarchical code, operation code, and time code in the candidate data to be compared are compared with the migration fingerprint request data item by item, and the items that are exactly the same, the items that are different, and the items that are missing are recorded. Based on the number of items that are completely matched, the consistency of key fields, and the elimination of conflict relationships, a consistency determination is performed, and candidate records that meet the full fingerprint matching conditions and candidate records that have eliminated conflict relationships are retained to generate valid migration candidate data.
[0064] The expression for comparing the object encoding, hierarchical encoding, operation encoding, and time encoding in the candidate data with the migration fingerprint request data item by item is as follows:
[0065] ;
[0066] in, This is the fingerprint matching determination value; This represents the number of matches. The number of differences; This is the consistency judgment value for key fields.
[0067] It should also be noted that the full fingerprint matching condition is determined by statistically summarizing the consistency of the combination of object encoding, hierarchical encoding, operation encoding, and time encoding in historical matching records, and extracting stable matching patterns that simultaneously satisfy the condition of complete consistency of all fields and no conflict relationship as the judgment criterion. For example, a combination of records that simultaneously satisfies the conditions of consistent migration object identifier, consistent hierarchical encoding, consistent operation type, continuous time sequence, and no parent-child conflict or version conflict is considered a stable matching pattern. In application, each field is compared item by item and the consistency and time continuity of key fields are verified. Only when all conditions are met is the full fingerprint matching condition determined to be valid.
[0068] S2.4 Read the parent and child node records from the valid migration candidate data and arrange them in a chain-like manner according to the parent-before-child order to generate a relationship chain and read the data.
[0069] It should be noted that parent node records and child node records are extracted from the valid migration candidate data. The upper-level position is determined based on the parent node identifier. The child nodes are attached to the corresponding parent nodes one by one according to their affiliation. The attached records are arranged continuously in the order of parent before child. Adjacent records in the same level are spliced into a chain structure according to the order of occurrence to generate a relationship chain for reading data.
[0070] S2.5. Perform version isolation on the data read from the relationship chain, obtain version determination identifier data, filter the target version range based on the version determination identifier data and remove non-target version records, and generate version isolation relationship data.
[0071] It should be noted that for each record in the relational chain data, version number, version time, version status, and hierarchical path information are extracted and arranged according to the chronological order of version time within the same hierarchical path. Among the arranged records, records with currently valid version status are first identified and used as the starting point of the target version. Historical records consistent with the hierarchical path are retrieved backward from the starting point of the target version along the version time. Records with consecutive version times and historically retained version status are included in the target version range. At the same time, records with abnormal version status, overlapping version times, inconsistent hierarchical paths, or conflicting correspondences with the starting point of the target version are judged as invalid conflicting versions and excluded. The records retained in the target version range are re-aggregated and reorganized according to hierarchical path and version time to generate version isolation relational data.
[0072] S2.6 Perform hierarchical restoration and content encapsulation on the version isolation relationship data, obtain the structure version association data, reorganize the structure version association data according to the hierarchical path order and write it into the unified structure, and generate a snapshot of the relationship before migration.
[0073] It should be noted that the parent-child positions, hierarchical depth, and version content in the version isolation relationship data are restored hierarchically, and the node content on the same path is filled in according to the hierarchical order to obtain the structural version association data. The structural version association data is then reorganized according to the hierarchical path order, and the node content, version content, and path relationship are written into a unified structure to generate a pre-migration relationship snapshot.
[0074] It should also be noted that the pre-migration relationship snapshot is a structured record formed by reading the effective migration candidate data through the relationship chain and isolating the version. It completely preserves the parent-child hierarchical relationship, path structure and version status information of each node before the migration. By forming the pre-migration relationship snapshot, a traceable structural benchmark can be provided for subsequent path backtracking and rearrangement, so that the parent-child connection relationship has a reference basis in the reconstruction process, thereby avoiding hierarchical misalignment and path breakage, and ensuring the continuity and consistency of the relationship reconstruction results.
[0075] S3. Using the path backtracking and rearrangement algorithm, the parent-child connection path is reconstructed from the pre-migration relationship snapshot and the hierarchical position is corrected synchronously to generate relationship reconstruction data.
[0076] S3.1. Using the path backtracking and rearrangement algorithm, perform node relationship parsing and ancestor chain backtracking on the pre-migration relationship snapshot to obtain node association identification data. Based on the node association identification data, trace the parent node level by level and construct the parent-child link structure.
[0077] It should be noted that the path backtracking and rearrangement algorithm first reads the node identifiers, parent node identifiers, and hierarchical path identifiers in the pre-migration relationship snapshot one by one. Using the node identifier as the current retrieval starting point, the parent node identifier as the upper-level tracking basis, and the hierarchical path identifier as the path verification basis, it performs parent-child correspondence checks, hierarchical correspondence checks, and path affiliation checks on each record to identify direct connections between nodes and indirect associations formed by cross-level continuation, thus obtaining node association identifier data. Starting with the last-level node in the node association identifier data as the initial tracking node, it follows the parent node... The identifier traces back level by level. During each backtracking, it synchronously verifies whether the hierarchical difference between the current tracking node and the previous level node is continuous, whether the path position is connected, and whether the parent-child affiliation is consistent. Only the upper-level nodes that meet the continuous attachment conditions are retained, and each level of retained nodes is written into the backtracking sequence. The ancestor nodes that appear repeatedly in each backtracking sequence are merged. The nodes with branches are segmented and organized according to the hierarchical depth and path sequence relationship. The organized nodes at each level are connected in the order of ancestor to descendant to form a parent-child link structure with continuous path, clear hierarchy, and traceable attachment relationship.
[0078] It should also be noted that the path backtracking and rearrangement algorithm is used to restore the original parent-child hierarchical relationship during the migration process. By backtracking the ancestor links and rearranging the paths on the snapshot of the relationship before the migration, the node attachment positions and hierarchical order are realigned, thereby ensuring that the multi-level relationship maintains structural continuity and logical consistency after reconstruction, and avoiding hierarchical misalignment, path breakage and confusion of association relationships caused by migration.
[0079] S3.2 Rearrange the attachment paths of the parent-child link structure, obtain candidate attachment nodes, reattach the candidate attachment nodes to the corresponding parent node positions according to the hierarchical order in the parent-child link structure, adjust the order relationship of sibling nodes, and generate parent-child reconstruction path data.
[0080] It should be noted that each link in the parent-child link structure is expanded node by node in ancestor-to-descendant order. The current attachment position, parent node position, hierarchy depth, sequence code, and time information for each node are read. The current attachment position is then compared item by item with the corresponding attachment positions after the parent node's hierarchy. This checks for instances of attachment hierarchy shifting forward or backward, incorrect parent node correspondence, or disordered insertion positions at the same level. Nodes with inconsistent attachment positions and hierarchy order are extracted to obtain candidate attachment nodes. Using the parent node identifier of the candidate attachment node as the basis for attribution, each candidate attachment node is assigned according to the established hierarchy relationship in the parent-child link structure. The node is re-inserted into the target position after the corresponding parent node, and the connection order between the candidate node and its adjacent nodes is simultaneously corrected. After the re-attachment is completed, all sibling nodes under the same parent node are further sorted according to time sequence, and the original arrangement direction is determined by combining the sequence code. The adjacency order is determined according to the tightness of the connection between nodes in the parent-child link structure, and the sibling nodes are adjusted to a continuous and non-overlapping arrangement. Finally, the parent-child position relationship after re-attachment, the adjusted sibling order relationship, and the updated path connection relationship are written into the link structure to generate parent-child reconstructed path data.
[0081] S3.3 Perform hierarchical position synchronization correction on the parent-child reconstruction path data, obtain hierarchical correction association data, and perform structural consistency verification on the hierarchical correction association data to generate relationship reconstruction data.
[0082] It should be noted that for each node in the parent-child reconstruction path data, the hierarchical depth, path position, and corresponding parent-child position are recalculated, and the calculated hierarchical values are backfilled into the corresponding records to obtain hierarchical correction association data. Then, based on the hierarchical correction association data, the system checks whether the parent node is unique, whether the child node skips levels, whether the hierarchical number is continuous, and whether the path direction is consistent to complete the structural consistency check and generate relationship reconstruction data.
[0083] S4. Using a state linkage algorithm, the relationship reconstruction data is written back to the current state of each node in the parent-child hierarchy from bottom to top, and the status identifier of the superior node is updated synchronously to generate state linkage data.
[0084] S4.1. Using a state linkage algorithm, the relationship reconstruction data is arranged in a bottom-up parent-child hierarchical order according to the hierarchical positioning identifier to generate hierarchical recursive node data.
[0085] It should be noted that a state linkage algorithm is adopted to read the hierarchical positioning identifier, parent node identifier, and child node identifier one by one from the relation reconstruction data. The lowest level node is identified according to the hierarchical depth value in the hierarchical positioning identifier, and the lowest level node is used as the starting point of the first layer arrangement. The corresponding parent node record is retrieved level by level from the parent node identifier in the first layer arrangement starting point. Each level of nodes is merged in order from low to high hierarchy. At the same time, the corresponding verification is performed on the parent node identifier and child node identifier in each level of node. After confirming the parent-child connection relationship, it is written into the arrangement sequence to generate hierarchical recursive node data.
[0086] It should also be noted that when the state linkage algorithm is executed, it first reads the parent-child correspondence, hierarchical positioning identifier, current state, and version state from the relation reconstruction data, and arranges the nodes in order from low to high hierarchical depth to form a bottom-up recursive queue. Then, within the child node group corresponding to the same parent node, it compares the current state, version state, and state change time between the child nodes one by one to determine whether the states of each child node are consistent and whether the states are sequential. The determined child node states are then summarized and written to the corresponding parent node. After completing the write-back of the current layer parent node state, the updated parent node state is used as the input of the next layer node to continue the same process until the top-level node completes the state update, thereby realizing the step-by-step transmission and synchronous update of node states along the parent-child hierarchical relationship.
[0087] S4.2 Within the child node group corresponding to the same parent node, perform state consistency determination on the hierarchical recursive node data, obtain state consistency data, and establish state transmission association data between the state consistency data and the corresponding parent node.
[0088] It should be noted that within the child node group corresponding to the same parent node, the current state, version state, and associated state in the hierarchical recursive node data are read. A state consistency determination is performed based on whether the state values are consistent, whether the state change directions are compatible, and whether the state sequence is continuous, to obtain state consistent data. For example, if the state values in the child node records are consistent, the state change directions are all continuous or synchronous changes, and the state change times are continuous without jumps or interruptions, the child node records are determined to meet the state consistency requirements and state consistent data is obtained. The state consistent data and the corresponding parent node are written into an explicit transmission relationship to mark the state source that the parent node should receive, and state transmission association data is established.
[0089] S4.3 Write the state in the state-transfer associated data back to the corresponding parent node level by level, and use it as the input of the upper-level node to continue to push upwards until the top-level node, generating state linkage data.
[0090] It should be noted that the state values in the state-transfer associated data are written back to the corresponding parent node in parent-child order. When writing back, the states of all child nodes under the same parent node are first summarized, and then the state of the parent node is determined according to the preset recursion rules. After the current layer is written back, the updated parent node state is used as the input of the upper layer node to continue to recursively push upwards until the top layer node, generating state linkage data.
[0091] It should also be noted that the recursive rule is established by performing sequence analysis and statistical summarization on the parent-child node state change process in historical state linkage data, extracting the stable mapping relationship between the child node state combination and the parent node state result, and establishing corresponding rules in combination with hierarchical order, state priority and conflict handling logic; in application, the parent node state is determined by matching the corresponding rule according to the current layer child node state combination, thus obtaining the recursive rule.
[0092] State linkage data is a structured state result formed by reconstructing relational data through hierarchical state write-back and parent-child recursion. It unifies and integrates the state changes of each node at different levels and establishes a transmission relationship. By forming state linkage data, it can provide a complete and continuous state basis for subsequent version consistency verification, making the transmission process of node state in the hierarchical structure traceable and consistent, thereby avoiding state breakage and conflict propagation, and improving the overall reliability and stability of migration results.
[0093] S5. Perform version consistency verification on the status linkage data, obtain consistency pass data, write the consistency pass data into the status table and update it synchronously, and generate a migration management plan.
[0094] S5.1 Extract state version feature data from the state linkage data and match it with historical version records to generate version verification benchmark data.
[0095] It should be noted that node status values, version numbers, hierarchical positions, and status change times are extracted from the status linkage data and combined to form status version feature data. The status version feature data is matched item by item with the corresponding fields in the historical version records to verify the version source, version order, status content, and hierarchical correspondence. The matching records that can be used as the basis for verification are summarized to generate version verification benchmark data.
[0096] S5.2 Filter out the status records that meet the consistency conditions and have no conflicts from the version verification benchmark data, and generate consistency passed data.
[0097] It should be noted that, according to node identifier and hierarchical position, the corresponding status records are extracted one by one from the version verification baseline data. Records of the same node in adjacent versions are used as a group of verification objects. The status value, version number, hierarchical position, and conflict flag in each group of verification objects are compared in turn. Status records with the same status value, consecutive version numbers in chronological order, consistent hierarchical positions, and no historical conflict flags are determined to meet the consistency conditions and are retained. Status records with inconsistent status values, interrupted version number transitions, misaligned hierarchical positions, or historical conflict flags are determined to not meet the consistency conditions and are excluded. After completing the group-by-group judgment, all retained records are re-aggregated and reorganized according to hierarchical position and version order. Status records that can be directly written are selected to generate consistency-passed data.
[0098] It should also be noted that the consistency condition is formed by statistically summarizing the state continuity relationship, version connection relationship and hierarchical correspondence relationship in the historical version records. It requires that the state records corresponding to the same node meet the following conditions: consistent state value, continuous version order, corresponding hierarchical position and no historical conflict markers. In application, only state records that meet all of the above judgment requirements are considered to meet the consistency condition.
[0099] S5.3. Write status table and link update for consistency data, obtain migration update record data, combine migration update record data with associated link identifier, and perform synchronous update to generate migration management scheme.
[0100] It should be noted that the node status, version status, and hierarchical status in the consistency data are written to the status table in a predetermined writing order, and the update time, associated source, and version position corresponding to each written content are recorded to obtain migration update record data. The migration update record data is combined with the associated link identifier to synchronously update the corresponding status on the parent and child links, thereby completing the consistency maintenance of migration status and link status and generating a migration management scheme.
[0101] This embodiment also provides a traceability code migration and status management system based on a relational database, including: a fingerprint generation module, used to collect migration request data and extract and associate elements from the migration request data to generate migration fingerprint request data;
[0102] The matching and retrieval module is used to perform operation fingerprint matching and historical record retrieval on migration fingerprint request data, obtain valid migration candidate data, and read the relationship chain and isolate the version of the valid migration candidate data to build a pre-migration relationship snapshot.
[0103] The relationship construction module is used to reconstruct the parent-child connection path and synchronously correct the hierarchical position of the relationship snapshot before migration through the path backtracking and rearrangement algorithm, and generate relationship reconstruction data.
[0104] The path reconstruction module is used to use a state linkage algorithm to write back the current state of the relationship reconstruction data node by node and update the status identifier of the upper level in a bottom-up manner according to the parent-child hierarchy, thereby generating state linkage data.
[0105] The status verification module is used to verify the version consistency of status linkage data, obtain consistency pass data, write the consistency pass data into the status table and update it synchronously, and generate a migration management plan.
[0106] In summary, this invention, through the path backtracking and rearrangement algorithm, reconstructs the parent-child connection path and corrects the hierarchical position in the industrial data storage scenario, ensuring that the multi-level relationship maintains a complete structural expression during the migration process, thereby restoring complex association links and avoiding hierarchical misalignment; through the state linkage algorithm, it completes bottom-up state recursion and cross-level synchronous updates in the industrial data storage scenario, ensuring that the state of each node evolves in a consistent manner, thereby guaranteeing the consistency control of the entire link state, improving the accuracy of relationship reconstruction and enhancing the consistency of migration results.
[0107] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for trace code migration and state management based on a relational database, characterized in that, include: Collect migration request data and extract and associate elements from the migration request data to generate migration fingerprint request data; Perform operation fingerprint matching and historical record retrieval on migration fingerprint request data to obtain valid migration candidate data, and perform relationship chain reading and version isolation on the valid migration candidate data to build a pre-migration relationship snapshot; The path backtracking and rearrangement algorithm is used to reconstruct the parent-child connection path from the pre-migration relationship snapshot and simultaneously correct the hierarchical position to generate relationship reconstruction data. The state linkage algorithm is adopted to reconstruct the relationship data node by node from bottom to top in the parent-child hierarchy, write back the current state and update the upper-level state identifier synchronously to generate state linkage data. Perform version consistency verification on the status linkage data, obtain consistency pass data, write the consistency pass data into the status table and update it synchronously, and generate a migration management plan.
2. The relational database based trace code migration and status management method of claim 1, wherein, The specific steps for collecting migration request data and extracting and associating features from the migration request data are as follows: Collect migration request data and perform field parsing and format specification to obtain standardized request data. Then, perform field decomposition and semantic mapping on the standardized request data to generate element decomposition data. Hierarchical binding is performed on the element decomposition data to obtain behavior association identification data, and time series association relationships are established based on the behavior association identification data. The time series association relationships are then subjected to unified encoding processing to generate feature encoding data.
3. The relational database based trace code migration and status management method of claim 1, wherein, The generation of migration fingerprint request data refers to performing fingerprint identifier generation on the feature encoding data, obtaining unique fingerprint identifier data, and associating and encapsulating the unique fingerprint identifier data with the feature encoding data.
4. The traceability code migration and status management method based on a relational database as described in claim 3, characterized in that, The specific steps for performing operation fingerprint matching and historical record retrieval on the migration fingerprint request data to obtain valid migration candidate data are as follows: The fingerprint retrieval features in the migration fingerprint request data are analyzed and combined according to the retrieval key rules to generate fingerprint retrieval constraint data; Locate the corresponding data entity identifier of the fingerprint retrieval constraint data, read the associated link record data according to the data entity identifier, merge and organize it, and generate candidate data to be compared. Perform operation fingerprint matching and consistency determination on the candidate data to be compared, and filter out candidate records that meet the full fingerprint matching conditions and candidate records whose conflict relationships are eliminated, and generate valid migration candidate data.
5. The traceability code migration and status management method based on a relational database as described in claim 4, characterized in that, The specific steps for reading the relationship chain and isolating the version of valid migration candidate data to construct a pre-migration relationship snapshot are as follows: Read parent and child node records from valid migration candidate data and arrange them in a chained manner according to the parent-before-child order to generate a relationship chain to read the data. Version isolation is performed on the data read from the relationship chain to obtain version determination identifier data. The target version range is filtered according to the version determination identifier data and non-target version records are removed to generate version isolation relationship data. Perform hierarchical restoration and content encapsulation on version isolation relationship data, obtain structural version association data, reorganize the structural version association data according to the hierarchical path order and write it into a unified structure, and generate a pre-migration relationship snapshot.
6. The traceability code migration and status management method based on a relational database as described in claim 1, characterized in that, The specific steps for generating relational reconstruction data are as follows: The path backtracking and rearrangement algorithm is used to perform node relationship parsing and ancestor chain backtracking on the pre-migration relationship snapshot to obtain node association identification data. Based on the node association identification data, the parent node is traced back level by level and the parent-child link structure is constructed. The parent-child link structure is reordered to obtain candidate attachment nodes. The candidate attachment nodes are then reattached to the corresponding parent node positions according to the hierarchical order in the parent-child link structure, and the order relationship of sibling nodes is adjusted to generate parent-child reconstruction path data. Perform hierarchical position synchronization correction on the parent-child reconstruction path data, obtain hierarchical correction association data, perform structural consistency verification on the hierarchical correction association data, and generate relationship reconstruction data.
7. The traceability code migration and status management method based on a relational database as described in claim 6, characterized in that, The state linkage algorithm is adopted, which reconstructs the relationship data node by node from bottom to top according to the parent-child hierarchy, writes back the current state and synchronously updates the status identifier of the parent level to generate state linkage data. The specific steps are as follows: A state linkage algorithm is used to arrange the relationship reconstruction data in a bottom-up parent-child hierarchical order according to the hierarchical positioning identifier, generating hierarchical recursive node data; Within the child node group corresponding to the same parent node, the state consistency of the hierarchical recursive node data is determined, the state consistency data is obtained, and the state consistency data is associated with the corresponding parent node to establish state transmission data. The state in the state-transfer associated data is written back to the corresponding parent node level by level, and then used as input for the upper-level node to continue to push upwards until the top-level node, generating state linkage data.
8. The traceability code migration and status management method based on a relational database as described in claim 7, characterized in that, The specific steps for performing version consistency verification on the status linkage data, obtaining consistency pass data, writing the consistency pass data into the status table, and synchronously updating it are as follows: Extract state version feature data from the state linkage data and match it with historical version records to generate version verification benchmark data; Filter out the status records that meet the consistency conditions and have no conflicts from the version verification benchmark data, and generate consistency passed data.
9. The traceability code migration and status management method based on a relational database as described in claim 1, characterized in that, The aforementioned migration management scheme refers to writing and updating the status table of the consistency-passing data, obtaining migration update record data, combining the migration update record data with the associated link identifier, and performing synchronous updates.
10. A traceability code migration and status management system based on a relational database, based on the traceability code migration and status management method based on a relational database as described in any one of claims 1 to 9, characterized in that, include: The fingerprint generation module is used to collect migration request data and extract and associate elements from the migration request data to generate migration fingerprint request data. The matching and retrieval module is used to perform operation fingerprint matching and historical record retrieval on migration fingerprint request data, obtain valid migration candidate data, and read the relationship chain and isolate the version of the valid migration candidate data to build a pre-migration relationship snapshot. The relationship construction module is used to reconstruct the parent-child connection path and synchronously correct the hierarchical position of the relationship snapshot before migration through the path backtracking and rearrangement algorithm, and generate relationship reconstruction data. The path reconstruction module is used to use a state linkage algorithm to write back the current state of the relationship reconstruction data node by node and update the status identifier of the upper level in a bottom-up manner according to the parent-child hierarchy, thereby generating state linkage data. The status verification module is used to verify the version consistency of status linkage data, obtain consistency pass data, write the consistency pass data into the status table and update it synchronously, and generate a migration management plan.