Data table updating method, database and computer readable storage medium

By adding intermediate data to the main data table and adjusting the association relationship, the impact on statistical data when data modification is solved, and flexible modification of the main data table is achieved without affecting the normal use of the slave data table.

CN114911812BActive Publication Date: 2025-05-23BEIJING BOE ENERGY TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210575926.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-24
Publication Date
2025-05-23
Estimated Expiration
2042-05-24

AI Technical Summary

Technical Problem

In the context of the development of big data technology, the data correlation between different industries and departments has increased, resulting in the modification of part of the data that will affect the statistical data generated based on the data, resulting in deviations and affecting the normal use of statistical data.

Method used

By adding the same intermediate data as the original data to be modified in the main data table, and determining the association relationship between the original data or intermediate data and the slave data table based on the specific identification field, adjusting the identification field to indicate whether the data has been modified, and finally modifying the unrelated data into the target data, obtaining the updated primary data table.

Benefits of technology

It realizes that the normal use of the slave data table is not affected when modifying the main data table, and improves the flexibility and user experience of data modification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114911812B_ABST
    Figure CN114911812B_ABST
Patent Text Reader

Abstract

The present disclosure is about a data table update method, a database and a computer-readable storage medium. The method includes: when it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified, adding intermediate data identical to the original data in the master data table; obtaining the first identification field of the master data table, and determining to associate the original data or the intermediate data with the slave data table according to the first identification field; adjusting the second identification field of the original data and the intermediate data; modifying the original data or the intermediate data that is not associated with the slave data table to the target data, and obtaining the updated master data table. In this embodiment, by adding intermediate data in the master data table, associating the slave data table to the original data or the intermediate data, and modifying the second identification field of the original data and the intermediate data, the effect of not affecting the slave data table when modifying the master data table is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a data table updating method, a database and a computer-readable storage medium. Background Art

[0002] With the development of big data technology, data from different industries and departments will be related. For example, urban traffic data is related to the city center joint command system, and urban traffic data is related to urban emergency management data. Since different data are related, modifying part of the data will affect the statistical data generated based on the data, which will affect the normal use of the statistical data. Summary of the invention

[0003] The present disclosure provides a data table updating method, a database and a computer-readable storage medium to solve the deficiencies of the related art.

[0004] According to a first aspect of an embodiment of the present disclosure, a data table updating method is provided, comprising:

[0005] When it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified, adding intermediate data identical to the original data in the master data table;

[0006] Acquire a first identification field of the master data table, and determine to associate the original data or the intermediate data with the slave data table according to the first identification field; the first identification field is used to indicate whether the sequence of primary keys in the master data table is allowed to be modified or prohibited to be modified;

[0007] Adjusting the second identification field of the original data and the intermediate data; the second identification field is used to indicate whether the data has been modified;

[0008] The original data or the intermediate data not associated with the slave data table is modified into target data to obtain an updated master data table.

[0009] Optionally, determining that the original data to be modified in the master data table is associated with the slave data table includes:

[0010] Acquire the primary key and the third identification field of the original data, wherein the third identification field is used to indicate whether the slave data table is allowed to follow the changes of the master data table;

[0011] When the value of the third identification field is the first value, querying the foreign key of the slave data table;

[0012] When the foreign key in the slave data table includes the primary key, it is determined that the original data is associated with the slave data table; when the foreign key in the slave data table does not include the primary key, it is determined that the original data is not associated with the slave data table.

[0013] Optionally, the method further comprises:

[0014] When the value of the third identification field is the second value, the original data is modified to the target data to obtain an updated master data table.

[0015] Optionally, the method further comprises:

[0016] When it is determined that the original data is not associated with the slave data table, the original data is modified to the target data to obtain an updated master data table.

[0017] Optionally, determining that modification of the master data table is allowed includes:

[0018] When it is determined that the original data is associated with the slave data table, a fourth identification field is obtained, where the fourth identification field is used to indicate whether modification of the master data table is allowed;

[0019] When the value of the fourth identification field is a first value, it is determined that the master data table is allowed to be modified; when the value of the fourth identification field is a second value, it is determined that the master data table is not allowed to be modified.

[0020] Optionally, determining to associate the original data or the intermediate data with the slave data table according to the first identification field includes:

[0021] When the value of the first identification field is a first value, it is determined to associate the original data with the slave data table; or when the value of the second identification field is a second value, it is determined to associate the intermediate data with the slave data table.

[0022] Optionally, adjusting the second identification field of the original data and the intermediate data includes:

[0023] When it is determined to associate the original data with the slave data table, the primary key of the intermediate data is assigned to the second identification field of the original data, and the second identification field of the intermediate data is assigned a second value; the second value is used to indicate that the data has been modified;

[0024] or,

[0025] When it is determined to associate the intermediate data with the slave data table, the intermediate data is associated with the slave data table and the primary key of the original data is assigned to the second identification field of the intermediate data, and the second identification field of the original data is assigned to a second value; the second value is used to indicate that the data has been modified.

[0026] Optionally, the method further comprises:

[0027] Verify whether the data and / or statistical results of the slave data table are changed.

[0028] Optionally, the modification of the master data table is implemented based on Python language and Django framework, or based on JAVA language and at least one framework of Hibernate / JDBC / MyBatis.

[0029] According to a second aspect of an embodiment of the present disclosure, there is provided a data table updating device, comprising:

[0030] An intermediate data adding module, for adding intermediate data identical to the original data in the master data table when it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified;

[0031] an associated data determination module, used for obtaining a first identification field of the master data table, and determining to associate the original data or the intermediate data with the slave data table according to the first identification field; the first identification field is used for indicating whether the sequence of the primary key in the master data table is allowed to be modified or is prohibited from being modified;

[0032] A second field adjustment module, used for adjusting a second identification field of the original data and the intermediate data; the second identification field is used for indicating whether the data is modified;

[0033] The master data table modification module is used to modify the original data or the intermediate data that are not associated with the slave data table into target data to obtain an updated master data table.

[0034] Optionally, the intermediate data adding module includes:

[0035] A primary key field acquisition submodule is used to acquire the primary key and a third identification field of the original data, wherein the third identification field is used to indicate whether the slave data table is allowed to follow the changes of the master data table;

[0036] A foreign key acquisition submodule, used for querying the foreign key of the slave data table when the value of the third identification field is the first value;

[0037] The associated data determination submodule is used to determine that the original data is associated with the slave data table when the foreign key in the slave data table includes the primary key, and to determine that the original data is not associated with the slave data table when the foreign key in the slave data table does not include the primary key.

[0038] Optionally, the device further comprises:

[0039] The master data table modification module is used to modify the original data to the target data when the value of the third identification field is the second value, so as to obtain an updated master data table.

[0040] Optionally, the device further comprises:

[0041] The master data table modification module is used to modify the original data into the target data to obtain an updated master data table when it is determined that the original data is not associated with the slave data table.

[0042] Optionally, the intermediate data adding module includes:

[0043] A fourth field acquisition submodule, used for acquiring a fourth identification field when it is determined that the original data is associated with the slave data table, wherein the fourth identification field is used to indicate whether the master data table is allowed to be modified;

[0044] The data table modification determination submodule is used to determine that the modification of the main data table is allowed when the value of the fourth identification field is a first value; and to determine that the modification of the main data table is not allowed when the value of the fourth identification field is a second value.

[0045] Optionally, the associated data determination module includes:

[0046] A first determination submodule is used to determine that the original data is associated with the slave data table when the value of the first identification field is a first value; or a second determination submodule is used to determine that the intermediate data is associated with the slave data table when the value of the second identification field is a second value.

[0047] Optionally, the second field adjustment module includes:

[0048] A first adjustment submodule is used for assigning the primary key of the intermediate data to the second identification field of the original data and assigning the second identification field of the intermediate data to a second value when determining to associate the original data with the slave data table; the second value is used to indicate that the data has been modified;

[0049] or,

[0050] The second adjustment submodule is used to associate the intermediate data with the slave data table and assign the primary key of the original data to the second identification field of the intermediate data when determining to associate the intermediate data with the slave data table, and assign the second identification field of the original data to a second value; the second value is used to indicate that the data has been modified.

[0051] Optionally, the device further comprises:

[0052] The verification module is used to verify whether the data and / or statistical results of the slave data table have changed.

[0053] Optionally, the modification of the master data table is implemented based on Python language and Django framework, or based on JAVA language and at least one framework of Hibernate / JDBC / MyBatis.

[0054] According to a third aspect of an embodiment of the present disclosure, there is provided a database, comprising at least one processing node; the processing node comprises:

[0055] processor;

[0056] a memory for storing a computer program executable by the processor;

[0057] The processor is configured to execute the computer program in the memory to implement the above method.

[0058] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium is provided, and when an executable computer program in the storage medium is executed by a processor, the method described in the first aspect can be implemented.

[0059] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0060] It can be seen from the above embodiments that in the scheme provided by the embodiment of the present disclosure, when it is determined that the original data to be modified in the master data table is associated with the slave data table and the modification of the master data table is allowed, the intermediate data identical to the original data is added to the master data table; then, the first identification field of the master data table is obtained, and it is determined according to the first identification field that the original data or the intermediate data is associated with the slave data table; the first identification field is used to indicate whether the order of the primary key in the master data table is allowed to be modified or prohibited to be modified; then, the second identification field of the original data and the intermediate data is adjusted; the second identification field is used to indicate whether the data is modified; finally, the original data or the intermediate data that is not associated with the slave data table is modified to the target data, and the updated master data table is obtained. In this way, in this embodiment, by adding intermediate data to the master data table, and associating the slave data table to the original data or the intermediate data, and modifying the second identification field of the original data and the intermediate data at the same time, the effect of not affecting the slave data table when modifying the master data table is achieved, which is conducive to improving the user experience.

[0061] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0063] Figure 1 The figure is a flow chart of a method for updating a data table according to an exemplary embodiment.

[0064] Figure 2 The present invention is a flowchart of determining whether original data to be modified is associated with a slave data table according to an exemplary embodiment.

[0065] Figure 3 The present invention is a flowchart showing a method for determining whether a master data table is allowed to be modified according to an exemplary embodiment.

[0066] Figure 4 The figure is a flowchart of another data table updating method according to an exemplary embodiment.

[0067] Figure 5 The figure is a flowchart of another data table updating method according to an exemplary embodiment.

[0068] Figure 6 is a flowchart of yet another data table updating method according to an exemplary embodiment.

[0069] Figure 7is a flowchart of yet another data table updating method according to an exemplary embodiment.

[0070] Figure 8 is a flowchart of yet another data table updating method according to an exemplary embodiment.

[0071] Fig. 9 The invention is a block diagram of a data table updating device according to an exemplary embodiment.

[0072] Fig.10 is a block diagram of a processing node according to an exemplary embodiment. DETAILED DESCRIPTION

[0073] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described exemplarily below do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices consistent with some aspects of the present disclosure as detailed in the attached claims. It should be noted that the features in the following embodiments and implementations may be combined with each other without conflict.

[0074] With the development of big data technology, data from different industries and departments will be related. For example, urban traffic data is related to the city center joint command system, and urban traffic data is related to urban emergency management data. Since different data are related, modifying part of the data will affect the statistical data generated based on the data, which will affect the normal use of the statistical data.

[0075] To solve the above technical problems, the embodiment of the present disclosure provides a data table update method, which can be applied to a database, the database includes at least one processing node, each processing node can be implemented by at least one server, and the above servers can implement the solution provided by the present disclosure alone or in cooperation with each other. In addition, each processing node can be provided with a Django framework and implemented in Python language. Or it can be implemented in JAVA language and at least one framework of Hibernate / JDBC / MyBatis. For the convenience of description, the solution of the present disclosure will be described later by each processing node executing the above data table update method alone.

[0076] The inventive concept of the present disclosure is to provide a solution that allows a master data table to be modified without affecting the normal use of a slave data table, wherein the slave data table is associated with part or all of the data in the master data table. Figure 1 FIG. 1 is a flow chart showing a method for updating a data table according to an exemplary embodiment. Figure 1, a data table updating method, comprising steps 11 to 14.

[0077] In step 11, when it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified, intermediate data identical to the original data is added to the master data table.

[0078] In this embodiment, the processing node can determine that the original data to be modified in the master data table is associated with the slave data table, see Figure 2 , including steps 21 to 23.

[0079] In step 21, the processing node may obtain the primary key and the third identification field of the original data.

[0080] In this step, considering that each group of original data in the master data table has a primary key, the processing node can directly obtain the primary key of the original data to be modified, and the primary key can uniquely identify the original data. The processing node can determine the original data to be modified by detecting the user's operation on a group of original data in the master data table, such as selecting a modification operation.

[0081] In this step, a field, namely the third identification field, is added to the master data table. The third identification field can be used to indicate whether the slave data table is allowed to follow the changes of the master data table. Its value is a first value and a second value. For example, when the third identification field is a first value (such as 1, or a non-zero value), it indicates that the slave data table is prohibited from tracking the changes of the master data table. When the third identification field is a second value (such as 0), it indicates that the slave data table is allowed to track the changes of the master data table. The processing node can obtain the third identification field of the master data table and obtain the value of the third identification field.

[0082] In step 22, when the value of the third identification field is the first value, the processing node may query the foreign key of the slave data table.

[0083] Considering that the original data in the master data table is associated with the slave data table, the primary key of the master data table is usually written into the foreign key of the slave data table. That is, when the primary key of the master data table is the same as the foreign key of the slave data table, it can be determined that the original data corresponding to the primary key is the data associated with the slave data table.

[0084] In this step, when it is determined that the value of the third identification field is the first value, the processing node can determine that the slave data table is prohibited from following the changes of the main data table. At this time, the processing node can query the foreign key of the slave data table, that is, the processing node can compare the primary key of the original data to be modified with the foreign key in the slave data table to determine whether the foreign key and primary key with the same value can be found. When it is determined that the value of the third identification field is the second value, the processing node can determine that the slave data table is allowed to follow the changes of the main data table. The processing node can respond to the user's modification operation this time, modify the original data to the target data, obtain the updated main data table, and end the modification process. In one example, the processing node can also generate a prompt message of successful modification to accurately prompt the user.

[0085] In step 23, the processing node can determine that the original data is associated with the slave data table when the foreign key in the slave data table includes the primary key, and can determine that the original data is not associated with the slave data table when the foreign key in the slave data table does not include the primary key.

[0086] In this embodiment, the processing node may determine that the master data table is allowed to be modified. Figure 3 , including steps 31 to 32.

[0087] In step 31, when it is determined that the original data is associated with the slave data table, the processing node may obtain a fourth identification field, where the fourth identification field is used to indicate whether the master data table is allowed to be modified.

[0088] In this step, the master data table further adds a fourth identification field, which can be used to indicate whether the master data table is allowed to be modified, and its value is a first value and a second value. For example, when the fourth identification field is a first value (such as 1, or a non-zero value), it indicates that the master data table is allowed to be modified, and when the fourth identification field is a second value (such as 0), it indicates that the master data table is prohibited from being modified. The processing node can obtain the fourth identification field of the master data table and obtain the value of the fourth identification field.

[0089] In step 32, when the value of the fourth identification field is a first value, the processing node may determine that the master data table is allowed to be modified; when the value of the fourth identification field is a second value, the processing node may determine that the master data table is not allowed to be modified.

[0090] When it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified, the processing node can add the same intermediate data as the original data in the master data table. For example, the processing node can use the preset auto-increment algorithm in the database to auto-increment a set of the same data, i.e., the intermediate data, for the original data. The content of the intermediate data is the same as that of the original data but the primary key is different, and the intermediate data will be located in the last row of the master data table.

[0091] It should be noted that the above-mentioned self-increment algorithm can be implemented by an existing algorithm. Of course, technical personnel can also select a suitable algorithm to generate intermediate data according to the specific scenario. When the original data can be self-incremented, the corresponding solution falls within the protection scope of this disclosure.

[0092] In step 12, the first identification field of the master data table is obtained, and the original data or the intermediate data is associated with the slave data table according to the first identification field; the first identification field is used to indicate whether the order of the primary key in the master data table is allowed to be modified or prohibited to be modified.

[0093] In this embodiment, a first identification field is also provided in the master data table, which is used to indicate whether the order of primary keys in the master data table is allowed to be modified or prohibited from being modified. The value of the first identification field is a first value and a second value. For example, when the value of the first identification field is the first value (such as 1, or a non-zero value), it indicates that the order of primary keys in the master data table is allowed to be modified, that is, the order of primary keys in the master data table before and after modification may be different; when the value of the first identification field is the second value (such as 0), it indicates that the order of primary keys in the master data table is prohibited from being modified, that is, the primary keys of the master data table before and after modification must be the same.

[0094] In this embodiment, the processing node can determine to associate the original data with the slave data table or to associate the intermediate data with the slave data table based on the first identification field. For example, when the value of the first identification field is a first value, the processing node can determine to associate the original data with the slave data table; or, when the value of the second identification field is a second value, it is determined to associate the intermediate data with the slave data table. It should be noted that in this embodiment, associating the original data or the intermediate data with the slave data table is an association process performed in order to update the master data table.

[0095] In step 13, the second identification field of the original data and the intermediate data is adjusted; the second identification field is used to indicate whether the data is modified.

[0096] In this embodiment, the main data table also sets a second marking field, which can be used to indicate whether the data has been modified. Its value is a first value and a second value. For example, when the value of the second identification field is the first value (such as 1, or a non-zero value), it indicates that the data has not been modified. When the value of the second identification field is the second value (such as 0), it indicates that the data has been modified.

[0097] In one embodiment, when it is determined to associate the original data with the slave data table, the processing node can assign the primary key of the intermediate data to the second identification field of the original data, that is, assign the primary key of a non-zero value to the second identification field of the original data, and assign the second identification field of the intermediate data to a second value; the second value is used to indicate that the data has been modified.

[0098] In another embodiment, when determining to associate the intermediate data to the slave data table, the processing node may assign the primary key of the original data to the second identification field of the intermediate data, and assign the second identification field of the original data to a second value; the second value is used to indicate that the data has been modified.

[0099] It should be noted that the first annotation field, the second annotation field, the third annotation field and the fourth annotation field are set in the master data table, and each annotation field can take the first value and the second value to represent the corresponding two states. It is understandable that the setting of the above-mentioned various annotation fields is only to describe different scenarios, so as to facilitate the technical staff to accurately understand the technical solution of the present disclosure. In one example, considering that each annotation field can correspond to 2 scenarios, the first annotation field, the second annotation field, the third annotation field and the fourth annotation field can represent 8 scenarios. In actual applications, a 3-bit annotation field can be set in the master data table to represent different scenarios. For example, when the annotation field is 000, it means that the slave data table is allowed to follow the changes in the master data table, that is, the corresponding scenario when the third identification field takes the second value, and other scenarios are similar, and the scheme of the present disclosure can also be implemented.

[0100] In step 14, the original data or the intermediate data not associated with the slave data table is modified into target data to obtain an updated master data table.

[0101] In this embodiment, the processing node can modify the original data or intermediate data that is not associated with the slave data table into target data. When it is determined to associate the original data with the slave data table, the intermediate data is not associated with the slave data table, and the second identification field of the intermediate data is assigned a second value, the processing node can modify the intermediate data into target data. When it is determined to associate the intermediate data with the slave data table, the original data is not associated with the slave data table, and the second identification field of the original data is assigned a second value, the processing node can modify the original data into target data. After modifying the original data or intermediate data in the master data table into target data, an updated master data table can be obtained.

[0102] In one embodiment, after obtaining the updated master data table, the processing node can verify whether the data and / or statistical results of the slave data table have changed, and whether the above verification results meet the requirements. Taking the slave data table as an example of prohibiting the slave data table from following the changes of the master data table, when it is detected that the data (and / or statistical results) of the slave data table have not changed, the processing node can determine that the master data table has been successfully modified. When it is detected that the data (and / or statistical results) of the slave data table have changed, the processing node can determine that the master data table has failed to be modified, and the tester can be reminded to readjust the scheme of the data table update method provided by the present disclosure, and finally achieve the effect of modifying the master data table without affecting the slave data table.

[0103] So far, the solution provided in the embodiment of the present disclosure achieves the effect of not affecting the slave data table when modifying the main data table by adding intermediate data to the main data table, associating the slave data table to the original data or the intermediate data, and modifying the second identification field of the original data and the intermediate data, which is beneficial to improving the user experience.

[0104] The following describes a data table update method provided by the embodiment of the present disclosure in combination with the application scenario of Python language and Django framework. Figure 4 ,include:

[0105] The processing node can determine whether the slave data table is allowed to be affected by the modification of the master data table by using the third identification field.

[0106] See also Figure 5 When the data and statistical results of the slave data table are required to change with the modification of the master data table data, that is, the modification of the master data table data is allowed to affect the slave data table data and statistical analysis results, the processing node can modify the data of the master data table without restriction. After the modification is completed, the updated master data table is obtained and the process ends.

[0107] When the data and statistical results of the slave data table are prohibited from changing with the modification of the master data table, that is, the modification of the master data table data is prohibited from affecting the data and statistical analysis results of the slave data table, the processing node can determine whether the original data to be modified in the master data table is related to the slave data table. This can be achieved by querying whether the primary key of the master data table exists in the foreign key of the slave data table through the reverse query function provided by the Django framework.

[0108] See also Figure 6 , when the original data is not associated with the slave data table, the master data table is allowed to be modified without restriction, that is, the original data to be modified in the master data table can be modified to the target data, the updated master data table is obtained, and the process ends.

[0109] For the original data in the master data table associated with the slave data table, in order to eliminate the impact of the modification of the master data table on the data and statistical results of the slave data table, the fourth identification field can be used to determine whether to adopt solution one or solution two.

[0110] Option 1, see Figure 7 The master data table is used only as a historical record table and is not allowed to be modified, and the process ends.

[0111] Solution 2: Modify the master data table, see Figure 8 ,include:

[0112] 1. Add an identification field (i.e., the second identification field in the above embodiment) to the main data table to distinguish whether the original data has been modified. If the identification field already exists, skip this step.

[0113] Taking Django framework as an example, to add an identification field, you need to add "original_flag = models.IntegerField (default = 0, db_column = 'original_flag')" in the model class, where "original_flag" is the identification field. Among them, "Model" is the instance object of the data table in Python.

[0114] 2. For the original data to be modified, add a new piece of data that is exactly the same as it (i.e., intermediate data) in the main data table. Due to the self-increment principle of the primary key of the main data table, the processing node will put the intermediate data in the last row of the main data table.

[0115] Taking the Django framework as an example, first query the original data to be modified (model_item = Model.objects.get (pk = id)), then save a new data with a new id (ie, primary key) (model_item.id = None; model_item.save()) to obtain the intermediate data.

[0116] 3. According to the id sorting requirement in the master data table (i.e., the auto-increment sorting of the primary key), the following scheme is included to modify the master data table without affecting the data and statistical results of the slave data table. The first identification field can be used to determine whether to select scheme 31 or scheme 32.

[0117] (31) Allow different id sorting in the master data table or specify fields in the master data table to sort the original data. For example, the original data can be used as historical data by setting an identification field (i.e., the first identification field), and the id value of the new data is assigned to the "original_flag" of the original data. In addition, the "original_flag" of the new data is set to 0. When modifying the data in the master data table, only the corresponding new data needs to be modified, and the original data remains unchanged. At the same time, the modification of the data in the master data table can be viewed based on the secondary data table.

[0118] Taking the Django framework as an example, first set the original data as historical data (Model.objects.get(pk=id).update('original_flag',model_item.id)), and then modify the new data (model_item.update('original_flag',0)).

[0119] (32) It is required that the id sorting in the modified master data table remains unchanged. At this time, the new data is used as historical data, that is, the "original_flag" of the original data is set to 0, and the id value of the original data is assigned to the "original_flag" of the new data. In addition, the id value of the association relationship from the data table to the new data is modified, the original data in the master data table is modified, and the new data remains unchanged.

[0120] Taking the Django framework as an example, modify the new data (model_item.update('original_flag',id)) and modify the original data (Model.objects.get(pk=id).update('original_flag',0)).

[0121] Finally, verify whether the data in the slave data table and the statistical analysis results change as the data in the master data table is modified.

[0122] In this way, the data table updating method provided in this embodiment confirms whether the modification of the master data table is allowed to affect the slave data table. If not allowed, the structure of the master data table is modified; then, the Django framework corresponding to the Python language is used to reversely query the database to determine whether the original data to be modified already exists in the slave data table. If so, a new piece of intermediate data is added to the master data table, and then the master-slave data coupling is reconstructed according to the requirements of the primary key sorting in the master data table, so as to meet the effect that the slave data table does not follow the changes of the master data table (or follows the changes of the master data table).

[0123] Based on a data table updating method provided in an embodiment of the present disclosure, an embodiment of the present disclosure further provides a data table updating device, see Fig. 9 ,include:

[0124] An intermediate data adding module 91 is used to add intermediate data identical to the original data in the master data table when it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified;

[0125] The associated data determination module 92 is used to obtain the first identification field of the master data table, and determine to associate the original data or the intermediate data with the slave data table according to the first identification field; the first identification field is used to indicate whether the sequence of the primary key in the master data table is allowed to be modified or prohibited to be modified;

[0126] A second field adjustment module 93, used to adjust the second identification field of the original data and the intermediate data; the second identification field is used to indicate whether the data is modified;

[0127] The master data table modification module 94 is used to modify the original data or the intermediate data that is not associated with the slave data table into target data to obtain an updated master data table.

[0128] In one embodiment, the intermediate data adding module includes:

[0129] A primary key field acquisition submodule is used to acquire the primary key and a third identification field of the original data, wherein the third identification field is used to indicate whether the slave data table is allowed to follow the changes of the master data table;

[0130] A foreign key acquisition submodule, used for querying the foreign key of the slave data table when the value of the third identification field is the first value;

[0131] The associated data determination submodule is used to determine that the original data is associated with the slave data table when the foreign key in the slave data table includes the primary key, and to determine that the original data is not associated with the slave data table when the foreign key in the slave data table does not include the primary key.

[0132] In one embodiment, the device further comprises:

[0133] The master data table modification module is used to modify the original data to the target data when the value of the third identification field is the second value, so as to obtain an updated master data table.

[0134] In one embodiment, the device further comprises:

[0135] The master data table modification module is used to modify the original data into the target data to obtain an updated master data table when it is determined that the original data is not associated with the slave data table.

[0136] In one embodiment, the intermediate data adding module includes:

[0137] A fourth field acquisition submodule, used for acquiring a fourth identification field when it is determined that the original data is associated with the slave data table, wherein the fourth identification field is used to indicate whether the master data table is allowed to be modified;

[0138] The data table modification determination submodule is used to determine that the modification of the main data table is allowed when the value of the fourth identification field is a first value; and to determine that the modification of the main data table is not allowed when the value of the fourth identification field is a second value.

[0139] In one embodiment, the associated data determination module includes:

[0140] A first determination submodule is used to determine that the original data is associated with the slave data table when the value of the first identification field is a first value; or a second determination submodule is used to determine that the intermediate data is associated with the slave data table when the value of the second identification field is a second value.

[0141] In one embodiment, the second field adjustment module includes:

[0142] A first adjustment submodule is used for assigning the primary key of the intermediate data to the second identification field of the original data and assigning the second identification field of the intermediate data to a second value when determining to associate the original data with the slave data table; the second value is used to indicate that the data has been modified;

[0143] or,

[0144] The second adjustment submodule is used to associate the intermediate data with the slave data table and assign the primary key of the original data to the second identification field of the intermediate data when determining to associate the intermediate data with the slave data table, and assign the second identification field of the original data to a second value; the second value is used to indicate that the data has been modified.

[0145] In one embodiment, the device further comprises:

[0146] The verification module is used to verify whether the data and / or statistical results of the slave data table have changed.

[0147] In one embodiment, the modification of the master data table is implemented based on the Python language and the Django framework, or based on the JAVA language and at least one of the frameworks of Hibernate / JDBC / MyBatis.

[0148] It should be noted that the device shown in this embodiment matches the contents of the method embodiment, and reference may be made to the contents of the above method embodiment, which will not be repeated here.

[0149] In an exemplary embodiment, a database is also provided. Fig.10 , comprising at least one processing node; the processing node comprising:

[0150] Processor 101; Memory 102 for storing computer programs executable by the processor;

[0151] The processor 101 is configured to execute the computer program in the memory 102 to implement the methods of the above embodiments.

[0152] In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, such as a memory including an executable computer program, and the executable computer program can be executed by a processor to implement the method of the above embodiment. The readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0153] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0154] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A data table update method, It is characterized in that include: When it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified, adding intermediate data identical to the original data in the master data table; Acquire a first identification field of the master data table, and determine to associate the original data or the intermediate data with the slave data table according to the first identification field; wherein, The first identification field is used to indicate whether the sequence of the primary keys in the master data table is allowed to be modified or is prohibited from being modified; Adjusting the second identification field of the original data and the intermediate data; wherein the second identification field is used to indicate whether the data has been modified; The original data or the intermediate data not associated with the slave data table is modified into target data to obtain an updated master data table.

2. The method according to claim 1, It is characterized in that The method includes the step of determining whether the original data to be modified in the master data table is associated with the slave data table, specifically including: Acquire the primary key and the third identification field of the original data, wherein the third identification field is used to indicate whether the slave data table is allowed to follow the changes of the master data table; When the value of the third identification field is the first value, querying the foreign key of the slave data table; When the foreign key in the slave data table includes the primary key, determining that the original data is associated with the slave data table; When the foreign key in the slave data table does not include the primary key, it is determined that the original data is not associated with the slave data table.

3. The method according to claim 2, It is characterized in that The method further comprises: When the value of the third identification field is the second value, the original data is modified to the target data to obtain an updated master data table.

4. The method according to claim 2, It is characterized in that The method further comprises: When it is determined that the original data is not associated with the slave data table, the original data is modified to the target data to obtain an updated master data table.

5. The method according to claim 2, It is characterized in that The method comprises the step of determining whether to allow modification of the master data table, specifically comprising: When it is determined that the original data is associated with the slave data table, a fourth identification field is obtained, where the fourth identification field is used to indicate whether modification of the master data table is allowed; When the value of the fourth identification field is a first value, it is determined that the master data table is allowed to be modified; when the value of the fourth identification field is a second value, it is determined that the master data table is not allowed to be modified.

6. The method according to claim 1, It is characterized in that Determining, according to the first identification field, to associate the original data or the intermediate data with the slave data table includes: When the value of the first identification field is a first value, determining to associate the original data with the slave data table; Alternatively, when the value of the second identification field is a second numerical value, it is determined to associate the intermediate data with the slave data table.

7. The method according to claim 1, It is characterized in that Adjusting the second identification field of the original data and the intermediate data includes: When it is determined to associate the original data with the slave data table, the primary key of the intermediate data is assigned to the second identification field of the original data, and the second identification field of the intermediate data is assigned a second value; the second value is used to indicate that the data has been modified; or When it is determined to associate the intermediate data with the slave data table, the intermediate data is associated with the slave data table and the primary key of the original data is assigned to the second identification field of the intermediate data, and the second identification field of the original data is assigned to a second value; the second value is used to indicate that the data has been modified.

8. The method according to claim 6 or 7, It is characterized in that The method further comprises: Verify whether the data and / or statistical results of the slave data table are changed.

9. The method according to any one of claims 1 to 5, It is characterized in that The modification of the master data table is implemented based on the Python language and the Django framework, or based on the JAVA language and at least one framework of Hibernate / JDBC / MyBatis.

10. A data table updating device, It is characterized in that include: An intermediate data adding module, for adding intermediate data identical to the original data in the master data table when it is determined that the original data to be modified in the master data table is associated with the slave data table and the master data table is allowed to be modified; An associated data determination module, used for obtaining a first identification field of the master data table, and determining to associate the original data or the intermediate data with the slave data table according to the first identification field; The first identification field is used to indicate whether the sequence of the primary keys in the master data table is allowed to be modified or is prohibited to be modified; A second field adjustment module, used for adjusting a second identification field of the original data and the intermediate data; the second identification field is used for indicating whether the data is modified; The master data table modification module is used to modify the original data or the intermediate data that are not associated with the slave data table into target data to obtain an updated master data table.

11. The device according to claim 10, It is characterized in that The intermediate data adding module comprises: A primary key field acquisition submodule is used to acquire the primary key and a third identification field of the original data, wherein the third identification field is used to indicate whether the slave data table is allowed to follow the changes of the master data table; A foreign key acquisition submodule, used for querying the foreign key of the slave data table when the value of the third identification field is the first value; The associated data determination submodule is used to determine that the original data is associated with the slave data table when the foreign key in the slave data table includes the primary key, and to determine that the original data is not associated with the slave data table when the foreign key in the slave data table does not include the primary key.

12. The device according to claim 11, It is characterized in that The device also includes: The master data table modification module is used to modify the original data to the target data when the value of the third identification field is the second value, so as to obtain an updated master data table.

13. The device according to claim 11, It is characterized in that The device also includes: The master data table modification module is used to modify the original data into the target data to obtain an updated master data table when it is determined that the original data is not associated with the slave data table.

14. The device according to claim 11, It is characterized in that The intermediate data adding module comprises: A fourth field acquisition submodule, used for acquiring a fourth identification field when it is determined that the original data is associated with the slave data table, wherein the fourth identification field is used to indicate whether the master data table is allowed to be modified; The data table modification determination submodule is used to determine that the modification of the main data table is allowed when the value of the fourth identification field is a first value; and to determine that the modification of the main data table is not allowed when the value of the fourth identification field is a second value.

15. The device according to claim 10, It is characterized in that The associated data determination module includes: A first determination submodule is used to determine that the original data is associated with the slave data table when the value of the first identification field is a first value; or a second determination submodule is used to determine that the intermediate data is associated with the slave data table when the value of the second identification field is a second value.

16. The device according to claim 10, It is characterized in that The second field adjustment module includes: A first adjustment submodule is used for assigning the primary key of the intermediate data to the second identification field of the original data and assigning the second identification field of the intermediate data to a second value when determining to associate the original data with the slave data table; the second value is used to indicate that the data has been modified; or, The second adjustment submodule is used to associate the intermediate data with the slave data table and assign the primary key of the original data to the second identification field of the intermediate data when determining to associate the intermediate data with the slave data table, and assign the second identification field of the original data to a second value; the second value is used to indicate that the data has been modified.

17. The device according to claim 15 or 16, It is characterized in that The device also includes: The verification module is used to verify whether the data and / or statistical results of the slave data table have changed.

18. The device according to any one of claims 10 to 14, It is characterized in that The modification of the master data table is implemented based on the Python language and the Django framework, or based on the JAVA language and at least one framework of Hibernate / JDBC / MyBatis.

19. A database, It is characterized in that The method comprises at least one processing node; the processing node comprises: processor; a memory for storing a computer program executable by the processor; The processor is configured to execute the computer program in the memory to implement the method according to any one of claims 1 to 9.

20. A non-transitory computer-readable storage medium, It is characterized in that When the executable computer program in the storage medium is executed by a processor, the method according to any one of claims 1 to 9 can be implemented.

Citation Information

Patent Citations

  • File processing method and device, and system

    CN106407320A

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

    CN111259023A