Database migration method, device, equipment, medium and product

By splitting the initial storage model of non-relational databases and determining field attributes, the method of migrating non-relational databases to relational databases is realized, solving the problem of low migration efficiency in the existing technology, improving the reliability of migration and efficiency.

CN117743299BActive Publication Date: 2024-12-13CHINA LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311728125.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-15
Publication Date
2024-12-13
Estimated Expiration
2043-12-15

AI Technical Summary

Technical Problem

The existing technology lacks effective methods to migrate non-relational databases to relational databases, resulting in low update efficiency and inability to meet the changing needs of business scenarios.

Method used

By obtaining the initial storage model and historical storage data of non-relational databases, splitting and processing according to the index level, converting it into a relational storage model, and determining the storage space and type of each field based on the historical data, realizing non-relational database to relationship migration of databases.

Benefits of technology

Improve the reliability of database migration, ensure a smooth transition of business data, and improve the efficiency and reliability of migration methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117743299B_ABST
    Figure CN117743299B_ABST
Patent Text Reader

Abstract

The present application relates to a database migration method, which includes: obtaining an initial storage model and historical storage data corresponding to an initial database to be migrated, wherein the initial storage model is a non-relational storage model; splitting the initial storage model according to the index level to obtain a target storage model, wherein the target storage model is a relational storage model; determining the field attributes corresponding to each field in the target storage model according to the historical storage data, wherein the field attributes include storage space and storage type, and the target storage model and the field attributes corresponding to each field are used to obtain the target database based on the target storage model and the field attributes corresponding to each field. The present method can realize the migration from a non-relational database to a relational database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a database migration method, device, equipment, medium and product. Background Art

[0002] In the information technology application innovation industry, although non-relational databases can store large amounts of data, their update efficiency is low when changes occur in business scenarios. Therefore, non-relational databases need to be migrated to relational databases.

[0003] Traditional database migration methods focus more on migration between relational databases, and lack database migration methods for migrating non-relational databases to relational databases. Summary of the invention

[0004] Based on this, it is necessary to provide a database migration method, device, equipment, medium and product that can migrate a non-relational database to a relational database in response to the above technical problems.

[0005] In a first aspect, the present application provides a database migration method, the method comprising:

[0006] Obtain the initial storage model and historical storage data corresponding to the initial database to be migrated. The initial storage model is a non-relational storage model.

[0007] The initial storage model is split according to the index level to obtain the target storage model, which is a relational storage model.

[0008] According to the historical storage data, the field attributes corresponding to each field in the target storage model are determined. The field attributes include storage space and storage type. The target storage model and the field attributes corresponding to each field are used to obtain the target database based on the target storage model and the field attributes corresponding to each field.

[0009] In one embodiment, the method provided herein splits the initial storage model according to the index level to obtain the target storage model, including:

[0010] The initial storage model is split according to the hierarchical relationship of the index levels to obtain at least one intermediate storage form and a hierarchical identifier of the intermediate storage form;

[0011] Based on the intermediate storage form and the level identifier of the intermediate storage form, determining multiple target storage forms, the level identifiers of the multiple target storage forms and the corresponding association relationships of the multiple target storage forms according to the index content of the index level;

[0012] A target storage model is obtained according to the multiple target storage forms, the hierarchical identifiers of the multiple target storage forms, and the association relationships corresponding to the multiple target storage forms.

[0013] In one embodiment, the process of determining the field attribute corresponding to each field in the target storage model according to the historical storage data in the provided method includes:

[0014] Based on the historical storage data, determine the data size and data type corresponding to each field in the initial storage model;

[0015] Determine the storage space corresponding to each field in the target storage model according to the data size corresponding to each field in the initial storage model;

[0016] According to the data type corresponding to each field in the initial storage model, the storage type corresponding to each field in the target storage model is determined.

[0017] In one embodiment, the method provided further includes:

[0018] Get business data;

[0019] Write the business data into the initial database to obtain the initial business document;

[0020] Write the business data into the target database to obtain the target business document;

[0021] Compare the initial business document with the target business document to obtain a comparison result;

[0022] Determine the migration result corresponding to the target database based on the comparison result.

[0023] In one embodiment, the process of determining the migration result corresponding to the target database according to the comparison result in the provided method includes:

[0024] If the comparison result is inconsistent, the migration result is migration failure;

[0025] The method also includes:

[0026] According to the comparison result, the target storage model is updated to obtain an updated target storage model; the field attributes corresponding to each field are updated to obtain the updated field attributes corresponding to each field.

[0027] In one embodiment, the process of determining the migration result corresponding to the target database according to the comparison result in the provided method includes:

[0028] If the comparison result is consistent, the migration result is successful.

[0029] In a second aspect, the present application also provides a database migration device, the device comprising:

[0030] A data acquisition module is used to acquire an initial storage model and historical storage data corresponding to the initial database to be migrated, where the initial storage model is a non-relational storage model;

[0031] A model building module is used to split the initial storage model according to the index level to obtain a target storage model, which is a relational storage model;

[0032] The database construction module is used to determine the field attributes corresponding to each field in the target storage model based on historical storage data. The field attributes include storage space and storage type. The target storage model and the field attributes corresponding to each field are used to obtain the target database based on the target storage model and the field attributes corresponding to each field.

[0033] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method of the first aspect are implemented.

[0034] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method of the first aspect when the computer program is executed by a processor.

[0035] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which implements the steps of the method of the first aspect when executed by a processor.

[0036] The above-mentioned database migration method, device, equipment, medium and product obtain the initial database to be migrated, the initial database includes an initial storage model and historical storage data, and the initial storage model is a non-relational storage model; the initial storage model is split according to the index level to obtain the target storage model, and the target storage model is a relational storage model; according to the historical storage data, the storage space and storage type corresponding to each field in the target storage model are determined, and the target storage model, each storage space and each storage type are used to obtain the target database based on the target storage model, each storage space and each storage type. In this way, the non-relational initial storage model is split to obtain a relational target storage model, thereby realizing the migration from the non-relational database to the relational database; the historical storage data stored in the initial database is used as the basis for determining the storage space and storage type corresponding to each field in the target storage model, so that the target storage model and the initial storage model are consistent in data storage space and storage type, thereby realizing the smooth transition of business data from being stored in the initial database to being stored in the target database, and improving the reliability of the database migration method. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0038] FIG1 is an application environment diagram of a database migration method in one embodiment;

[0039] FIG2 is a schematic diagram of a flow chart of a database migration method in one embodiment;

[0040] FIG3 is a schematic diagram of an initial storage model in one embodiment;

[0041] FIG4 is a flow chart of steps for obtaining a target storage model in one embodiment;

[0042] FIG5 is a schematic diagram of multiple intermediate storage tables in one embodiment;

[0043] FIG6 is a schematic diagram of steps for obtaining multiple target storage tables in one embodiment;

[0044] FIG7 is a schematic diagram of a target storage model in one embodiment;

[0045] FIG8 is a flow chart of steps for determining storage space and storage type in one embodiment;

[0046] FIG9 is a schematic flow chart of steps for obtaining migration results in one embodiment;

[0047] FIG10 is a flow chart of steps for obtaining migration results in one embodiment;

[0048] FIG11 is a schematic diagram of a flow chart of a database migration method in another embodiment;

[0049] FIG12 is a structural block diagram of a database migration device in one embodiment;

[0050] FIG. 13 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application 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 application and are not used to limit the present application.

[0052] The database migration method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. The initial data platform 102 and the target data platform 106 communicate with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers.

[0053] Among them, the server 104 obtains the initial database to be migrated from the initial data platform 102, the initial database includes the initial storage model and historical storage data, and the initial storage model is a non-relational storage model; the server 104 splits the obtained initial storage model according to the index level to obtain the target storage model, and the target storage model is a relational storage model; according to the historical storage data, the storage space and storage type corresponding to each field in the target storage model are determined; the server 104 sends the target storage model, each storage space and each storage type to the target data platform 106, so that the target data platform 106 can obtain the target database according to the target storage model, each storage space and each storage type. The server 104 can be implemented by an independent server or a server cluster composed of multiple servers.

[0054] In an exemplary embodiment, as shown in FIG2 , a database migration method is provided, which is described by taking the method applied to the server 104 in FIG1 as an example, and includes the following steps 202 to 206. Among them:

[0055] Step 202: Acquire the initial storage model and historical storage data corresponding to the initial database to be migrated.

[0056] Among them, the initial storage model is a non-relational storage model. The non-relational storage model is a storage model without a fixed data structure. It has the advantage of high read and write efficiency in application scenarios with large data volumes. However, the data processing tools and adapted application systems of the non-relational storage model are less than those of the relational data model. Databases based on the non-relational storage model cannot immediately guarantee data consistency at all index levels within a period of time after data is updated.

[0057] Exemplarily, the initial database may be a document-oriented non-relational database, such as MongoDB or CouchDB; another exemplary embodiment, the initial database may be a key-value database oriented to high-performance concurrent reading and writing, such as Redis or Tokyo Cabint.

[0058] Exemplarily, for an initial database of document type, the initial storage model may be as shown in Figure 3. The initial storage model may include multiple index levels, each index level may include two attributes: hierarchical relationship and index content. For example, the index level of "insured unit information" in Figure 3 has a hierarchical relationship of the first level and index content of the insured unit information.

[0059] The historical storage data is the business data corresponding to the historical period stored in the initial database according to the initial storage model.

[0060] Step 204, splitting the initial storage model according to the index level to obtain a target storage model, which is a relational storage model.

[0061] Among them, the index level in the initial storage model is used to quickly locate the required data and reduce the complexity of the query.

[0062] Exemplarily, the index levels can be divided based on the range of digital data stored in the initial database; another exemplary embodiment, the index levels can be divided based on the information content of text data stored in the initial database; another exemplary embodiment, the index levels can be divided based on the geographic location or geometric shape of image data stored in the initial database.

[0063] Among them, the relational storage model is a storage model that organizes data in the form of a two-dimensional table. Through data structures such as tables, rows, and columns, the target database is more structured and standardized. It can effectively manage and control the input and output of stored data, ensure data consistency, reliability, and security, and has the advantages of being easy to understand, simple to operate, and easy to maintain.

[0064] Exemplarily, the target database corresponding to the target storage model may be oceanBase, MySQL, or Oracle.

[0065] Step 206: Determine the field attribute corresponding to each field in the target storage model according to the historical storage data.

[0066] The field attributes include storage space and storage type, and the target storage model, each storage space and each storage type are used to obtain a target database based on the target storage model, each storage space and each storage type.

[0067] Among them, the storage space and storage type of each field in the initial storage model can be obtained according to the historical storage data stored in the initial database. In order to achieve smooth migration from a non-relational database to a relational database, the storage space of the corresponding field in the target storage model is determined according to the storage space of each field in the initial storage model, and the storage type of the corresponding field in the target storage model is determined according to the storage type of each field in the initial storage model.

[0068] In the database migration method provided in this embodiment, by obtaining the initial storage model and historical storage data corresponding to the initial database to be migrated, the initial storage model is a non-relational storage model; the initial storage model is split according to the index level to obtain the target storage model, which is a relational storage model; according to the historical storage data, the field attributes corresponding to each field in the target storage model are determined, and the field attributes include storage space and storage type. The target storage model and the field attributes corresponding to each field are used to obtain the target database based on the target storage model and the field attributes corresponding to each field. In this way, the non-relational initial storage model is split to obtain a relational target storage model, thereby realizing the migration from the non-relational database to the relational database; the historical storage data stored in the initial database is used as the basis for determining the field attributes corresponding to each field in the target storage model, so that the target storage model and the initial storage model are consistent in data storage space and storage type, thereby realizing the smooth transition of business data from being stored in the initial database to being stored in the target database, and improving the reliability of the database migration method.

[0069] In an exemplary embodiment, based on the embodiment shown in FIG. 2 , as shown in FIG. 4 , the method provided includes splitting the initial storage model according to the index level to obtain the target storage model, including:

[0070] Step 402 : split the initial storage model according to the hierarchical relationship of the index levels to obtain at least one intermediate storage form and a hierarchical identifier of the intermediate storage form.

[0071] The hierarchical relationship of the index level includes at least two levels, the index levels with the same level are used as an intermediate storage form, and the sorting sequence number of each level in the hierarchical relationship is used as the hierarchical identifier of the intermediate storage form corresponding to the level.

[0072] Optionally, the intermediate storage tables are determined in descending order according to the hierarchical relationship of the index levels.

[0073] Exemplarily, based on the initial storage model shown in FIG3, the index level includes three hierarchical relationships, wherein the first level includes: insurance policy number, insured unit information, and offer information; the second level of the index level includes: number of insured persons, total insured amount, total premium, insurance type list, sales channel, sales organization, and sales employee number; the third level of the index level includes: insurance type code, insurance type insured amount, and insurance type premium. As shown in FIG5, three intermediate storage forms can be obtained according to the aforementioned three hierarchical relationships, namely, the first intermediate storage form, the second intermediate storage form, and the third intermediate storage form. The first intermediate storage form with a hierarchical identification of 1 is obtained according to all the contents of the first level; the second intermediate storage form with a hierarchical identification of 2 is obtained according to all the contents of the second level; and the third intermediate storage form with a hierarchical identification of 3 is obtained according to all the contents of the third level.

[0074] Step 404 , based on the intermediate storage form and the level identifier of the intermediate storage form, determine multiple target storage forms, the level identifiers of the multiple target storage forms and the corresponding association relationships among the multiple target storage forms according to the index content of the index level.

[0075] Based on the example of step 402, as shown in FIG6, according to the index content of the index level, the first intermediate storage form is used as the first target storage form, which can also be called the group order basic hat information table. Based on the initial storage model, the index content in the first target storage form: offer information, is associated with the index content in the second intermediate storage form: number of insured persons, total insured amount, total premium and insurance type list. Since the level identifier of the second intermediate storage form is 2, the second target storage form with the same level identifier of 2 can be obtained, which can also be called the offer information table. The index content in the second target storage form: insurance type list, is associated with the index content in the third intermediate storage form: insurance type code, insurance type insured amount and insurance type premium. Since the level identifier of the third intermediate storage form is 3, the third target storage form with the same level identifier of 3 can be obtained, which can also be called the insurance type information table.

[0076] Step 406: obtaining a target storage model according to the multiple target storage forms, the hierarchical identifiers of the multiple target storage forms, and the association relationships corresponding to the multiple target storage forms.

[0077] Combine multiple target storage forms according to hierarchical identification and association relationships to obtain a target storage model.

[0078] Exemplarily, multiple target storage forms are combined according to the hierarchical identifiers and association relationships to obtain a target storage model as shown in FIG. 7 .

[0079] In this embodiment, the non-relational initial storage model is split into multiple target storage forms according to the hierarchical relationship of the index levels and the index content, and a relational target storage model is further formed, thereby realizing database migration from a non-relational database to a relational database with low operation complexity.

[0080] In an exemplary embodiment, based on the embodiment shown in FIG. 2 , as shown in FIG. 8 , the process of determining the field attribute corresponding to each field in the target storage model according to the historical storage data in the provided method includes:

[0081] Step 802: Determine the data size and data type corresponding to each field in the initial storage model based on the historical storage data.

[0082] The historical storage data is used to perform data analysis on the business data corresponding to the historical period based on the historical storage data, so as to obtain the data size and data type corresponding to each field in the initial storage model.

[0083] Exemplarily, relevant functions in computer algorithms may be used to perform operations and analysis on historical storage data to determine the data size and data type of each field.

[0084] Exemplarily, the data size may be in bytes; the data type may include an integer type, a floating point type, a character type, and an array type.

[0085] Step 804, determining the storage space corresponding to each field in the target storage model according to the data size corresponding to each field in the initial storage model.

[0086] Among them, for each field in the target storage model, the storage space corresponding to the field is consistent with the data size of the corresponding field in the initial storage model.

[0087] Optionally, if a field in the initial storage model contains multiple data of different sizes, the maximum value of the data sizes can be used as the storage space for the corresponding field in the target storage model.

[0088] Step 806, determining the storage type corresponding to each field in the target storage model according to the data type corresponding to each field in the initial storage model.

[0089] Among them, for each field in the target storage model, the storage type corresponding to the field is consistent with the storage type of the corresponding field in the initial storage model.

[0090] Optionally, if there are multiple different types of data under a field in the initial storage model, the data type with the largest number of occurrences among the data types can be used as the storage type of the corresponding field in the target storage model.

[0091] Exemplarily, the historical storage data may be processed using a data model management tool to determine the storage space and storage type corresponding to each field in the target storage model. The data model management tool may be Datablau, Collibra, etc.

[0092] In this embodiment, by processing historical storage data, the storage space and storage type corresponding to each field in the target storage model are accurately determined to avoid the impact of database migration on subsequent business data storage, thereby improving the efficiency of the database migration method.

[0093] In an exemplary embodiment, based on the embodiment shown in FIG8 , as shown in FIG9 , the provided method further includes:

[0094] Step 902, obtaining business data.

[0095] The business data may be data of multiple insurance policies purchased within a preset time period.

[0096] Step 904: write the business data into the initial database to obtain an initial business document.

[0097] Step 906: Write the business data into the target database to obtain the target business document.

[0098] Among them, the initial business document is obtained by storing the business data in the initial database according to the initial storage model, including multiple initial document data corresponding to multiple insurance policy data; the target business document is obtained by storing the business data in the target database according to the target storage model, including multiple target document data corresponding to multiple insurance policy data.

[0099] Step 908: Compare the initial business document with the target business document to obtain a comparison result.

[0100] Exemplarily, the comparison process may be to first compare whether the number of target storage forms obtained in the target business document is consistent based on the hierarchical relationship and index content in the initial business document; then, for each initial document data in the initial business document, compare whether the content of each field in the initial document data is consistent with the content of the corresponding field in the corresponding target document data.

[0101] Exemplarily, when comparing the contents of fields, the comparison processing can be based on a batch job method to compare the initial document data and the target document data corresponding to each policy data in turn. The preset hash function can be used to convert the content of each field in the initial document data and the content of the corresponding field in the target document data into hash sequences, and then the two hash sequences are compared to obtain a comparison result; or through a line-by-line comparison method, the content of each field in the initial document data and the content of the corresponding field in the target document data are compared line by line according to field to obtain a comparison result.

[0102] Exemplarily, if the compared contents are consistent, a consistent comparison result can be obtained; if there are differences in the compared contents, an inconsistent comparison result can be obtained. Optionally, the inconsistent comparison result also includes a difference information table in the form of an Excel table, and the difference information table includes the contents of the fields that are different between the initial document data and the target document data.

[0103] Step 910: Determine the migration result corresponding to the target database according to the comparison result.

[0104] Based on the example in step 908, if the comparison result is consistent, the target database meets the conditions for database migration, and the migration result is migration success; if the comparison result is inconsistent, the target database does not meet the conditions for database migration, and the migration result is migration failure. Optionally, in the case where the migration result is migration failure, it indicates that the storage space and storage type determined in the embodiment shown in FIG4 may deviate from the actual application scenario, and the target storage model can be modified and updated by comparing the difference information table to obtain an updated target database.

[0105] In this embodiment, the initial business document is compared with the target business document to obtain a comparison result, and then the migration result of the target database is determined, so as to avoid the storage and subsequent use of business data affected by the database migration, thereby improving the reliability of the database migration method.

[0106] In an exemplary embodiment, based on the embodiment shown in FIG. 9 , as shown in FIG. 10 , the process of determining the migration result corresponding to the target database according to the comparison result in the provided method includes:

[0107] Step 1002, determine whether the comparison result is consistent.

[0108] Step 1004: If the comparison result is inconsistent, the migration result is migration failure.

[0109] If the comparison result is inconsistent, it means that the effect of storing the business data in the target database is not exactly the same as that in the initial database, and the target database cannot completely replace the initial database. Therefore, the migration result is migration failure.

[0110] Step 1006: update the target storage model according to the comparison result to obtain an updated target storage model; update the field attributes corresponding to each field to obtain the updated field attributes corresponding to each field.

[0111] Among them, if the comparison result is inconsistent, the storage space corresponding to each field in the target storage model, the storage type corresponding to each field, or the index level of the initial storage model can be updated according to the difference information table in the comparison result to obtain an updated target storage model.

[0112] Step 1008: If the comparison result is consistent, the migration result is successful.

[0113] In this embodiment, the migration result is determined by comparing the results, and the target storage model is updated in case of migration failure until the migration result is successful. In this way, a high degree of matching before and after the database migration is ensured, thereby improving the reliability of the database migration method.

[0114] In an exemplary embodiment, as shown in FIG. 11 , a database migration method is provided, which is described by taking the method applied to the server 104 in FIG. 1 as an example, and includes the following steps 1101 to 206 . Among them:

[0115] Step 1101: Obtain an initial storage model and historical storage data corresponding to an initial database to be migrated.

[0116] Among them, the initial storage model is a non-relational storage model.

[0117] Step 1102 : split the initial storage model according to the hierarchical relationship of the index levels to obtain at least one intermediate storage form and a hierarchical identifier of the intermediate storage form.

[0118] Step 1103 : Based on the intermediate storage form and the level identifier of the intermediate storage form, multiple target storage forms, the level identifiers of the multiple target storage forms and the corresponding association relationships among the multiple target storage forms are determined according to the index content of the index level.

[0119] Step 1104 , obtaining a target storage model according to the multiple target storage forms, the hierarchical identifiers of the multiple target storage forms, and the association relationships corresponding to the multiple target storage forms.

[0120] Step 1105, determining the data size and data type corresponding to each field in the initial storage model based on the historical storage data.

[0121] Step 1106, determining the storage space corresponding to each field in the target storage model according to the data size corresponding to each field in the initial storage model.

[0122] Step 1107, determining the storage type corresponding to each field in the target storage model according to the data type corresponding to each field in the initial storage model.

[0123] Step 1108, obtaining business data.

[0124] Step 1109, write the business data into the initial database to obtain an initial business document.

[0125] Step 1110, write the business data into the target database to obtain the target business document.

[0126] Step 1111 , compare the initial business document with the target business document to obtain a comparison result.

[0127] Step 1112, determine whether the comparison result is consistent.

[0128] Step 1113: If the comparison result is inconsistent, the migration result is migration failure.

[0129] Step 1114, based on the comparison result, the target storage model is updated to obtain an updated target storage model; the field attributes corresponding to each field are updated to obtain updated field attributes corresponding to each field.

[0130] Step 1115: If the comparison result is consistent, the migration result is successful.

[0131] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0132] Based on the same inventive concept, the embodiment of the present application also provides a database migration device for implementing the database migration method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more database migration device embodiments provided below can refer to the limitations on the database migration method above, and will not be repeated here.

[0133] In an exemplary embodiment, as shown in FIG. 12 , a database migration device is provided, including: a data acquisition module 1202, a model construction module 1204 and a database construction module 1206, wherein:

[0134] The data acquisition module 1202 is used to acquire the initial database to be migrated, the initial database includes an initial storage model and historical storage data, and the initial storage model is a non-relational storage model;

[0135] The model building module 1204 is used to split the initial storage model according to the index level to obtain a target storage model, which is a relational storage model;

[0136] The database construction module 1206 is used to determine the field attributes corresponding to each field in the target storage model based on the historical storage data. The field attributes include storage space and storage type. The target storage model and the field attributes corresponding to each field are used to obtain the target database based on the target storage model and the field attributes corresponding to each field.

[0137] In one of the embodiments, the model building module 1204 is also used to split the initial storage model according to the hierarchical relationship of the index hierarchy to obtain multiple target storage forms and hierarchical identifiers of the multiple target storage forms; determine the associated relationship data corresponding to the multiple target storage forms according to the index content of the index hierarchy; and obtain the target storage model based on the multiple target storage forms, the hierarchical identifiers of the multiple target storage forms, and the associated relationship data corresponding to the multiple target storage forms.

[0138] In one embodiment, the database construction module 1206 is also used to determine the data size and data type corresponding to each field in the initial storage model based on historical storage data; determine the storage space corresponding to each field in the target storage model based on the data size corresponding to each field in the initial storage model; and determine the storage type corresponding to each field in the target storage model based on the data type corresponding to each field in the initial storage model.

[0139] In one of the embodiments, the provided database migration device also includes a data writing module, which is used to obtain business data; write the business data into an initial database to obtain an initial business document; write the business data into a target database to obtain a target business document; compare the initial business document with the target business document according to data size to obtain a comparison result; and determine the migration result corresponding to the target database based on the comparison result.

[0140] In one of the embodiments, the data writing module in the provided database migration device is also used to determine that the migration result is a migration failure when the comparison result is inconsistent; based on the comparison result, the target storage model is updated to obtain an updated target storage model; the field attributes corresponding to each field are updated to obtain the field attributes corresponding to each field after the update; and the migration result is determined to be a migration success when the comparison result is consistent.

[0141] Each module in the above database migration device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0142] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG13. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store an initial storage model and historical storage data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a database migration method is implemented.

[0143] Those skilled in the art will understand that the structure shown in FIG. 13 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0144] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0145] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0146] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0147] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0148] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

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

[0150] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A database migration method, characterized in that: The method comprises: Acquire an initial storage model and historical storage data corresponding to an initial database to be migrated, wherein the initial storage model is a non-relational storage model; Splitting the initial storage model according to the hierarchical relationship of the index levels to obtain at least one intermediate storage form and a hierarchical identifier of the intermediate storage form; Based on the intermediate storage form and the level identifier of the intermediate storage form, determining multiple target storage forms, the level identifiers of the multiple target storage forms and the corresponding association relationships of the multiple target storage forms according to the index content of the index level; Obtaining a target storage model according to the multiple target storage forms, the hierarchical identifiers of the multiple target storage forms, and the association relationships corresponding to the multiple target storage forms, wherein the target storage model is a relational storage model; According to the historical storage data, the field attributes corresponding to each field in the target storage model are determined, and the field attributes include storage space and storage type. The target storage model and the field attributes corresponding to each field are used to obtain the target database based on the target storage model and the field attributes corresponding to each field.

2. The method according to claim 1, characterized in that The determining, according to the historical storage data, a field attribute corresponding to each field in the target storage model includes: Determine the data size and data type corresponding to each field in the initial storage model according to the historical storage data; Determine the storage space corresponding to each field in the target storage model according to the data size corresponding to each field in the initial storage model; The storage type corresponding to each field in the target storage model is determined according to the data type corresponding to each field in the initial storage model.

3. The method according to claim 2, characterized in that The method further comprises: Get business data; Writing the business data into the initial database to obtain an initial business document; Writing the business data into the target database to obtain a target business document; Comparing the initial business document with the target business document to obtain a comparison result; A migration result corresponding to the target database is determined according to the comparison result.

4. The method according to claim 3, characterized in that The determining the migration result corresponding to the target database according to the comparison result includes: If the comparison result is inconsistent, the migration result is migration failure; The method further comprises: According to the comparison result, the target storage model is updated to obtain an updated target storage model; and the field attributes corresponding to each of the fields are updated to obtain updated field attributes corresponding to each of the fields.

5. The method according to claim 3, characterized in that: The determining the migration result corresponding to the target database according to the comparison result includes: If the comparison result is consistent, the migration result is successful.

6. A database migration device, characterized in that: The device comprises: A data acquisition module, used to acquire an initial storage model and historical storage data corresponding to an initial database to be migrated, wherein the initial storage model is a non-relational storage model; A model building module is used to split the initial storage model according to the hierarchical relationship of the index level to obtain at least one intermediate storage form and the hierarchical identifier of the intermediate storage form; based on the intermediate storage form and the hierarchical identifier of the intermediate storage form, determine multiple target storage forms, the hierarchical identifiers of the multiple target storage forms and the corresponding association relationships of the multiple target storage forms according to the index content of the index level; obtain a target storage model according to the multiple target storage forms, the hierarchical identifiers of the multiple target storage forms and the corresponding association relationships of the multiple target storage forms, and the target storage model is a relational storage model; A database construction module is used to determine the field attributes corresponding to each field in the target storage model based on the historical storage data, and the field attributes include storage space and storage type. The target storage model and the field attributes corresponding to each field are used to obtain the target database based on the target storage model and the field attributes corresponding to each field.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

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

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.