Data storage method and related equipment
By deleting cold balance records and merging cold transaction records within the database, the problem of increased storage space in existing technologies is solved, achieving smaller storage space requirements and higher storage efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-04-03
AI Technical Summary
Existing data storage methods reduce the storage requirements of the main database but increase the additional requirements for cold data storage, resulting in an increase in overall storage space.
By deleting cold balance records with zero values and merging cold transaction records of the same dimension within the database, the total amount of data stored in the database is reduced. A general solution is adopted that does not depend on a specific database and is specifically optimized for balance tables and transaction tables.
It effectively reduces storage space requirements, decreases the total amount of data stored in the database, avoids increased storage requirements due to additional storage of cold data, and improves the utilization efficiency of storage space.
Smart Images

Figure CN121786029A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage, and more specifically, to data storage methods, data storage devices, data storage equipment, computer-readable storage media, and computer program products containing instructions. Background Technology
[0002] With the development of enterprise resource management, especially in ERP (Enterprise Resource Planning) systems, the challenge of continuously increasing data storage needs has emerged.
[0003] The existing data storage method uses "horizontal database sharding," which divides data into "cold data" (data that is not frequently accessed) and "hot data" (data that is frequently accessed) based on certain business fields (such as time fields). Cold data is migrated to lower-cost storage devices to reduce the storage burden on the main database, avoid system performance bottlenecks, and attempt to reduce hardware costs.
[0004] However, even with horizontal database partitioning, while reducing the storage requirements of the primary database, the introduction of cold data storage increases additional storage needs, resulting in an overall increase in storage requirements. Therefore, existing data storage methods require a relatively large amount of storage space. Summary of the Invention
[0005] This application provides a data storage method, a data storage device, a data storage equipment, a computer-readable storage medium, and a computer program product containing instructions for data storage while reducing the required storage space.
[0006] In a first aspect, embodiments of this application provide a data storage method, including:
[0007] Delete the target balance records with zero balance values in the initial balance tables of each tenant in the database to obtain the target balance tables for each tenant. Each balance record in the target balance table includes the dimension corresponding to each balance identifier and the balance value.
[0008] Multiple target transaction records of the same dimension in the initial transaction records of each tenant in the database are merged to obtain merged transaction records of the same dimension. The multiple target transaction records of the same dimension in the initial transaction records are replaced with merged transaction records of the same dimension to obtain target transaction records for each tenant. Each transaction record in the target transaction record includes a balance identifier corresponding to each transaction identifier and a transaction value.
[0009] Save the target balance table and the target transaction table of each tenant to the database.
[0010] Secondly, embodiments of this application provide a data storage device, including:
[0011] The acquisition unit is used to delete target balance records with zero balance values in the initial balance tables of each tenant in the database to obtain target balance tables for each tenant. Each balance record in the target balance table includes a dimension corresponding to each balance identifier and a balance value.
[0012] The acquisition unit is further configured to merge multiple target transaction records of the same dimension in the initial transaction table of each tenant in the database to obtain the merged transaction record of the same dimension, and replace the multiple cold transaction records of the same dimension in the initial transaction table with the merged transaction record of the same dimension to obtain the target transaction table of each tenant. Each transaction record in the target transaction table includes a balance identifier corresponding to each transaction identifier and a transaction value.
[0013] The storage unit is used to save the target balance table and the target transaction table of each tenant to the database.
[0014] Thirdly, embodiments of this application provide a data storage device, including:
[0015] Central processing unit, memory, input / output interfaces, wired or wireless network interfaces, and power supply;
[0016] The memory is either a short-term storage memory or a persistent storage memory;
[0017] The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the aforementioned data storage method.
[0018] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a computer, cause the computer to perform the aforementioned data storage method.
[0019] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on a computer, cause the computer to execute the aforementioned data storage method.
[0020] As can be seen from the above technical solutions, the embodiments of this application have the following advantages: By directly optimizing the data within the database, i.e., deleting cold balance records with zero values and merging cold transaction records of the same dimension, this method reduces the total amount of data stored in the database compared to the existing horizontal database partitioning method, and avoids the increased storage requirements due to additional storage of cold data, thus reducing the demand for storage space. Therefore, the data storage method of this application requires less storage space.
[0021] Accordingly, the data storage device, data storage equipment, computer-readable storage medium, and computer program product containing instructions provided in this application also have the aforementioned technical effects. Attached Figure Description
[0022] Figure 1 This is a schematic diagram of the architecture of a data storage system disclosed in an embodiment of this application;
[0023] Figure 2 This is a flowchart illustrating a data storage method disclosed in an embodiment of this application;
[0024] Figure 3 This is a schematic diagram of the structure of a data storage device disclosed in an embodiment of this application;
[0025] Figure 4 This is a schematic diagram of the structure of a data storage device disclosed in an embodiment of this application. Detailed Implementation
[0026] This application provides a data storage method, a data storage device, a data storage equipment, a computer-readable storage medium, and a computer program product containing instructions for data storage while reducing the required storage space.
[0027] The relevant technical features in this field are described as follows:
[0028] 1. Balance Records: A balance record is a record that uses multiple columns to summarize a set of values. These columns are called dimension columns, the value columns are called balance columns, and the entire record is called a balance record. Each balance record is determined by the value of a dimension column and is unique. For example, Record 1: A1 Organization + B1 Material + C1 Warehouse Basic Quantity = 100, is a balance record. In this case, Organization, Material, and Warehouse are called dimension columns, and Basic Quantity is called the balance column. A1 Organization + B1 Material + C1 Warehouse is unique; different values in any dimension column result in different records. For example, Record 2: A2 Organization + B1 Material + C1 Warehouse Basic Quantity = 200, is a completely different balance record due to the different organization.
[0029] 2. Snapshot Records: These records document every change in the balance record, including: what document, at what time, according to what rules, which balance record needed to be updated, and the amount of change for each number. They are also called transaction logs. The relationship between snapshot records and balance records is N:1.
[0030] 3. Balance Sheet: A table structure used to store balance records, typically stored in a database such as MySQL or Oracle. It consists of a header and a body. The header records the dimension columns and the balance column, while the body records the specific value of each balance record. It can also be called an ledger table.
[0031] 4. Snapshot table: A table structure used to store snapshot records, usually stored in a database such as MySQL or Oracle.
[0032] Please see Figure 1 The architecture of the data storage system in this application embodiment includes:
[0033] Data storage device 101 and client 102. When data storage is performed, data storage device 101 can connect to client 102. Data storage device 101 can delete target balance records with zero balance values in the initial balance tables of each tenant in the database to obtain target balance tables for each tenant; merge multiple target transaction records of the same dimension in the initial transaction tables of each tenant in the database to obtain merged transaction records of the same dimension; replace multiple target transaction records of the same dimension in the initial transaction tables with merged transaction records of the same dimension to obtain target transaction tables for each tenant; and save the target balance tables and target transaction tables for each tenant to the database. Data storage device 101 can receive update requests from target tenants sent by client 102, generate and save the updated target balance tables and / or target transaction tables for the target tenants to the database. Data storage device 101 can also receive rollback requests from target tenants sent by client 102, generate and save the rolled-back target balance tables for the target tenants to the database.
[0034] based on Figure 1 Please refer to the data storage system shown. Figure 2 , Figure 2 This is a flowchart illustrating a data storage method disclosed in an embodiment of this application. The method includes:
[0035] 201. Delete the target balance records with zero balance values in the initial balance tables of each tenant in the database to obtain the target balance tables for each tenant. Each balance record in the target balance table includes the dimension corresponding to each balance identifier and the balance value.
[0036] In one optional implementation, the database may include, but is not limited to, various databases within the ERP platform; specific details are not limited here. A balance identifier refers to a field or value in the balance table that uniquely identifies each balance record. A balance table refers to a database table that records balance information, such as an inventory balance table or an account balance table, but is not limited to a specific type of balance table. Target balance records are balance records with an exponential value of zero that have remained unchanged for a long period; these records are considered "cold" data because they are not frequently accessed. A dimension can be a single field or a combination of fields used to describe the characteristics of a balance record, such as product type, time, location, etc. There is a one-to-one mapping relationship between balance identifiers and dimensions.
[0037] 202. Merge multiple target transaction records of the same dimension in the initial transaction records of each tenant in the database to obtain merged transaction records of the same dimension. Replace the multiple target transaction records of the same dimension in the initial transaction records with merged transaction records of the same dimension to obtain the target transaction records of each tenant. Each transaction record in the target transaction records includes the balance identifier corresponding to each transaction identifier and the transaction value.
[0038] In one alternative implementation, a transaction identifier refers to a field or value in a transaction table that uniquely identifies each transaction record. A transaction table is a database table that records details of business transactions or events, such as an inventory transaction table that records every change in inventory. A target transaction record refers to a transaction record in the same dimension of the transaction table that has not changed for a long time or is infrequently accessed. There is a many-to-one mapping relationship between transaction identifiers and balance identifiers; that is, a balance record in the balance table can correspond to at least one transaction record in the transaction table. For example, a single sale may involve multiple transaction records.
[0039] 203. Save the target balance table and target transaction table of each tenant to the database.
[0040] In an alternative implementation, the processed data (such as the target balance sheet and target transaction record) can be saved back to the original database to achieve data optimization.
[0041] In this way, by optimizing data directly within the database—specifically by deleting cold balance records with zero values and merging target transaction records of the same dimension—this method reduces the total amount of data stored in the database compared to existing horizontal database partitioning methods. It also avoids the increased storage requirements caused by storing additional cold data, thus lowering the storage space requirement. Therefore, the data storage method of this application requires less storage space.
[0042] It's worth noting that existing technologies can also employ columnar storage, which reduces data size at the storage layer by using a specific database engine. However, this method lacks versatility and relies on specific database components. Most ERP systems use relational databases, which typically employ row-based storage and do not support columnar storage. Existing ERP systems also need to adapt to various databases, most of which do not support columnar storage technology. This application provides a universal solution that does not depend on a specific database, specifically designed for balance sheets and transaction records, effectively reducing storage space requirements. In other words, this application does not rely on specific databases or database sharding technologies and has high versatility.
[0043] In one optional implementation, the target balance records with zero balance values in the initial balance tables of each tenant in the database are deleted to obtain the target balance tables for each tenant. This includes: taking the balance records with zero balance values before a first preset time point in the initial balance tables of each tenant in the database as target balance records and deleting the target balance records to obtain the target balance tables for each tenant. Furthermore, multiple target transaction records of the same dimension in the initial transaction tables of each tenant in the database are merged to obtain merged transaction records of the same dimension. This includes: taking multiple transaction records of the same dimension in the initial transaction tables of each tenant in the database before a second preset time point as multiple target transaction records of the same dimension and merging the multiple target transaction records of the same dimension to obtain merged transaction records of the same dimension.
[0044] Specifically, the first preset time point can refer to a time limit set by the tenant to identify which balance records are considered "target balance records (cold balance records)" (i.e., inactive balance records that have not changed or been accessed for a long time). The second preset time point can refer to another time limit set by the tenant to identify which transaction records (detailed records of transactions or events) are considered "target transaction records (cold transaction records)" (i.e., inactive transaction records that have not changed or been accessed for a long time).
[0045] More specifically, a technical solution for deleting target balance records can be as follows: Based on the last modification time (a first preset time point) in the balance records, filter out balance records whose values were all zero N days ago, and remove these balance records from the initial balance table. This significantly reduces the amount of data recorded in the initial balance table and the overall storage space. It's important to understand that in actual business operations, balance tables like those for inventory, where product inventory has dimensions such as batch numbers and shelf lives, will eventually reach zero as procurement and sales occur and will not change again. This type of data is suitable for data separation. Please refer to Table 1 for details; Table 1 is the initial balance table for a certain inventory.
[0046]
[0047] Table 1
[0048] As shown in Table 1, assuming the first preset time point is January 1, 2025, we can filter out data whose last modification time is less than January 1, 2025 (in actual operation, it is specified by the user / tenant) and whose values are all 0. Then, the balance records with FID (balance identifier) = {2, 4, 6} will be deleted from the initial balance table to obtain the target balance table. Please refer to Table 2 for the target balance table. Table 2 is the target balance table for a certain inventory.
[0049]
[0050] Table 2
[0051] More specifically, the technical solution for merging the target transaction records is as follows: N snapshot records (transaction records) corresponding to the same balance record that are earlier than a certain time point (second preset time point) are merged into one, and the numerical parts are summarized. Please refer to Table 3, which is the initial transaction table.
[0052]
[0053] Table 3
[0054] As shown in Table 3, assuming the second preset time point is January 1, 2025, data with an update time less than January 1, 2025 (in actual operation, this is specified by user / tenant) can be filtered out, grouped by balance ID (balance identifier), and the values are summed. For example, there are 4 records with balance ID = 1001 that can be merged, resulting in a value of -20; and 2 records with balance ID = 1001 that can be merged, resulting in a value of 10. After generating a merged transaction record from the snapshot (transaction record) corresponding to each balance record ID, the original snapshot records (transaction records) in Table 3 with transaction records FID (balance identifier) = {1,2,3,4,6,7} can be deleted, thus obtaining the target transaction table in Table 4.
[0055]
[0056] Table 4
[0057] As shown in Table 4, the amount of data in Table 4 was reduced from 8 rows to 4 rows. In actual operation, the reduction ratio is related to the selected time point. The total number of records was significantly reduced, achieving the effect of storage optimization.
[0058] In this way, by filtering and deleting cold balance records with a value of zero and merging cold transaction records, the amount of data stored in the database is reduced, thereby saving storage space.
[0059] In an optional implementation, after saving the target balance table and target transaction table of each tenant to the database, the method further includes: obtaining an update request from the target tenant, the update request being used to increase or decrease the balance value and / or transaction value of the target dimension of the target tenant by a first value, the update request including the target dimension; determining the balance record update information corresponding to the target dimension based on the determination result of whether there is a balance record of the target dimension in the target balance table of the target tenant and the update request, so as to obtain the updated target balance table of the target tenant based on the updated balance record update information corresponding to the target dimension, and saving the updated target balance table of the target tenant to the database; and / or adding a new transaction record of the target dimension to the target transaction table of the target tenant, and increasing or decreasing the transaction value of the new transaction record of the target dimension by a first value to obtain the updated transaction value corresponding to the target dimension, generating the transaction record update information corresponding to the target dimension to obtain the updated target transaction table of the target tenant, and saving the updated target transaction table of the target tenant to the database, wherein the transaction value of the new transaction record of the target dimension is zero.
[0060] Specifically, it dynamically manages and updates balance and transaction records in the database. It receives update requests, adjusts balance or transaction values for specific dimensions, and saves the updated data back to the database. This ensures that the balance and transaction data in the database promptly reflects the latest business activities, while also guaranteeing data real-time performance and accuracy.
[0061] In one optional implementation, determining the balance record update information corresponding to the target dimension based on the determination result of whether a balance record of the target dimension exists in the target tenant's target balance table and the update request includes: if the target tenant's target balance table does not contain a balance record of the target dimension, then a new balance record of the target dimension is created, and the balance value of the new balance record of the target dimension is increased or decreased by a first value to obtain the updated balance value corresponding to the target dimension, so as to generate the balance record update information corresponding to the target dimension, wherein the balance value of the new balance record of the target dimension is zero; if the target tenant's target balance table contains a balance record of the target dimension, then the balance record value of the target dimension in the target balance table is increased or decreased by a first value to obtain the updated balance value corresponding to the target dimension, so as to generate the balance record update information corresponding to the target dimension.
[0062] Specifically, if a specific dimension of the balance record is missing from the target balance table, the system determines that the balance value of that dimension's balance record is zero (e.g., it was previously deleted as cold balance data). In this case, the system creates a new balance record and, based on the update request, increases or decreases the balance value of this new balance record to generate the corresponding balance record update information for the target dimension. If the target balance table already contains a balance record for that specific dimension, the system directly increases or decreases the balance value of that dimension's balance record to generate the corresponding balance record update information for the target dimension.
[0063] In this way, historical dimensions that no longer exist can be automatically initialized to zero and adjusted according to update requests, while dimensions that still exist are updated directly. This ensures that the balance record table in the database accurately reflects the latest business activities, thereby improving the efficiency and accuracy of updates.
[0064] In one optional implementation, after deleting target balance records with zero balance values in the initial balance tables of each tenant in the database to obtain target balance tables for each tenant, the method further includes: compressing the dimensions in the target balance records of each tenant according to a preset compression algorithm to obtain compressed dimensions for each tenant, and saving the compressed dimensions to the compressed tables of each tenant according to the balance identifiers in the target balance records of each tenant. Furthermore, after saving the target balance tables and target transaction tables of each tenant to the database, the method further includes: obtaining a rollback request from the target tenant, the rollback request being used to increase or decrease the amount value and / or transaction value of the target dimension corresponding to the target balance identifier of the target tenant by a second value, the rollback request including the target balance identifier; obtaining and decompressing the target compressed dimension from the compressed table of the target tenant based on the target balance identifier; creating a new balance record for the target dimension based on the decompressed target dimension; increasing or decreasing the balance value of the new balance record for the target dimension by a second value to obtain the rollback balance value corresponding to the target dimension, and generating a target dimension pair. The corresponding balance record rollback information is generated to obtain the target balance table of the target tenant after rollback, and the target balance table of the target tenant after rollback is saved to the database. The balance value of the new balance record of the target dimension is zero. A new transaction record of the target dimension corresponding to the target balance identifier is added to the target transaction table of the target tenant, and the transaction value of the new transaction record of the target dimension is increased or decreased by a second value to obtain the rollback transaction value corresponding to the target dimension. The transaction record rollback information corresponding to the target dimension is generated to obtain the target transaction table of the target tenant after rollback, and the target transaction table of the target tenant after rollback is saved to the database. The transaction value of the new transaction record of the target dimension is zero.
[0065] Specifically, the preset compression algorithms include, but are not limited to, any compression technology such as GZIP, ZIP, BZIP2, and LZMA; no specific limitation is made here. A compressed table refers to a new table created in the database to store dimensional information compressed using the preset compression algorithm.
[0066] It is important to understand that since the rollback request includes the target balance identifier but not the dimension information, the dimension information in the target balance record can be compressed and saved first to further optimize storage. Then, when processing the rollback request, the previous dimension information can be restored by decompressing the dimension information, and the rollback operation can be performed to obtain the rollback information of the transaction record corresponding to the target dimension, so as to obtain the target transaction table of the target tenant after rollback.
[0067] More specifically, please refer to the example in Table 1. After filtering out data with a last modification time less than January 1, 2025 (or as specified by the user in actual operation) and all amount records with a value of 0, you can extract the dimension values (dimensional information) of the three selected amount records with FID={2, 4, 6}. Then, concatenate the specific dimension values and use a preset compression algorithm to compress the string, resulting in a shorter string, which is then stored in a compressed table. For example, if the preset compression algorithm is GZIP, FID = 2, and the original string = W11, W21, ... WN1, the string can reach hundreds or thousands of characters in length. After GZIP compression, it becomes = XXX2, which is significantly shortened. The compressed string is then stored in a separate table, as detailed in Table 5.
[0068]
[0069] Table 5
[0070] For example, suppose a target tenant needs to reverse a reduction in inventory of a certain product made a week ago (e.g., 100 units were mistakenly reduced, resulting in a balance of 0, and now 100 units need to be added back). The system can decompress the relevant dimension information of the product from the compressed table, create a new balance record, set the inventory quantity of this record to 0, and then add 100 to the 0 to obtain an updated balance of 100, thus generating an updated balance table. This updated balance table is then saved back to the database. Simultaneously, a new record is added to the target tenant's transaction log, reflecting the increase of 100 units in inventory quantity.
[0071] In this way, compressing unnecessary data in advance can reduce storage requirements. The inventors' tests showed that storing compressed data in additional physical tables can compress approximately 50%-80% of records, achieving a compression rate of about 30%-40%, which significantly reduces storage needs. Secondly, compressing this dimensional information also allows for data restoration when rollback operations are needed, thereby improving the efficiency and accuracy of rollback operations.
[0072] In an optional implementation, the method further includes: obtaining a first query request for the target tenant's balance record for the target dimension; if the target tenant's target balance table does not contain a balance record for the target dimension, then creating a new balance record for the target dimension and using the new balance record for the target dimension as the query result of the first query request, wherein the balance value of the new balance record is zero; if the target tenant's target balance table contains a balance record for the target dimension, then using the balance record for the target dimension in the target balance table as the query result of the target tenant's query request.
[0073] Specifically, by ensuring that only necessary balance records are retained in the target tenant's balance table, the amount of data in the database is reduced, thereby improving query efficiency. For balance records that do not exist in the target balance table, the system can automatically create and initialize them with a balance value of zero, and then return the result, simplifying the data management process. This reduction in the amount of data in the balance table directly leads to faster query speeds, thus improving the query performance for balance records.
[0074] In an optional implementation, the method further includes: obtaining a second query request for the transaction record of the target tenant for the target balance identifier, and taking at least one transaction record corresponding to the target balance identifier in the target tenant's target transaction table as the query result of the second query request.
[0075] Specifically, ensure that each tenant's target transaction table in the database contains only the necessary transaction records, thereby reducing the amount of data in the database and improving query efficiency. For transaction records that are not frequently accessed (i.e., target transaction records), since tenants usually do not need to query the specific values of these records, merging target transaction records with the same dimensions can reduce storage requirements while ensuring query results and improving the query performance of transaction records.
[0076] For further details, please refer to Figure 3 One embodiment of the data storage device in this application includes:
[0077] The acquisition unit is used to delete target balance records with zero balance values in the initial balance tables of each tenant in the database to obtain target balance tables for each tenant. Each balance record in the target balance table includes a dimension corresponding to each balance identifier and a balance value.
[0078] The acquisition unit is further configured to merge multiple target transaction records of the same dimension in the initial transaction records of each tenant in the database to obtain merged transaction records of the same dimension, and replace the multiple target transaction records of the same dimension in the initial transaction records with the merged transaction records of the same dimension to obtain target transaction records for each tenant. Each transaction record in the target transaction record includes a balance identifier corresponding to each transaction identifier and a transaction value.
[0079] The storage unit is used to save the target balance table and the target transaction table of each tenant to the database.
[0080] In one alternative implementation, the acquisition unit may be used for:
[0081] The target balance records are obtained by taking the balance records with zero balance values in the initial balance table of each tenant in the database before the first preset time point and deleting the cold balance records.
[0082] The database takes multiple transaction records of the same dimension in each tenant's initial transaction record table before the second preset time point as multiple target transaction records of the same dimension, and merges the multiple target transaction records of the same dimension to obtain the merged transaction record of the same dimension.
[0083] In one alternative implementation, the acquisition unit may be used for:
[0084] Obtain an update request from a target tenant, the update request being used to increase or decrease a first value in the balance value and / or transaction value of the target dimension of the target tenant, the update request including the target dimension;
[0085] Based on the determination result of whether the target dimension balance record exists in the target tenant's target balance table and the update request, the balance record update information corresponding to the target dimension is determined, so as to obtain the updated target tenant's target balance table based on the balance record update information corresponding to the target dimension, and the updated target tenant's target balance table is saved to the database.
[0086] and / or
[0087] A new target transaction record for the target dimension is added to the target transaction table of the target tenant. The transaction value of the target transaction record for the target dimension is increased or decreased by a first value to obtain the updated transaction value corresponding to the target dimension. The transaction record update information corresponding to the target dimension is generated to obtain the updated target transaction table of the target tenant. The updated target transaction table of the target tenant is saved to the database. The transaction value of the new transaction record for the target dimension is zero.
[0088] In one alternative implementation, the acquisition unit may be used for:
[0089] If the target tenant's target balance table does not contain a balance record for the target dimension, a new balance record for the target dimension is created, and the balance value of the new balance record for the target dimension is increased or decreased by a first value to obtain the updated balance value corresponding to the target dimension, so as to generate the balance record update information corresponding to the target dimension. The balance value of the new balance record for the target dimension is zero.
[0090] If the target tenant's target balance table contains a balance record for the target dimension, then the balance record value for the target dimension in the target balance table is increased or decreased by a first value to obtain the updated balance value corresponding to the target dimension, thereby generating the balance record update information corresponding to the target dimension.
[0091] In one alternative implementation, the storage unit may be used for:
[0092] The dimensions in the target balance records of each tenant are compressed according to a preset compression algorithm to obtain the compressed dimensions of each tenant, and the compressed dimensions are saved to the compression table of each tenant according to the balance identifier in the target balance records of each tenant.
[0093] The acquisition unit can be used for:
[0094] Obtain the rollback request of the target tenant. The rollback request is used to increase or decrease the amount value and / or transaction value of the target dimension corresponding to the target balance identifier of the target tenant by a second value. The rollback request includes the target balance identifier.
[0095] Based on the target balance identifier, the target compressed dimension is obtained from the compressed table of the target tenant and decompressed. A new balance record for the target dimension is created based on the decompressed target dimension. The balance value of the new balance record for the target dimension is increased or decreased by a second value to obtain the rollback balance value corresponding to the target dimension. Rollback information for the balance record corresponding to the target dimension is generated to obtain the target balance table of the target tenant after rollback. The target balance table of the target tenant after rollback is saved to the database. The balance value of the new balance record for the target dimension is zero.
[0096] A new transaction record corresponding to the target balance identifier is added to the target transaction table of the target tenant. The transaction value of the new transaction record of the target dimension is increased or decreased by a second value to obtain the rollback transaction value corresponding to the target dimension. Rollback information of the transaction record corresponding to the target dimension is generated to obtain the target transaction table of the target tenant after rollback. The target transaction table of the target tenant after rollback is saved to the database. The transaction value of the new transaction record of the target dimension is zero.
[0097] In one alternative implementation, the acquisition unit may be used for:
[0098] The first query request to obtain the balance records of the target tenant for the target dimension;
[0099] If the target tenant's target balance table does not contain a balance record for the target dimension, a new balance record for the target dimension of the target tenant is created, and the new balance record for the target dimension of the target tenant is used as the query result of the first query request. The balance value of the new balance record is zero.
[0100] If the target tenant's target balance table contains a balance record for the target dimension, then the balance record for the target dimension of the target tenant in the target balance table will be used as the query result of the target tenant's query request.
[0101] In one alternative implementation, the storage unit may be used for:
[0102] A second query request is made to obtain the transaction history of the target tenant for the target balance identifier;
[0103] The query result of the second query request is to use at least one transaction record corresponding to the target balance identifier in the target transaction table of the target tenant.
[0104] For further details, please refer to Figure 4 One embodiment of the data storage device in this application includes:
[0105] Central processing unit 401, memory 405, input / output interface 404, wired or wireless network interface 403, and power supply 402;
[0106] Memory 405 is either a short-term storage memory or a persistent storage memory;
[0107] The central processing unit 401 is configured to communicate with the memory 405 and execute instructions stored in the memory 405 to perform the aforementioned operations. Figure 2 The method in the illustrated embodiment.
[0108] Furthermore, embodiments of this application also provide a computer-readable storage medium, which includes instructions that, when executed on a computer, cause the computer to perform the aforementioned... Figure 2 The method in the illustrated embodiment.
[0109] Furthermore, embodiments of this application also provide a computer program product containing instructions, which, when run on a computer, causes the computer to perform the aforementioned... Figure 2 The method in the illustrated embodiment.
[0110] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0111] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0112] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0113] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0114] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0115] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A data storage method, characterized in that, include: Delete the target balance records with zero balance values in the initial balance tables of each tenant in the database to obtain the target balance tables for each tenant. Each balance record in the target balance table includes the dimension corresponding to each balance identifier and the balance value. Multiple target transaction records of the same dimension in the initial transaction records of each tenant in the database are merged to obtain merged transaction records of the same dimension. The multiple target transaction records of the same dimension in the initial transaction records are replaced with merged transaction records of the same dimension to obtain target transaction records for each tenant. Each transaction record in the target transaction record includes a balance identifier corresponding to each transaction identifier and a transaction value. Save the target balance table and the target transaction table of each tenant to the database.
2. The method according to claim 1, characterized in that, The process of deleting target balance records with zero balance values from the initial balance tables of each tenant in the database to obtain the target balance tables for each tenant includes: The target balance records are obtained by taking the balance records of each tenant in the initial balance table of the database that have a balance value of zero before the first preset time point, and deleting the target balance records to obtain the target balance table of each tenant. The process of merging multiple target transaction records of the same dimension in the initial transaction records of each tenant in the database to obtain the merged transaction records of the same dimension includes: The database takes multiple transaction records of the same dimension in each tenant's initial transaction record table before the second preset time point as multiple target transaction records of the same dimension, and merges the multiple target transaction records of the same dimension to obtain the merged transaction record of the same dimension.
3. The method according to claim 1, characterized in that, After saving the target balance table and the target transaction log table of each tenant to the database, the method further includes: Obtain an update request from a target tenant, the update request being used to increase or decrease a first value in the balance value and / or transaction value of the target dimension of the target tenant, the update request including the target dimension; Based on the determination result of whether the target dimension balance record exists in the target tenant's target balance table and the update request, the balance record update information corresponding to the target dimension is determined, so as to obtain the updated target tenant's target balance table based on the balance record update information corresponding to the target dimension, and the updated target tenant's target balance table is saved to the database. and / or A new transaction record for the target dimension is added to the target transaction table of the target tenant, and the transaction value of the new transaction record for the target dimension is increased or decreased by a first value to obtain the updated transaction value corresponding to the target dimension. Transaction record update information corresponding to the target dimension is generated to obtain the updated target transaction table of the target tenant. The updated target transaction table of the target tenant is then saved to the database, and the transaction value of the new transaction record for the target dimension is zero.
4. The method according to claim 3, characterized in that, The determination of whether a balance record for the target dimension exists in the target tenant's target balance table and the update request, to determine the balance record update information corresponding to the target dimension, includes: If the target tenant's target balance table does not contain a balance record for the target dimension, a new balance record for the target dimension is created, and the balance value of the new balance record for the target dimension is increased or decreased by a first value to obtain the updated balance value corresponding to the target dimension, so as to generate the balance record update information corresponding to the target dimension. The balance value of the new balance record for the target dimension is zero. If the target tenant's target balance table contains a balance record for the target dimension, then the balance record value for the target dimension in the target balance table is increased or decreased by a first value to obtain the updated balance value corresponding to the target dimension, thereby generating the balance record update information corresponding to the target dimension.
5. The method according to claim 1, characterized in that, After deleting target balance records with zero balance values from the initial balance tables of each tenant in the database to obtain the target balance tables for each tenant, the method further includes: The dimensions in the target balance records of each tenant are compressed according to a preset compression algorithm to obtain the compressed dimensions of each tenant, and the compressed dimensions are saved to the compression table of each tenant according to the balance identifier in the target balance records of each tenant. After saving the target balance table and the target transaction log table of each tenant to the database, the method further includes: Obtain the rollback request of the target tenant. The rollback request is used to increase or decrease the amount value and / or transaction value of the target dimension corresponding to the target balance identifier of the target tenant by a second value. The rollback request includes the target balance identifier. Based on the target balance identifier, the target compressed dimension is obtained from the compressed table of the target tenant and decompressed. A new balance record for the target dimension is created based on the decompressed target dimension. The balance value of the new balance record for the target dimension is increased or decreased by a second value to obtain the rollback balance value corresponding to the target dimension. Rollback information for the balance record corresponding to the target dimension is generated to obtain the target balance table of the target tenant after rollback. The target balance table of the target tenant after rollback is saved to the database. The balance value of the new balance record for the target dimension is zero. A new transaction record corresponding to the target balance identifier is added to the target transaction table of the target tenant. The transaction value of the new transaction record of the target dimension is increased or decreased by a second value to obtain the rollback transaction value corresponding to the target dimension. Rollback information of the transaction record corresponding to the target dimension is generated to obtain the target transaction table of the target tenant after rollback. The target transaction table of the target tenant after rollback is saved to the database. The transaction value of the new transaction record of the target dimension is zero.
6. The method according to claim 1, characterized in that, The method further includes: Obtain the first query request for the target tenant's balance records for the target dimension; If the target tenant's target balance table does not contain a balance record for the target dimension, a new balance record for the target dimension of the target tenant is created, and the new balance record for the target dimension of the target tenant is used as the query result of the first query request. The balance value of the new balance record is zero. If the target tenant's target balance table contains a balance record for the target dimension, then the balance record for the target dimension of the target tenant in the target balance table will be used as the query result of the target tenant's query request.
7. The method according to claim 1, characterized in that, The method further includes: A second query request is made to obtain the transaction history of the target tenant for the target balance identifier; The query result of the second query request is to use at least one transaction record corresponding to the target balance identifier in the target transaction table of the target tenant.
8. A data storage device, characterized in that, include: Central processing unit and memory; The memory is either a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1 to 7.
10. A computer program product containing instructions, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1 to 7.