Data processing method and device, computer device, and storage medium
By obtaining the type and attribute information of the database table, determining the method of attribute value determination, and updating the associated attributes, the problem of low data update efficiency between database tables is solved, and efficient attribute value calculation and updating are achieved.
Patent Information
- Application Number
- CN202310666218.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-06
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2043-06-06
AI Technical Summary
The database suffers from inefficient data updates between tables, a large amount of homogeneous code implementation, and a tendency to contain hidden errors.
By obtaining the type of the target table and the attribute information of the attribute to be processed, the method of determining the attribute value is determined, the associated attributes are obtained, and the attribute values are updated based on this information, thus realizing complex calculation scheduling within and between tables.
It improves the efficiency of calculating and updating attribute values in the database, and reduces the use of homogenized code and the occurrence of hidden errors.
Smart Images

Figure CN116737734B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database, in particular to a data processing method and device, computer equipment and storage medium. BACKGROUND
[0002] A database is a collection of a large amount of data stored in a computer for a long time, organized, shareable and uniformly managed, which can be a computer software system for data storage and data management according to a data structure. A large amount of data is usually stored in a database, and operations such as adding, deleting, searching and modifying the data stored in the database are required during use. A large number of tables are stored in the database, and there may be a connection between the tables. The updated data in the table may affect the data in other tables, and needs to be changed synchronously. There are a large number of homogenized code implementations in this process, and various implicit errors may occur due to complex environment logic, resulting in low efficiency of data update in the database. SUMMARY
[0003] Therefore, the embodiments of the present application provide a data processing method and device, computer equipment and storage medium to solve the problem of low efficiency of database data update.
[0004] In a first aspect, the embodiments of the present application provide a data processing method, which comprises:
[0005] obtaining the type of a target table and attribute information of a to-be-processed attribute in the target table;
[0006] determining a determination mode corresponding to the attribute value of the to-be-processed attribute based on the type and the attribute information;
[0007] obtaining an associated attribute of the to-be-processed attribute based on the determination mode corresponding to the attribute value of the to-be-processed attribute;
[0008] determining the attribute value of the to-be-processed attribute and the attribute value of the associated attribute based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute.
[0009] The data processing method provided in the embodiments obtains the type of a target table and attribute information of a to-be-processed attribute in the target table, determines a determination mode corresponding to the attribute value of the to-be-processed attribute based on the type and the attribute information, obtains an associated attribute of the to-be-processed attribute based on the determination mode corresponding to the attribute value of the to-be-processed attribute, and finally determines the attribute value of the to-be-processed attribute and the attribute value of the associated attribute. The scheme obtains the associated attribute of the to-be-processed attribute based on the determination mode corresponding to each to-be-processed attribute, so that the attribute value of the associated attribute can be updated according to the attribute value of the to-be-processed attribute, and complex calculation and scheduling of each attribute in the table and between tables can be realized, thereby improving the calculation and update efficiency of the attribute value in the table.
[0010] In some optional embodiments, the determining manner corresponding to the attribute value of the to-be-processed attribute based on the type and the attribute information of the to-be-processed attribute comprises:
[0011] The determining manner corresponding to the attribute value of the to-be-processed attribute is obtained from a preset list based on the type of the target table, and the preset list comprises a mapping relationship between the type of each table in the database and the determining manner of the attribute value.
[0012] In some optional embodiments, the obtaining the associated attribute of the to-be-processed attribute based on the determining manner corresponding to the attribute value of the to-be-processed attribute comprises:
[0013] The determining manner corresponding to the attribute value of the to-be-processed attribute is parsed to obtain all attributes involved in the determining manner;
[0014] The associated attribute related to the attribute value of the to-be-processed attribute is extracted from the all attributes.
[0015] In some optional embodiments, the determining the attribute value of the to-be-processed attribute and the attribute value of the associated attribute based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute comprises:
[0016] The attribute value of the to-be-processed attribute is updated based on the attribute information of the to-be-processed attribute to determine the attribute value of the to-be-processed attribute after the update;
[0017] The determining manner corresponding to the attribute value of the associated attribute is determined based on a preset list;
[0018] The attribute value of the associated attribute is determined based on the determining manner corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute.
[0019] In some optional embodiments, the determining the attribute value of the associated attribute based on the determining manner corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute comprises:
[0020] The attribute value of the associated attribute in the same row as the to-be-processed attribute is updated according to the determining manner corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute;
[0021] The attribute values of the associated attributes of other rows in the target table are recursively processed based on the to-be-processed attribute after the update and the associated attributes in the same row as the to-be-processed attribute to update the attribute values of the associated attributes of the other rows.
[0022] In some optional embodiments, the determining the attribute value of the associated attribute based on the attribute value of the to-be-processed attribute and the corresponding determination manner of the attribute value of the associated attribute further includes:
[0023] updating the attribute value of the associated attribute in the target table based on the attribute value of the to-be-processed attribute and the corresponding determination manner of the attribute value of the associated attribute, to obtain an updated target table;
[0024] updating the attribute value of the associated attribute in the associated table based on the updated target table, to determine the attribute value of the associated attribute in the associated table, the associated table being associated with the target table.
[0025] In some optional embodiments, after the attribute value of the associated attribute in the associated table is updated based on the updated target table, to determine the attribute value of the associated attribute in the associated table, the method further includes:
[0026] determining a result attribute related to the associated attribute in the associated table based on the attribute value of the associated attribute in the associated table and the corresponding determination manner of the attribute value of the associated attribute, the result attribute being in the target table;
[0027] updating the attribute value of the result attribute based on the updated attribute value of the associated attribute in the associated table and the corresponding determination manner.
[0028] In a second aspect, an embodiment of the present application provides a data processing apparatus, and the apparatus includes:
[0029] a data acquisition module configured to acquire a type of a target table and attribute information of a to-be-processed attribute in the target table;
[0030] a manner determination module configured to determine a corresponding determination manner of an attribute value of the to-be-processed attribute based on the type and the attribute information;
[0031] an associated attribute determination module configured to obtain an associated attribute of the to-be-processed attribute based on the corresponding determination manner of the attribute value of the to-be-processed attribute;
[0032] an attribute updating module configured to determine the attribute value of the to-be-processed attribute and an attribute value of the associated attribute based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute.
[0033] In a third aspect, an embodiment of the present application provides a computer device, and the computer device includes a memory and a processor, the memory and the processor are communicatively connected with each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the data processing method in the first aspect or any of the corresponding embodiments.
[0034] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores computer instructions for causing a computer to execute the data processing method of the first aspect or any of the corresponding embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0035] In order to more clearly illustrate the specific embodiments or prior art technical solutions of the present application, the drawings needed in the specific embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0036] Figure 1 is a flowchart of a data processing method according to some embodiments of the present application;
[0037] Figure 2 is a structural block diagram of a data processing device according to an embodiment of the present application;
[0038] Figure 3 is a hardware structure schematic diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0040] When updating the data in each table in the database, since there is a certain association relationship between each attribute, and there is an association relationship between tables, modification of the A field may involve modification of the fields in the table where the A field is located and the fields of other tables. This process can be relatively complex, and there is a large amount of homogenization code implementation, and various implicit errors are prone to occur due to complex environment logic. In the related art, the modification of each data in the database table is usually implemented by code, which needs to be calculated by the relevant developers one by one, and a lot of time is needed, and the efficiency is low.
[0041] Based on this, an embodiment of the present application provides a data processing method, which will be further described in combination with the following several embodiments.
[0042] According to the embodiment of the present application, a data processing method is provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from here.
[0043] In the present embodiment, a data processing method is provided, which can be used in a terminal such as a computer, a tablet computer, Figure 1 is a flowchart of the data processing method according to the embodiment of the present application, as shown in Figure 1 The flowchart includes the following steps:
[0044] In step S11, the type of the target table and the attribute information of the to-be-processed attribute in the target table are obtained.
[0045] The target table refers to a table in which the attribute value needs to be modified. The type of the target table can be the name of the table and the business type of the table. The to-be-processed attribute refers to an attribute whose attribute value needs to be modified. The attribute information of the to-be-processed attribute can include the table to which the to-be-processed attribute belongs, the attribute name of the to-be-processed attribute, the id of the to-be-processed attribute, the attribute value of the to-be-processed attribute, etc.
[0046] The present embodiment can be used in a full update mode of a database or an incremental update mode of a database. Based on different update modes, the type of the target table and the attribute information of the to-be-processed attribute in the target table can be obtained in different ways, and the specific mode is not limited. The type of the applicable database includes a relational database.
[0047] In step S12, based on the type and the attribute information, the determination mode corresponding to the attribute value of the to-be-processed attribute is determined.
[0048] There is a certain association relationship between each attribute in the table of the database, each attribute has its calculation formula, and multiple calculation formulas are involved in a table. For example, the attribute value of attribute C is calculated by the attribute value of attribute B and the attribute value of attribute A, which can be understood as that attribute A and attribute B will affect attribute C. The determination mode corresponding to the attribute value of the to-be-processed attribute refers to the calculation formula in which the to-be-processed attribute is involved in the calculation formula of each attribute in the table.
[0049] Taking the target table including attribute A, attribute B and attribute C as an example, wherein attribute A is the to-be-processed attribute, the attribute value of attribute C = the attribute value of attribute A * the attribute value of attribute B, and the determination mode corresponding to the attribute value of attribute A is: the attribute value of attribute C = the attribute value of attribute A * the attribute value of attribute B.
[0050] In the present embodiment, the number of determination modes can be one or multiple, and the specific mode is not limited.
[0051] In step S13, the associated attributes of the to-be-processed attribute are obtained based on the determination mode corresponding to the attribute value of the to-be-processed attribute.
[0052] According to the determination mode corresponding to the attribute value of the to-be-processed attribute, the attributes involved in the determination mode are obtained, and the associated attributes refer to the attributes that are affected by the attribute value of the to-be-processed attribute.
[0053] The associated attributes of the to-be-processed attribute can include attributes having a direct association relationship with the to-be-processed attribute, and can also include attributes having an indirect association relationship with the to-be-processed attribute. The attributes having a direct association relationship refer to the attributes that can be affected by the attribute value of the to-be-processed attribute, and the attributes having an indirect association relationship refer to the attributes associated with the direct associated attributes. The associated attributes can be in the target table or in other tables, and the other tables can be considered as associated tables of the target table.
[0054] Taking the to-be-processed attribute as A, the determination mode corresponding to the attribute value of A includes A*B=C and C / D=E.
[0055] According to the above determination mode, the associated attributes of A include the attribute C and the attribute E, wherein the attribute C is a direct associated attribute, and the attribute E is an indirect associated attribute.
[0056] All entries of the to-be-processed attribute and the associated attributes are read from the cache, and if there are none, an initialization function is called to initialize, and each entry is stored in the cache. If other associated tables are involved, the association relationship between the target table and the associated table is established in the cache.
[0057] In step S14, the attribute value of the to-be-processed attribute and the attribute value of the associated attribute are determined based on the attribute information of the to-be-processed attribute and the associated attributes of the to-be-processed attribute.
[0058] The attribute value of the to-be-processed attribute is updated according to the attribute information of the to-be-processed attribute, and the attribute value of the associated attribute of the to-be-processed attribute is calculated based on the updated attribute value of the to-be-processed attribute.
[0059] Since the associated attributes can exist not only in the target table but also in other associated tables, the associated attributes in the other tables also need to be updated. In some cases, the attribute values of the associated attributes in the other tables can also affect the attribute values of some attributes in the target table, and therefore, the attribute values of the attributes associated with the target table also need to be updated based on the updated attribute values of the associated attributes in the other tables.
[0060] In the process of updating the associated attributes, the associated attributes whose attribute values change each time can be stored in an attribute list.
[0061] The data processing method provided in the embodiment acquires the type of a target table and attribute information of a to-be-processed attribute in the target table, determines a determination manner corresponding to an attribute value of the to-be-processed attribute based on the type and the attribute information, obtains an associated attribute of the to-be-processed attribute based on the determination manner corresponding to the attribute value of the to-be-processed attribute, and finally determines the attribute values of the to-be-processed attribute and the associated attribute. The scheme obtains the associated attribute of the to-be-processed attribute based on the determination manner corresponding to each to-be-processed attribute, so that the attribute value of the associated attribute can be updated according to the attribute value of the to-be-processed attribute, complex calculation scheduling of each attribute in a table and between tables can be implemented, and the calculation and updating efficiency of the attribute values in the table is improved.
[0062] In the embodiment, a data processing method is provided, which can be used in a terminal such as a computer or a tablet computer. The method comprises the following steps:
[0063] In step S21, the type of a target table and attribute information of a to-be-processed attribute in the target table are acquired.
[0064] For details, refer to step S11 of the embodiment shown in Figure 1 In the embodiment, a data processing method is provided, which can be used in a terminal such as a computer or a tablet computer. The method comprises the following steps:
[0065] In step S22, a determination manner corresponding to an attribute value of the to-be-processed attribute is determined based on the type and the attribute information.
[0066] Specifically, step S22 comprises:
[0067] In step S221, the determination manner corresponding to the attribute value of the to-be-processed attribute is acquired from a preset list based on the type of the target table. The preset list comprises a mapping relationship between the type of each table in a database and the determination manner of the attribute value.
[0068] The determination manner corresponding to the attribute value of the attribute can be one or multiple, the type of the table can be a business type, and it can be considered that each table in the database has a corresponding type. The type can also be an identification number of the table. The determination manner of the attribute value of each attribute in each table is stored in the preset list in advance. The determination manner can be understood as a calculation relationship between the attributes.
[0069] Based on the type of the target table, the determination manner corresponding to the attribute value of all attributes in the table of the type can be acquired from the preset list, including the determination manner corresponding to the attribute value of the to-be-processed attribute.
[0070] In step S23, an associated attribute of the to-be-processed attribute is obtained based on the determination manner corresponding to the attribute value of the to-be-processed attribute.
[0071] For details, refer to step S13 of the embodiment shown in Figure 1 In the embodiment, a data processing method is provided, which can be used in a terminal such as a computer or a tablet computer. The method comprises the following steps:
[0072] Step S24, determining the attribute value of the to-be-processed attribute and the attribute value of the associated attribute based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute.
[0073] For details, please refer to Figure 1 Step S14 of the embodiment shown will not be repeated here.
[0074] The data processing method provided by the embodiment can obtain the determination manner corresponding to the attribute value of the to-be-processed attribute from the preset list, pre-store the determination manner of each attribute value, facilitate direct obtaining according to the type of the target table, and further calculate the attribute values of the to-be-processed attribute and the associated attribute, thereby improving the calculation efficiency.
[0075] In the embodiment, a data processing method is provided, which can be used in terminals such as computers and tablet computers. The method comprises the following steps:
[0076] Step S31, obtaining the type of the target table and the attribute information of the to-be-processed attribute in the target table.
[0077] For details, please refer to Figure 1 Step S11 of the embodiment shown will not be repeated here.
[0078] Step S32, determining the determination manner corresponding to the attribute value of the to-be-processed attribute based on the type and the attribute information.
[0079] For details, please refer to Figure 1 Step S12 of the embodiment shown will not be repeated here.
[0080] Step S33, obtaining the associated attribute of the to-be-processed attribute based on the determination manner corresponding to the attribute value of the to-be-processed attribute.
[0081] Specifically, step S33 comprises the following steps:
[0082] Step S331, analyzing the determination manner corresponding to the attribute value of the to-be-processed attribute to obtain all attributes involved in the determination manner;
[0083] Step S332, extracting the associated attribute related to the attribute value of the to-be-processed attribute from all the attributes.
[0084] After determining the determination manner corresponding to the attribute value of the to-be-processed attribute, the determination manner is analyzed, and the associated attribute is determined from all the attributes analyzed. The attribute value of the associated attribute will change with the change of the attribute value of the to-be-processed attribute.
[0085] The associated attribute of the to-be-processed attribute can include an attribute having a direct association relationship with the to-be-processed attribute, and can also include an attribute having an indirect association relationship with the to-be-processed attribute. The attribute having a direct association relationship refers to an attribute that can be affected by the attribute value of the to-be-processed attribute. The attribute having an indirect association relationship can refer to an attribute associated with the direct association attribute. The associated attribute can be in the target table, or can be in another table, which can be considered as an associated table of the target table.
[0086] Taking the to-be-processed attribute as A, the determination mode corresponding to the attribute value of A includes A*B=C, C / D=E.
[0087] In the above example, all the attributes involved in the determination mode include attribute B, attribute C, attribute D and attribute E. The associated attributes include attribute C and attribute E, attribute C is a direct association attribute, and attribute E is an indirect association attribute.
[0088] Step S34, based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute, determining the attribute value of the to-be-processed attribute and the attribute value of the associated attribute.
[0089] For details, please refer to Figure 1 Step S14 of the embodiment shown in the figure will not be repeated here.
[0090] The data processing method provided by the embodiment determines the associated attribute by analyzing the determination mode corresponding to the attribute value of the to-be-processed attribute, and extracting the associated attribute related to the attribute value of the to-be-processed attribute from all attributes. This method does not need to calculate each attribute due to too many attributes involved in the determination mode, but only needs to update the impact term of the attribute value of the to-be-processed attribute, thereby avoiding unnecessary calculation and improving the efficiency of updating data in the database.
[0091] In the embodiment, a data processing method is provided, which can be used in terminals such as computers and tablet computers. The method includes the following steps:
[0092] Step S41, obtaining the type of the target table and the attribute information of the to-be-processed attribute in the target table.
[0093] For details, please refer to Figure 1 Step S11 of the embodiment shown in the figure will not be repeated here.
[0094] Step S42, based on the type and the attribute information, determining the determination mode corresponding to the attribute value of the to-be-processed attribute.
[0095] For details, please refer to Figure 1 Step S12 of the embodiment shown in the figure will not be repeated here.
[0096] Step S43, obtaining the associated attribute of the to-be-processed attribute based on the determination manner corresponding to the attribute value of the to-be-processed attribute.
[0097] For details, please refer to Figure 1 Step S13 of the embodiment shown will not be repeated here.
[0098] Step S44, determining the attribute value of the to-be-processed attribute and the attribute value of the associated attribute based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute.
[0099] Specifically, step S44 includes the following steps:
[0100] Step S441, updating the attribute value of the to-be-processed attribute based on the attribute information of the to-be-processed attribute, and determining the updated attribute value of the to-be-processed attribute.
[0101] The attribute information of the to-be-processed attribute contains the attribute value and the id, and the specific cell can be determined according to the id. The original attribute value is changed to the attribute value in the attribute information by assigning value to it, so as to determine the updated attribute value.
[0102] Step S442, determining the determination manner corresponding to the attribute value of the associated attribute based on the preset list.
[0103] The preset list stores the determination manner corresponding to the attribute value of the associated attribute in the target table. Specifically, the determination manner of all attribute values corresponding to the target table can be determined based on the target table, and then the determination manner of the attribute value of the associated attribute is extracted from all determination manners. Here, the associated attribute in the target table can also include the associated attribute in other tables, and the specific determination can be made according to the actual situation.
[0104] Step S443, determining the attribute value of the associated attribute based on the determination manner corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute.
[0105] According to the attribute value of the to-be-processed attribute and the determination manner corresponding to the attribute value of the to-be-processed attribute, the attribute value of the directly associated associated attribute is updated, and the attribute value of the indirectly associated associated attribute can be calculated and updated according to the updated attribute value of the directly associated associated attribute and the determination manner.
[0106] In some embodiments, step S443 includes the following steps:
[0107] Step S4431, updating the attribute value of the associated attribute in the same row as the to-be-processed attribute according to the determination manner corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute.
[0108] First, the attribute value of the associated attribute in the same row as the to-be-processed attribute is updated, which includes the directly associated attribute and the indirectly associated attribute, which can be calculated based on the attribute value of the directly associated attribute.
[0109] In step S4432, the attribute values of the associated attributes of other rows in the target table are recursively processed based on the updated to-be-processed attribute and the associated attribute in the same row as the to-be-processed attribute, to update the attribute values of the associated attributes of other rows.
[0110] After the associated attribute in the same row as the attribute value of the to-be-processed attribute is updated, the attribute values of other rows that can be affected by the attribute values of the row are calculated row by row, and the attribute values of the associated attributes of other rows are updated. The associated attribute in the embodiment is in the target table, and does not involve other tables.
[0111] In some embodiments, step S443 further includes the following steps:
[0112] In step S4433, the attribute values of the associated attributes in the target table are updated based on the determination mode corresponding to the attribute values of the associated attributes and the attribute value of the to-be-processed attribute, to obtain an updated target table.
[0113] First, the attribute values of all associated attributes in the target table are updated based on the attribute value of the to-be-processed attribute and the determination mode corresponding to the attribute values of the associated attributes. The specific updating process can be referred to steps S4431-S4432, which will not be described here.
[0114] In step S4434, the attribute values of the associated attributes in the associated table are updated based on the updated target table, and the attribute values of the associated attributes in the associated table are determined. The associated table is associated with the target table.
[0115] The associated table refers to a table associated with the target table. The associated table includes the associated attribute of the to-be-processed attribute, and the associated attribute in the associated table and the to-be-processed attribute can be a direct association or an indirect association. Based on the attribute values in the updated target table and the determination mode of the attribute values of the associated attributes in the associated table, the attribute values of the associated attributes in the associated table are updated, thereby obtaining the attribute values of the associated attributes in the associated table.
[0116] In some embodiments, the above step S4434 further includes the following steps:
[0117] In step a1, the result attribute related to the associated attribute in the associated table is determined based on the determination mode corresponding to the attribute values of the associated attributes in the associated table, and the result attribute is in the target table.
[0118] The determination mode of the attribute value of the association attribute in the association table is obtained from a preset list, wherein the attribute in the target table that is affected by the attribute value of the updated association attribute in the association table is a result attribute.
[0119] In step a2, the attribute value of the result attribute is updated based on the attribute value of the updated association attribute in the association table and the determination mode.
[0120] It is judged whether the attribute value of the association attribute in the association table will affect the attribute in the target table, and if so, the attribute value of the result attribute is calculated again according to the attribute value of the updated association attribute in the association table and the determination mode.
[0121] The method provided by the embodiment of the application updates the attribute value of the result attribute in the target table that is affected by the attribute value of the association attribute in the association table after the attribute value of the association attribute in the association table is updated, and avoids missing all attribute values that should be changed.
[0122] A data processing method is provided in combination with a specific scenario.
[0123] The following table is taken as an example, wherein the subject is a target table, and the library is an association table.
[0124]
[0125] The library is master data, the subject is sub-data of the library, the library number of the subject corresponds to the number of the library, the total price of the subject = unit price * quantity, the total price of the subject is aggregated to the parent item, and the total price of the library = the root-level total price of the subject of the library is aggregated.
[0126] The update of the data includes two methods of full update and incremental update, and first, the incremental update is taken as an example, and the execution process is as follows:
[0127] 1. The update information is transmitted, and the update information includes: type: subject; update id: 2; attribute: unit price; and value: 26.
[0128] 2. All calculation rules of the type are obtained, the calculation rule is a determination mode of the attribute value, and the calculation rules include: the total price of the subject = unit price * quantity, the total price of the subject is aggregated to the parent item, and the total price ratio of the subject = the total price of the subject / the total price of the library. The data of the specified type is read out from the cache, and if the cache does not have the data, an initialization function is called to initialize, the data of the subject with the number 2 is read, the library number 1 is obtained, the data of the library number 1 and the subject table with the library number 1 is executed, and the data is stored in the cache in pieces, and the association relationship between the subject and the library is established in the cache.
[0129] 3. The attribute value of the current data is set: the subject data with the number 2 in the cache is obtained, and the unit value is set to 26.
[0130] 4. Single-line calculation rule affected by current data update attribute is calculated (total price of subject = unit price * quantity), and the total price of the subject is 260, the total price of the data in the cache is updated to 260, and the update attribute (total price) is supplemented to the update attribute list.
[0131] 5. Single-line calculation rule affected by the update in the previous step is calculated (total price ratio of subject = total price of subject / total price of library, i.e. total price ratio = 1.3), and the update attribute (total price ratio of subject) is supplemented to the update attribute list.
[0132] 6. Multi-line calculation rule affected by current data update attribute is calculated line by line (total price of subject sub-item is aggregated to parent item, data of subject No. 1, total price is changed from 100 to 300), and the update attribute (total price) is supplemented to the update attribute list.
[0133] 7. Single-line calculation rule affected by the update in the previous step is calculated (total price ratio of subject = total price of subject / total price of library, i.e. total price ratio of subject No. 1 = 1.5), and the update attribute (total price ratio) is supplemented to the update attribute list.
[0134] 8. The data associated with the data is updated in steps 4 to 7, and the recursive processing is performed. This step obtains the associated data: library No. 1, executes the rule: total price of library = total price of subject root level of library, calculates the total price of library = total price of subject No. 1 and 4 = 300 + 100 = 400. The calculation of the total price ratio of the subject is affected by the calculation rule of the total price ratio of the subject, and the real total price ratio of the subject is calculated line by line. This calculation affects the total price ratio field of the subject table, and there is no calculation rule affected, and the calculation is completed.
[0135] The following is an example of full update, and the execution process is as follows:
[0136] 1. Obtain the specified table data (library data No. 1, subject data of library No. 1) and rules (total price of subject = unit price * quantity, total price of subject sub-item is aggregated to parent item, total price of library = total price of subject root level of library, total price ratio of subject = total price of subject / total price of library).
[0137] 2. Single-line calculation rule is calculated line by line (total price of subject = unit price * quantity, total price of library = total price of subject root level of library, total price ratio of subject = total price of subject / total price of library), and the update attribute is supplemented to the update attribute list.
[0138] 3. Multi-line calculation rule is calculated line by line (total price of subject sub-item is aggregated to parent item), and the update attribute is supplemented to the update attribute list.
[0139] 4. The single-line calculation rule affected by the previous update is calculated (the total amount of the subject accounts for the total amount of the subject accounts / the total amount of the library to which it belongs), and the update attribute is supplemented to the update attribute list.
[0140] 5. Update the associated data according to steps 2-4, and recursively process. This step obtains the associated data: library No. 1, executes the rule: the total amount of the library = the total amount of the subject accounts to which it belongs, and calculates the total amount of the library = the total amount of subject accounts No. 1 and No. 4 = 300 + 100 = 400. The calculation of the total amount of the subject accounts affected by the calculation of the total amount of the library No. 1, and the calculation of the true total amount of the subject accounts. This calculation affects the total amount of the subject table field, and there is no calculation rule, and the calculation is completed.
[0141] In the process of updating the table in the database, the updated data is detected and stored, and a mechanism for saving and clearing the data in the cache is provided.
[0142] In this method, in the processing of the mapping object, the data entity implements the CalcObjMap interface, and the CalcObjMap interface supports Map operations such as get and put of object attributes;
[0143] In the processing based on the reference object, the related calculation items referenced in the calculation item all use the CalcItemCacheRef class, and the related operations directly act on the object corresponding to the key in the cache, avoiding the problem of multiple assignments of multiple repeated objects.
[0144] In addition, it also supports updating and storing the update impact data, and the calculation item CalcItem in the calculation rule engine inherits Map, and the put and get operations of CalcItem directly act on its data attribute. When put, first compare the new and old data, if different, update, set the update attribute of itself to true, and record whether it is updated. When storing, only the data with update true is stored.
[0145] The embodiment of the present application supports the determination mode of single-row field and the determination mode of multi-row field, supports cross-table assignment, for example, supports the assignment of the calculation result of A table to the H field of B table, and the H field of B table is used in the calculation of A table in turn, supports full-amount calculation and incremental calculation, and supports recording of changed row data, facilitating fine-grained incremental update of data. (The calculation item CalcItem in the calculation rule engine inherits Map, and the put and get operations of CalcItem directly act on the data attribute of CalcItem. When put, the new and old data are compared first, and if they are different, the data is updated, and the update attribute of itself is set to true, which is used to record whether the update is performed. When warehousing, only the data with true update is warehoused.) Memory space is saved, the related reference positions adopt the space-saving reference object mode, single-point position update and new data acquisition are facilitated. The overall program logic is assembled in a configuration mode, and hidden BUGs are not easy to appear. Online configuration and maintenance can be performed, and the changes in demand can be quickly responded. After use, the homogenization code can be greatly reduced, and there is no need to write calculation code line by line, and the work efficiency of technical personnel is improved.
[0146] In the embodiment, a data processing apparatus is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and will not be described again. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation of hardware, or a combination of software and hardware, is also possible and contemplated.
[0147] The embodiment provides a data processing apparatus, as shown in the following Figure 2 The apparatus comprises:
[0148] The data acquisition module 51 is configured to acquire the type of a target table and attribute information of a to-be-processed attribute in the target table.
[0149] The mode determination module 52 is configured to determine a determination mode corresponding to an attribute value of the to-be-processed attribute based on the type and the attribute information.
[0150] The associated attribute determination module 53 is configured to obtain an associated attribute of the to-be-processed attribute based on the determination mode corresponding to the attribute value of the to-be-processed attribute.
[0151] The attribute update module 54 is configured to determine the attribute value of the to-be-processed attribute and the attribute value of the associated attribute based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute.
[0152] In some optional embodiments, the mode determination module 52 comprises:
[0153] A mode determination unit is configured to determine, based on the type of the target table, a determination mode corresponding to the attribute value of the to-be-processed attribute from a preset list, the preset list including a mapping relationship between the type of each table in the database and the determination mode of the attribute value.
[0154] In some optional embodiments, the associated attribute determination module 53 includes:
[0155] A mode analysis unit is configured to analyze the determination mode corresponding to the attribute value of the to-be-processed attribute to obtain all attributes involved in the determination mode.
[0156] An associated attribute determination unit is configured to extract, from the all attributes, an associated attribute related to the attribute value of the to-be-processed attribute.
[0157] In some optional embodiments, the attribute updating module 54 includes:
[0158] A first updating unit is configured to update the attribute value of the to-be-processed attribute based on the attribute information of the to-be-processed attribute, and determine an updated attribute value of the to-be-processed attribute.
[0159] A first mode determination unit is configured to determine, based on a preset list, a determination mode corresponding to the attribute value of the associated attribute.
[0160] A second updating unit is configured to determine the attribute value of the associated attribute based on the determination mode corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute.
[0161] In some optional embodiments, the second updating unit includes:
[0162] A first same-table updating subunit is configured to update, according to the determination mode corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute, the attribute value of the associated attribute in the same row as the to-be-processed attribute.
[0163] A second same-table updating subunit is configured to recursively process, based on the updated to-be-processed attribute and the associated attribute in the same row as the to-be-processed attribute, the attribute value of the associated attribute in other rows of the target table, to update the attribute value of the associated attribute in the other rows.
[0164] In some optional embodiments, the second updating unit further includes:
[0165] A target table updating subunit is configured to update, based on the determination mode corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute, the attribute value of the associated attribute in the target table, to obtain an updated target table.
[0166] The association table update subunit is used to update the attribute values of the association attributes in the association table based on the updated target table, and to determine the attribute values of the association attributes in the association table, wherein the association table is associated with the target table.
[0167] In some optional implementations, the second updating unit further includes:
[0168] The result attribute determination unit is used to determine the result attribute related to the associated attribute in the association table based on the determination method corresponding to the attribute value of the associated attribute in the association table, wherein the result attribute is in the target table;
[0169] The result attribute update unit is used to update the attribute value of the result attribute based on the updated attribute value of the associated attribute in the association table and the determination method.
[0170] In this embodiment, the data processing device is presented in the form of a functional unit. Here, a unit refers to an ASIC circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above-mentioned functions.
[0171] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0172] This invention also provides a computer device having the above-described features. Figure 2 The data processing device shown.
[0173] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 3 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 3 Take a processor 10 as an example.
[0174] The processor 10 can be a central processor, a network processor, or a combination thereof. The processor 10 can further include a hardware chip. The hardware chip can be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device can be a complex programmable logic device, a field programmable logic gate array, a generic array logic, or any combination thereof.
[0175] The memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods illustrated in the above embodiments.
[0176] The memory 20 can include a program storage area and a data storage area. The program storage area can store an operating system and applications required by at least one function. The data storage area can store data created by the use of the computer device according to the presentation of a small program landing page, and the like. In addition, the memory 20 can include a high-speed random access memory, and can further include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some alternative embodiments, the memory 20 can optionally include a memory disposed remotely from the processor 10, and these remote memories can be connected to the computer device through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0177] The memory 20 can include a volatile memory, such as a random access memory, and can also include a non-volatile memory, such as a flash memory, a hard disk, or a solid state disk. The memory 20 can further include a combination of the above-mentioned types of memories.
[0178] The computer device further includes a communication interface 30 for communication of the computer device with other devices or communication networks.
[0179] The embodiments of the present application further provide a computer readable storage medium, and the method according to the embodiments of the present application can be implemented in hardware, firmware, or recorded in a storage medium, or be implemented as computer codes stored in a remote storage medium or a non-transitory machine readable storage medium and downloaded through a network and stored in a local storage medium, so that the method described herein can be processed by such software on a storage medium using a general purpose computer, a special purpose processor, or programmable or special hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid state disk, etc. Further, the storage medium can also include a combination of the above-mentioned types of memories. It can be understood that the computer, the processor, the microprocessor controller, or the programmable hardware includes a storage component that can store or receive software or computer codes, when the software or computer codes are accessed and executed by the computer, the processor, or the hardware, the method shown in the above embodiments is implemented.
[0180] Although the embodiments of the present application are described in conjunction with the accompanying drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and changes fall within the scope defined by the appended claims.
Claims
1. A data processing method, characterized by, The method comprises: acquiring a type of a target table and attribute information of an attribute to be processed in the target table; determining a determination manner corresponding to an attribute value of the attribute to be processed based on the type and the attribute information, comprising: acquiring the determination manner corresponding to the attribute value of the attribute to be processed from a preset list based on the type of the target table, the preset list comprising a mapping relationship between the type of each table in a database and the determination manner of the attribute value; obtaining an associated attribute of the attribute to be processed based on the determination manner corresponding to the attribute value of the attribute to be processed; determining the attribute value of the attribute to be processed and an attribute value of the associated attribute based on the attribute information of the attribute to be processed and the associated attribute of the attribute to be processed, comprising: updating the attribute value of the attribute to be processed based on the attribute information of the attribute to be processed to determine an updated attribute value of the attribute to be processed; determining a determination manner corresponding to the attribute value of the associated attribute based on a preset list; determining the attribute value of the associated attribute based on the determination manner corresponding to the attribute value of the associated attribute and the attribute value of the attribute to be processed.
2. The method of claim 1, wherein, The determination manner corresponding to the attribute value of the attribute to be processed comprises: parsing the determination manner corresponding to the attribute value of the attribute to be processed to obtain all attributes involved in the determination manner; extracting the associated attribute related to the attribute value of the attribute to be processed from the all attributes.
3. The method of claim 1, wherein, The determination manner corresponding to the attribute value of the associated attribute and the attribute value of the attribute to be processed comprises: updating the attribute value of the associated attribute in the same row as the attribute to be processed according to the determination manner corresponding to the attribute value of the associated attribute and the attribute value of the attribute to be processed; recursively processing the attribute values of the associated attributes in other rows in the target table based on the updated attribute to be processed and the associated attributes in the same row as the attribute to be processed, to update the attribute values of the associated attributes in the other rows.
4. The method of claim 1, wherein, The determination manner corresponding to the attribute value of the associated attribute and the attribute value of the attribute to be processed further comprises: updating the attribute values of the associated attributes in the target table based on the determination manner corresponding to the attribute value of the associated attribute and the attribute value of the attribute to be processed to obtain an updated target table; updating the attribute values of the associated attributes in an associated table based on the updated target table to determine the attribute values of the associated attributes in the associated table, the associated table being associated with the target table.
5. The method of claim 4, wherein, After the attribute values of the associated attributes in the associated table are updated based on the updated target table to determine the attribute values of the associated attributes in the associated table, the method further comprises: determining a result attribute related to the associated attributes in the associated table based on the determination manner corresponding to the attribute values of the associated attributes in the associated table, the result attribute being in the target table; updating the attribute value of the result attribute based on the updated attribute values of the associated attributes in the associated table and the determination manner.
6. A data processing apparatus, characterized by The device comprises: The data acquisition module is configured to acquire a type of a target table and attribute information of a to-be-processed attribute in the target table. The mode determination module is configured to determine a determination mode corresponding to an attribute value of the to-be-processed attribute based on the type and the attribute information. The associated attribute determination module is configured to obtain an associated attribute of the to-be-processed attribute based on the determination mode corresponding to the attribute value of the to-be-processed attribute. The attribute updating module is configured to determine the attribute value of the to-be-processed attribute and an attribute value of the associated attribute based on the attribute information of the to-be-processed attribute and the associated attribute of the to-be-processed attribute. The mode determination module includes a mode determination unit configured to acquire the determination mode corresponding to the attribute value of the to-be-processed attribute from a preset list based on the type of the target table, the preset list including a mapping relationship between types of tables in a database and determination modes of attribute values. The attribute updating module includes a first updating unit configured to update the attribute value of the to-be-processed attribute based on the attribute information of the to-be-processed attribute, and determine an updated attribute value of the to-be-processed attribute; a first mode determination unit configured to determine the determination mode corresponding to the attribute value of the associated attribute based on the preset list; and a second updating unit configured to determine the attribute value of the associated attribute based on the determination mode corresponding to the attribute value of the associated attribute and the attribute value of the to-be-processed attribute.
7. A computer device, comprising: The data processing apparatus includes: a memory and a processor, which are communicatively connected, and the memory stores computer instructions, and the processor executes the computer instructions to perform the data processing method in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to make a computer execute the data processing method in any one of claims 1 to 5.
Citation Information
Patent Citations
Updating method and system for associated data of non-relational database
CN107315764A
Configuration linkage method and device
CN110532274A