Methods, devices, and electronic devices for updating and querying business tables
By employing an access control table to manage dual roles of business data tables for querying and updating, the method addresses inefficient querying during updates, ensuring data accuracy and efficiency in database systems.
Patent Information
- Application Number
- CN202111616400.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-12-27
AI Technical Summary
During the data table update process, data query efficiency in the prior art is low, the accuracy of data query results cannot be guaranteed, and the time to wait for the data table update to be completed is long.
By establishing two business data tables with the same structure, it takes turns to serve as a business query table for querying data and a business update table for update data, and using the access control table to record the table type relationship, realizing read and write separation, allowing data queries to be performed during the data table update process.
It realizes that data query can still be accurately performed during the data table update process, improves the efficiency and accuracy of data query, and avoids long-term waiting.
Smart Images

Figure CN114297210B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology. Specifically, the present application relates to a method, apparatus, and electronic device for updating and querying a service table. Background Art
[0002] In the era of informatization, the market can be understood through big data. When facing the statistical analysis requirements of some specified services, it is often necessary to import the statistical analysis data in full volume into the database table at regular intervals for users to query and process.
[0003] Currently, for the data tables that need to be updated in full volume in the database, if you want to access the data table for data query during the update process, you need to wait for the data table update to complete. Otherwise, you may query incorrect data and cannot ensure the accuracy of the data query results.
[0004] If you wait for the data table update to complete before querying the data, at this time, the waiting time for querying the data will be relatively long, resulting in low efficiency of data query during the data table update process, which is difficult to meet the actual needs. Summary of the Invention
[0005] The purpose of the embodiments of the present application is to solve the problem of low efficiency of data query during the data table update process.
[0006] In a first aspect, a method for updating and querying a service table is provided. The method includes:
[0007] When a service table update request is received, the access control table is detected; the service table update request includes a target service table identifier and full volume update data, and the target service table identifier corresponds to two service data tables with the same table structure;
[0008] If the detection result is that the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, then based on the access control table, determine the table types corresponding to the two service data tables respectively, and the table types are update type or query type;
[0009] Based on the full volume update data, perform a full volume update on the service data table with the update type, and exchange the table types corresponding to the two service data tables recorded in the access control table;
[0010] When a data query request is received, if the service table identifier to be queried in the data query request is the target service table identifier, then determine the service data table with the current table type as the query type by querying the access control table, and perform data query in the determined service data table.
[0011] In an alternative embodiment of the first aspect, the method further includes;
[0012] Determine the update frequency of at least one original business table in the database;
[0013] For each original business table, if the update frequency of the original business table is greater than a preset frequency threshold, generate two business data tables with the same table structure corresponding to the original business table based on the original business table, and use the business table identifier of the original business table as the business table identifier corresponding to the two business data tables with the same table structure.
[0014] In an alternative embodiment of the first aspect, each business data table has a corresponding business table sub-identifier;
[0015] If the access control table stores the correspondence between two business data tables corresponding to the target business table identifier and two preset table types, determining the table types corresponding to the two business data tables respectively based on the access control table includes:
[0016] If the access control table stores the correspondence between the business table sub-identifiers of two business data tables corresponding to the target business table identifier and two preset table types, then for each business data table, use the table type corresponding to the business table sub-identifier of the business data table in the access control table as the table type corresponding to the business data table.
[0017] In an alternative embodiment of the first aspect, the method further includes:
[0018] Obtain a business table creation request, where the business table creation request includes a business table identifier to be created and initial configuration information of the business table;
[0019] Create two business data tables corresponding to the business table identifier to be created based on the initial configuration information of the business table.
[0020] In an alternative embodiment of the first aspect, after detecting the access control table, it further includes:
[0021] If the access control table does not have the correspondence between two business data tables corresponding to the target business table identifier and the table type, select any one of the two business data tables to enter full-volume update data, and store the correspondence between the two business data tables corresponding to the target business table identifier and the table type in the access control table.
[0022] In an alternative embodiment of the first aspect, storing the correspondence between two business data tables corresponding to the target business table identifier and the table type in the access control table includes:
[0023] In the access control table, set the table type corresponding to the business data table that has entered full-volume update data as the query type, and set the table type corresponding to the other business data table as the update type.
[0024] In a second aspect, an apparatus for updating and querying a service table is provided. The apparatus includes:
[0025] An update request receiving module, configured to detect an access control table when receiving a service table update request. The service table update request includes a target service table identifier and full update data. The target service table identifier corresponds to two service data tables with the same table structure.
[0026] A table type determining module, configured to, if the detection result is that the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, determine the table types respectively corresponding to the two service data tables based on the access control table. The table types are update type or query type.
[0027] A service table update module, configured to perform a full update on the service data table of the update type based on the full update data, and exchange the table types respectively corresponding to the two service data tables recorded in the access control table.
[0028] A data query module, configured to, when receiving a data query request, if the service table identifier to be queried in the data query request is the target service table identifier, determine the service data table of the query type as the current table type by querying the access control table, and perform data query in the determined service data table.
[0029] In an optional embodiment of the second aspect, a service data table generation module is further included, specifically configured to:
[0030] Determine the update frequency of at least one original service table in the database;
[0031] For each original service table, if the update frequency of the original service table is greater than a preset frequency threshold, generate two service data tables with the same table structure corresponding to the original service table based on the original service table, and use the service table identifier of the original service table as the service table identifier corresponding to the two service data tables with the same table structure.
[0032] In an optional embodiment of the second aspect, each service data table has a corresponding service table sub-identifier;
[0033] If the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, when the table type determining module determines the table types respectively corresponding to the two service data tables based on the access control table, it is specifically configured to:
[0034] If the access control table stores the correspondence between the sub-table identifiers of the two business data tables corresponding to the target business table identifier and two preset table types, then for each business data table, the table type corresponding to the sub-table identifier of the business data table in the access control table is used as the table type corresponding to the business data table.
[0035] In an optional embodiment of the second aspect, it further includes a business table creation module, specifically used for:
[0036] Obtain a business table creation request, where the business table creation request includes the identifier of the business table to be created and the initial configuration information of the business table;
[0037] Create two business data tables corresponding to the identifier of the business table to be created based on the initial configuration information of the business table.
[0038] In an optional embodiment of the second aspect, it further includes a business table initialization module, specifically used for:
[0039] If the access control table does not store the correspondence between the two business data tables corresponding to the target business table identifier and the table type, then select any one of the two business data tables to enter the full amount of updated data, and store the correspondence between the two business data tables corresponding to the target business table identifier and the table type in the access control table.
[0040] In an optional embodiment of the second aspect, when the business table initialization module stores the correspondence between the two business data tables corresponding to the target business table identifier and the table type in the access control table, it is specifically used for:
[0041] In the access control table, set the table type corresponding to the business data table that has entered the full amount of updated data as the query type, and set the table type corresponding to the other business data table as the update type.
[0042] In a third aspect, an electronic device is provided, and the electronic device includes:
[0043] A memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the program, it implements the method for updating and querying the business table in any of the above embodiments.
[0044] In a fourth aspect, a computer-readable storage medium is provided, and a computer program is stored on the computer-readable storage medium, and when the program is executed by the processor, it implements the method for updating and querying the business table in any of the above embodiments.
[0045] Fifth aspect, a computer program product or a computer program is provided. The computer program product or the computer program includes computer instructions which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that when the computer device executes, the method provided in the embodiments of the first aspect is implemented.
[0046] For the above method of updating and querying a service table, when a service table update request is received, the access control table is detected. If the detection result shows that the access control table stores the correspondence between two service data tables corresponding to the target service table identifier and two preset table types, the table types respectively corresponding to the two service data tables can be determined from the access control table. The service data table with the table type of the update type can be fully updated, and the table types corresponding to the two service data tables recorded in the access control table are exchanged. If a data query request is received during the update process, the access control table is queried, and data is queried in the service data table with the determined table type of the query type. By establishing two service data tables with the same structure and alternately using them as the service query table for querying data and the service update table for updating data, the technical solution of the embodiments of the present application can achieve read-write separation, and the technical effect of accurately querying data during the update of the service data table can be achieved. Description of the Drawings
[0047] To more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for the description in the embodiments of the present application will be briefly introduced below.
[0048] Figure 1 It is a schematic flowchart of a method for updating and querying a service table provided by an embodiment of the present application;
[0049] Figure 2a It is a schematic diagram of an access control table in a method for updating and querying a service table provided by an embodiment of the present application;
[0050] Figure 2b It is a schematic diagram of an access control table in a method for updating and querying a service table provided by an embodiment of the present application;
[0051] Figure 3 It is a schematic flowchart of a method for updating and querying a service table provided by an embodiment of the present application;
[0052] Figure 4 It is a schematic flowchart of a method for updating and querying a service table provided by an embodiment of the present application;
[0053] Figure 5A timing schematic diagram of a method for updating and querying a service table provided by an embodiment of the present application;
[0054] Figure 6 A structural schematic diagram of a device for updating and querying a service table provided by an embodiment of the present application;
[0055] Figure 7 A structural schematic diagram of an electronic device for updating and querying a service table provided by an embodiment of the present application. Detailed implementation manners
[0056] The embodiments of the present application will be described below with reference to the accompanying drawings in the present application. It should be understood that the embodiments described below in conjunction with the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and do not constitute limitations on the technical solutions of the embodiments of the present application.
[0057] Those skilled in the art of the present technology can understand that unless specifically stated otherwise, the singular forms "a", "an", "the", and "said" used herein may also include the plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements, and / or components, but do not exclude being implemented as other features, information, data, steps, operations, elements, components, and / or combinations thereof supported by the art of the present technology. It should be understood that when we say an element is "connected" or "coupled" to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used here can include a wireless connection or wireless coupling. The term "and / or" used here indicates at least one of the items defined by the term, for example, "A and / or B" can be implemented as "A", or implemented as "B", or implemented as "A and B".
[0058] To make the purpose, technical solutions, and advantages of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0059] The embodiments of the present application provide a method for updating and querying a service table, and this method can be implemented by a device / system configured with a database. The device / system involved in the embodiments of the present application can create two service data tables with the same structure, and alternately use them as a service query table for querying data and a service update table for updating data, so that the technical solutions of the embodiments of the present application can achieve read-write separation and can accurately perform data query during the update process of the service data table.
[0060] The technical solutions of the embodiments of the present application and the technical effects brought about by the technical solutions of the present application will be described below through the description of several exemplary embodiments. It should be noted that the following embodiments can be referred to, learned from, or combined with each other. For the same terms, similar features, and similar implementation steps in different embodiments, they will not be described repeatedly.
[0061] The method for updating and querying a service table provided in the embodiments of the present application can be applied to a terminal or a server.
[0062] Those skilled in the art of the present technology can understand that the "terminal" used here can be a personal computer, mobile phone, tablet computer, PDA (Personal Digital Assistant), MID (Mobile Internet Device), etc.
[0063] The embodiments of the present application provide a method for updating a service table. As Figure 1 shown, the method includes:
[0064] Step S101, when a service table update request is received, the access control table can be detected; wherein, the service table update request may include a target service table identifier and full - volume update data, and the target service table identifier corresponds to two service data tables with the same table structure.
[0065] The method for updating and querying a service table provided by the present application can be applicable to all databases or data processing systems that need to perform full - volume updates on tables. Taking a database as an example, there can be many service tables stored in the database to meet data query and processing requirements.
[0066] When a service table update request is received, the service table update request may contain a target service table identifier and full - volume update data. Based on the target service table identifier, the service table to be updated can be determined from various service tables in the database.
[0067] Specifically, in the method for updating and querying a service table provided by the present application, a target service table identifier can correspond to two service data tables with the same table structure. In addition to corresponding to the target service table identifier at the same time, each service data table also has its own service table sub - identifier.
[0068] The target service table identifier can be the target service table name. For example, if it is "Statistics Table of A User's Consumption Amount", the service table sub - identifiers of the two service data tables corresponding to the target service table identifier can be "Statistics Table of A User's Consumption Amount 1" and "Statistics Table of A User's Consumption Amount 2".
[0069] Step S102. If the detection result shows that the access control table stores the correspondence between the two business data tables corresponding to the target business table identifier and the two preset table types, then the table types corresponding to the two business data tables can be determined based on the access control table, where the table type can be an update type or a query type;
[0070] Among them, the two preset table types include the update type and the query type. When the table type corresponding to a business data table is the update type, this business data table can be used as a business update table. Similarly, when the table type of a business data table is the query type, this business data table can be used as a business query table.
[0071] In the embodiment of the present application, each business data table can have a corresponding business table sub-identifier. If the access control table stores the correspondence between the business table sub-identifiers of the two business data tables corresponding to the target business table identifier and the two preset table types, then for each business data table, the table type corresponding to the business data table in the access control table corresponding to the business table sub-identifier is used as the table type corresponding to the business data table.
[0072] Specifically, the ways for the access control table to store the correspondence between the business table sub-identifiers of the two business data tables and the two preset table types may include but are not limited to: there are fields corresponding to the two table types in the access control table. For example, the two fields can be set to "business update table" (corresponding to the update type) and "business query table" (corresponding to the query type), and the values of these two fields can be set to the business table sub-identifier, so as to establish the correspondence between the two table types and the business table sub-identifiers of the two business data tables, and then further determine the table types of the two business data tables.
[0073] For example, when the business table sub-identifiers of the two business data tables corresponding to the target business table identifier are "Statistics Table 1 of A User's Consumption Amount" and "Statistics Table 2 of A User's Consumption Amount", the value of the "business update table" field corresponding to the target business table identifier in the access control table can be "Statistics Table 1 of A User's Consumption Amount", and the value of the "business query table" field can be "Statistics Table 2 of A User's Consumption Amount". Then, based on the target business table identifier and the business table sub-identifier, it can be determined from the access control table that the table type of the business data table with the business sub-identifier of "Statistics Table 1 of A User's Consumption Amount" is the update type, and the table type of the business data table with the business sub-identifier of "Statistics Table 2 of A User's Consumption Amount" is the query type.
[0074] It should be noted that the specific forms and contents of the above business table identifier and business table sub-identifier are only for illustrative purposes. According to the different grammars of different databases, the identifier can be in different forms, including but not limited to English letters, Chinese characters, symbols, and digital serial numbers, etc.
[0075] In the embodiments of the present application, each service table identifier may correspond to its own access control table.
[0076] In the method for updating and querying a service table provided by the present application, when detecting the access control table, if the access control table stores the correspondence between the service table sub-identifiers of two service data tables corresponding to the target service table identifier and two preset table types, then based on the target service table identifier and the service table sub-identifiers, determining the table types corresponding to the two service data tables from the access control table may specifically include the following steps:
[0077] (1) Determining a target access control table based on the target service table identifier; the target access control table may contain a field with a value of the target service table identifier, and the corresponding target access control table can be matched through the target service table identifier;
[0078] (2) Detecting the target access control table, if the target access control table stores the correspondence between the service table sub-identifiers of two service data tables corresponding to the target service table identifier and two preset table types, then based on the target service table identifier and the service table sub-identifiers, determining the table types corresponding to the two service data tables from the target access control table.
[0079] In some embodiments, the access control table may also be a master table, and the access control table contains some attribute information corresponding to some service table identifiers respectively. The corresponding attribute information can be found in the access control table according to the service table identifier.
[0080] As an alternative solution, the access control table may contain fields of "service update table" and "service query table" corresponding to each recorded service table identifier.
[0081] For any service table identifier whose correspondence between its service sub-identifier and table type is recorded in the access control table, the table types corresponding to the two service data tables corresponding to this service table identifier can be determined by querying the values of these two fields. Specifically, the table type corresponding to the service data table corresponding to the service table sub-identifier that is the value of the "service update table" field is the update type; the table type corresponding to the service data table corresponding to the service table sub-identifier that is the value of the "service query table" field is the query type.
[0082] Step S103: Perform a full update on the service data table with an update type based on the full update data, and exchange the table types corresponding to the two service data tables recorded in the access control table.
[0083] Specifically, the current data in the service data table with an update type can be cleared first, and the full update data can be imported into this service data table to achieve a full update.
[0084] In an embodiment of the present application, if each service table identifier corresponds to its own access control table, after the full - volume update of the service data table with the table type of service update table based on the full - volume update data, the table types corresponding to the service table sub - identifiers of the two service data tables in the target access control table corresponding to the target service table identifier can be exchanged respectively.
[0085] Specifically, when the values of the fields of "service update table" and "service query table" corresponding to the two table types in the target access control table are the service table sub - identifiers of the two service data tables respectively, after the full - volume update is completed, the values of the fields of "service update table" and "service query table" in the target access control table can be interchanged. For example, before the full - volume update, the value of the "service update table" field is "service table sub - identifier 1", and the value of the "service query table" field is "service table sub - identifier 2". After the full - volume update, the values of the "service update table" and "service query table" fields are exchanged, so that the value of the "service update table" field is "service table sub - identifier 2", and the value of the "service query table" field is "service table sub - identifier 2", so that the table types corresponding to the service table sub - identifiers of the two service data tables after the exchange are exchanged.
[0086] In one example, the table types corresponding to the two service data tables corresponding to the target service table identifier are not fixed during multiple update processes, but change dynamically according to the number of updates.
[0087] Suppose the service table sub - identifiers of the two service data tables corresponding to the target service table identifier are "A user consumption amount statistics table 1" and "A user consumption amount statistics table 2" respectively. The current corresponding relationship stored in the target access control table corresponding to the target service table identifier is: the table type corresponding to "A user consumption amount statistics table 1" is the update type, and the table type corresponding to "A user consumption amount statistics table 2" is the query type.
[0088] Then, during the update process after the first receipt of the service table update request, based on the target access control table, it can be determined that the table type of the service data table with the service table sub - identifier of "A user consumption amount statistics table 1" is the update type, and the table type of the service data table with the service table sub - identifier of "A user consumption amount statistics table 2" is the query type. The service data table of the update type (i.e., the service data table corresponding to "A user consumption amount statistics table 1") can be fully updated with the full - volume update data. After the full - volume update is completed, the table types corresponding to the service table sub - identifiers of the two service data tables in the target access control table corresponding to the target service table identifier are exchanged, so that the table type corresponding to "A user consumption amount statistics table 1" is the query type, and the table type corresponding to "A user consumption amount statistics table 2" is the update type.
[0089] During the update process after receiving the service table update request for the second time, based on the target access control table, it can be determined that the table type of the service data table with the service table sub-identifier of "A User Consumption Amount Statistics Table 1" is the query type, and the table type of the service data table with the service table sub-identifier of "A User Consumption Amount Statistics Table 2" is the update type. The service data table with the update type (i.e., the service data table corresponding to "A User Consumption Amount Statistics Table 2") can be fully updated with the full amount of updated data. Similarly, after the full update is completed, the table types corresponding to the service table sub-identifiers of the two service data tables in the target access control table corresponding to the target service table identifier are exchanged, so that the table type corresponding to "A User Consumption Amount Statistics Table 1" is the update type, and the table type corresponding to "A User Consumption Amount Statistics Table 2" is the query type.
[0090] During subsequent multiple updates, the above method can be used for processing, and no redundant discussion will be made.
[0091] Step S104, when a data query request is received, if the service table identifier to be queried in the data query request is the target service table identifier, then determine the service data table with the current table type of the query type by querying the access control table, and perform data query in the determined service data table. It can be understood that step S104 can occur after step S103, or at any time node between step S101 and step S103. When a data query request is received, it is only necessary to determine the service data table with the current table type of the query type based on the access control table and perform data query.
[0092] For the above method of updating and querying the service table, when a service table update request is received, the access control table is detected. If the detection result shows that the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and the preset two table types, then determine the table types corresponding to the two service data tables respectively from the access control table. The service data table with the update type can be fully updated, and the table types corresponding to the two service data tables recorded in the access control table are exchanged. If a data query request is received during the update process, then query the access control table and perform data query in the service data table with the determined table type of the query type. By establishing two service data tables with the same structure and alternately using them as the service query table for querying data and the service update table for updating data, the technical solution of the embodiment of the present application can achieve read-write separation and accurately perform data query during the update process of the service data table.
[0093] In an example, the schematic structural diagram of the target access control table corresponding to the target service table identifier can be as Figure 2aAs shown below: Among them, the target access control table may include five fields: "Number", "Business Table Identifier", "Chinese Name", "Business Update Table", and "Business Query Table". The values of the five fields are as Figure 2a shown in the second row of
[0094] When the target business table identifier is "CONSUMPTION_STATISTICS", the value of the "Business Table Identifier" field in the target access control table corresponding to the target business table identifier is also "CONSUMPTION_STATISTICS". The target business table identifier here is composed of letters to conform to the syntax of the specified database and is only for illustrative purposes. The value of the "Chinese Name" field in the target access control table explains the Chinese meaning of the target business table identifier composed of letters, indicating that the business data table corresponding to the target business table identifier is used to record the user consumption amount.
[0095] When the business table sub-identifiers of the two business data tables corresponding to the target business table identifier are respectively: "CONSUMPTION_STATISTICS_A" and "CONSUMPTION_STATISTICS_B", the business data table with the business table sub-identifier ending with "_A" can be called Table A, and the business data table with the business table sub-identifier ending with "_B" can be called Table B.
[0096] It can be determined based on the target access control table that the table type corresponding to the current Table A is the update type table, and the table type corresponding to Table B is the query type.
[0097] When a business table update request is received and after the full update of Table A with the full update data for the table type of the business update table, the table types corresponding to the business table sub-identifiers of the two business data tables in the target access control table can be exchanged to achieve the exchange of the table types corresponding to the two business data tables.
[0098] The exchanged target access control table can be as Figure 2b shown, and the values of the "Business Update Table" and "Business Query Table" fields are exchanged.
[0099] In an embodiment of the present application, a possible implementation manner is provided. The method for updating and querying a business table further includes the following steps:
[0100] (1) Obtain a business table creation request, where the business table creation request includes a to-be-created business table identifier and business table initial configuration information; among them, the business table initial configuration information includes but is not limited to several attributes corresponding to the to-be-created business table identifier, and each attribute may be composed of a column name, a data type, and multiple integrity constraint conditions for this column;
[0101] (2) Create two business data tables corresponding to the business table identifier to be created and an access control table corresponding to the business table identifier to be created based on the initial configuration information of the business table; among them, the structures of the two business data tables corresponding to the business table identifier to be created are the same.
[0102] In the embodiments of the present application, two business data tables are not created for each business table identifier to be created. Two business data tables can be created for the business table identifier corresponding to the business data that may have full volume update requirements.
[0103] Specifically, the user can first set some keywords, such as "statistics", "total amount", "daily", "monthly", and "yearly", etc. When the business table identifier to be created contains at least one of the pre-set keywords, create two business data tables corresponding to the business table identifier to be created.
[0104] In the embodiments of the present application, a possible implementation method is provided. If there is an original business table in the database for which two tables with the same result have not been created, the method for updating and querying the business table provided by the present application may further include the following steps:
[0105] Determine the update frequency of at least one original business table in the database;
[0106] For each original business table, if the update frequency of the original business table is greater than the preset frequency threshold, generate two business data tables with the same table structure corresponding to the original business table based on the original business table, and use the business table identifier of the original business table as the business table identifier corresponding to the two business data tables with the same table structure.
[0107] In the embodiments of the present application, a possible implementation method is provided. After detecting the access control table, it further includes:
[0108] If there is no corresponding relationship between the two business data tables corresponding to the target business table identifier and the table type in the access control table, any one of the two business data tables can be selected to enter the full volume update data, and the corresponding relationship between the two business data tables corresponding to the target business table identifier and the table type is stored in the access control table.
[0109] It can be understood that the business table update process not only includes updating the business data table that already contains data, but also includes, when creating a new set of business data tables, selecting any one of the new business data tables to enter the full volume update data, and the full volume update data here can be the initial business data.
[0110] In an embodiment of the present application, after selecting any business data table to enter the initial business data, at this time, for this group of business data tables, one business data table has entered the business initial data, and the other business data table has not stored data yet. Then, the following steps can be executed: In the access control table, set the table type corresponding to the business data table that has entered the full - volume update data to the query type, and set the table type corresponding to the other business data table to the update type.
[0111] Specifically, after entering the initial business data into any business data table, the access control table corresponding to this group of business data tables can be further initialized, so that the table type corresponding to the business table sub - identifier of the business data table that has entered the full - volume update data in the access control table is the query type, and the table type corresponding to the business table sub - identifier of the other business data table is the update type.
[0112] When receiving the business table update request for this group of business data tables next time, the business data table that has not entered data will be fully updated. Before the second update is completed, if a data query request is received, data query will be performed in the business data table that has entered the business initial data.
[0113] In one embodiment, the process of updating the business table can be as Figure 3 shown, including two situations: the process of entering data into the business data table for the first time after creating a group of business data tables, and the step - by - step process of updating the group of business data tables with the entered data. A group of business data tables refers to two business data tables corresponding to a business table identifier. A group of business data tables with entered data can refer to any business data table in the group of business data tables that stores data.
[0114] The specific steps are as follows:
[0115] Step S301, receive the business table update request. The business update request can include the target business table identifier and business data. The target business table identifier can correspond to two business data tables with the same table structure. For example, Table A and Table B; each business data table has a corresponding business table sub - identifier. The business table sub - identifier of Table A can be "Business Data Table A", and the business table sub - identifier of Table B can be "Business Data Table B";
[0116] Step S302, detect whether there is a correspondence between the business table sub - identifiers and table types of Table A and Table B in the access control table. If so, enter Step S303; otherwise, enter Step S305;
[0117] Step S303, determine the table types corresponding to Table A and Table B respectively from the access control table based on the target business table identifier and the business table sub - identifiers of Table A and Table B;
[0118] Step S304: Perform a full update on the business data table with the table type of business update table based on the business data, and exchange the table types corresponding to the business table sub-identifiers of Table A and Table B in the access control table, and end the process. For example, before the update, if the table type corresponding to Table A is the business update table (i.e., the update type), and the table type corresponding to Table B is the business query table (i.e., the query type), then perform a full update on Table A, and exchange the table types corresponding to the business table sub-identifiers of Table A and Table B in the access control table. After the exchange, the business table sub-identifier of Table A corresponds to the business query table, and the business table sub-identifier of Table B corresponds to the business update table, so that the table types corresponding to the two business table sub-identifiers are swapped, thereby realizing the swapping of the table types of the two business data tables.
[0119] Step S305: It is stated that no data has been entered after the creation of Table A and Table B. Then, any business data table can be selected from Table A and Table B to enter business data, and the access control table is initialized so that the table type corresponding to the business table sub-identifier of the business data table where the business data is entered in the initialized access control table is the business query table, and the table type corresponding to the business table sub-identifier of the other business data table is the business update table. For example, if business data is entered in Table A, then the table type corresponding to the business table sub-identifier of Table A in the access control table is the business query table (i.e., the query type), and the table type corresponding to the business table sub-identifier of Table B in the access control table is the business update table (i.e., the update type), and the process ends.
[0120] In an embodiment of the present application, a possible implementation manner is provided, as Figure 4 shown. The method for updating and querying a business table provided by the present application may further include the following steps:
[0121] Step S401: Receive a data query request, where the data query request includes the business table identifier to be queried. Among them, the business table identifier to be queried may be the target business table identifier during the update process, or other business table identifiers in the database.
[0122] Step S402: Determine the access control table corresponding to the business table identifier to be queried. Specifically, the access control table corresponding to the business table identifier to be queried can be determined based on the business table identifier to be queried.
[0123] Step S403: Determine the business table sub-identifier whose table type is a business query table from the access control table corresponding to the business table identifier to be queried, and query data in the business data table corresponding to the determined business table sub-identifier. Specifically, the business table identifier to be queried may correspond to two business data tables with the same table structure. The access control table corresponding to the business table identifier to be queried stores the correspondence between the business table sub-identifiers of the two business data tables corresponding to the business table identifier to be queried and the two table types. The business table sub-identifier whose table type is the query type can be determined from the access control table, and then the business data table can be further determined based on the determined business table sub-identifier, and data can be queried in the determined business data table.
[0124] In an embodiment of the present application, a possible implementation manner is provided. The method for updating and querying a business table provided by the present application may further include the following steps:
[0125] (1) Obtain a data processing request, where the data processing request includes a request identifier and a business table identifier to be processed; among them, the business table identifier to be processed may be the target business table identifier in the update process or the business table identifier to be queried in the data query process;
[0126] (2) Determine the request type of the data processing request based on the request identifier. The request type may include a business table update request and a data query request; among them, the request identifier may be simply set to a number. For example, the request identifier corresponding to the request type of the business table update request may be set to 1, and the request identifier corresponding to the request type of the data query request may be set to 0;
[0127] (3) For different request types, the following two corresponding processes can be adopted:
[0128] A. When the request type of the data processing request is a business table update request, use the business table identifier to be processed as the target business table identifier and detect the access control table corresponding to the target business table identifier;
[0129] Subsequent steps can perform corresponding processing according to the received business table update request. For example, if the access control table stores the correspondence between the business table sub-identifiers of the two business data tables corresponding to the target business table identifier and the two preset table types, then determine the table types corresponding to the two business data tables respectively based on the target business table identifier and the business table sub-identifier. The table types include an update type and a query type; perform a full update on the business data table with the table type of the update type based on the full update data;
[0130] B. When the request type of the data processing request is a data query request, use the business table identifier to be processed as the business table identifier to be queried and determine the access control table corresponding to the business table identifier to be queried;
[0131] Subsequent steps can perform corresponding processing according to the received data query request. For example, determine the business table sub-identifier with the table type of the query type from the access control table corresponding to the business table identifier to be queried, and query data in the business data table corresponding to the determined business table sub-identifier.
[0132] To more clearly illustrate the method for updating and querying business tables in this application, the method for updating and querying business tables will be further described below in conjunction with specific optional embodiments.
[0133] The time schematic diagram of the method for updating and querying business tables provided in this optional embodiment can be as Figure 5 shown. In this embodiment, the method for updating and querying business tables can include two parts: updating and querying. Among them, the query operation can occur at any time node in this process. For data query requests initiated at different time nodes, various corresponding processing solutions are described in detail below. In addition, in this embodiment, the business query table is used to refer to the query type, and the business update table is used to refer to the update type.
[0134] The method for updating and querying business tables in this embodiment can specifically include the following steps:
[0135] First, two business tables (business data tables) with the same structure and an access control table can be created. Specifically, the two business tables with the same structure can be Table A and Table B.
[0136] Second, when initially importing data, one of Table A and Table B can be selected to import the initial business data. For example, select to import the initial business data into Table A and initialize the access control table. Specifically, the value of the "business query table" field representing the table type in the access control table can be set to the business table sub-identifier of Table A, and the value of the "business update table" field can be set to the business table sub-identifier of Table B. After the first import of data, the dynamic correspondence relationship between Table A and Table B and the table type can be as Figure 5 shown in the second ellipse on the right.
[0137] After importing data into Table A, before the next business table update, the table type corresponding to Table A is the business query table, and the table type corresponding to Table B is the business update table. If a data query request is received at this time, Table A is used to query data.
[0138] Fourth, when a business table update request is received, since the table type corresponding to Table B is the business update table at this time, a full update is performed on Table B. This is the second import of data. The full update means clearing the data in Table B and importing the business update data in the business update request.
[0139] During the process of full - volume update of Table B (before the update is completed), the table types of Table A and Table B have not been swapped yet. At this time, if a data query request is received, Table A is still used to query data.
[0140] After the full - volume update of Table B is completed, the corresponding table types of Table A and Table B can be swapped. Specifically, the values of the two fields, "business query table" and "business update table", which represent the table types in the access control table, can be swapped. After the swap, the corresponding table types of Table A and Table B are as shown in the third ellipse on the right. At this time, Table B corresponds to the business query table, and Table A corresponds to the business update table.
[0141] If a data query request is received after the full - volume update of Table B is completed, since the table type corresponding to Table B is the business query table at this time, Table B is used to query data.
[0142] Step 5: A business table update request is received. Since the table type corresponding to Table A is the business update table at this time, a full - volume update is performed on Table A. This is the third time to import data.
[0143] During the process of full - volume update of Table A (before the update is completed), the table types of Table A and Table B have not been swapped yet. At this time, if a data query request is received, Table B whose table type corresponds to the business query table is used to query data.
[0144] After the full - volume update of Table A is completed, the corresponding table types of Table A and Table B can be swapped. Specifically, the values of the two fields, "business query table" and "business update table", which represent the table types in the access control table, can be swapped. After the swap, the corresponding table types of Table A and Table B are as shown in the fourth ellipse on the right. At this time, Table A corresponds to the business query table, and Table B corresponds to the business update table.
[0145] If a data query request is received after the full - volume update of Table A is completed, since the table type corresponding to Table A is the business query table at this time, Table A is used to query data.
[0146] If there are multiple subsequent updates, all can be processed according to the above - mentioned process, and no further elaboration will be made.
[0147] An embodiment of the present application provides a device for updating and querying a business table, as Figure 6 shown. The device 60 for updating and querying the business table may include: an update request receiving module 601, a table type determination module 602, a business table update module 603, and a data query module 604, where,
[0148] An update request receiving module 601, configured to detect an access control table when a service table update request is received; the service table update request includes a target service table identifier and full - volume update data, and the target service table identifier corresponds to two service data tables with the same table structure.
[0149] A table type determination module 602, configured to, if the detection result is that the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, determine the table types corresponding to the two service data tables respectively based on the access control table, and the table types are update types or query types.
[0150] A service table update module 603, configured to perform a full - volume update on the service data table with the update type based on the full - volume update data, and exchange the table types corresponding to the two service data tables recorded in the access control table.
[0151] A data query module 604, configured to, when a data query request is received, if the service table identifier to be queried in the data query request is the target service table identifier, determine the service data table with the current query type by querying the access control table, and perform data query in the determined service data table.
[0152] The above - mentioned device for updating and querying a service table detects the access control table when receiving a service table update request. If the detection result is that the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, the table types corresponding to the two service data tables are determined from the access control table. The service data table with the update type can be fully updated, and the table types corresponding to the two service data tables recorded in the access control table are exchanged. If a data query request is received during the update process, the access control table is queried, and data query is performed in the service data table with the determined query type. The above method can achieve read - write separation by establishing two service data tables with the same structure, alternately serving as the service query table for querying data and the service update table for updating data, and can accurately perform data query during the update of the service data table.
[0153] In an embodiment of the present application, a service data table generation module is further included, specifically configured to:
[0154] Determine the update frequency of at least one original service table in the database;
[0155] For each original service table, if the update frequency of the original service table is greater than a preset frequency threshold, two service data tables with the same table structure corresponding to the original service table are generated based on the original service table, and the service table identifier of the original service table is used as the service table identifier corresponding to the two service data tables with the same table structure.
[0156] In an embodiment of the present application, each service data table has a corresponding service table sub-identifier;
[0157] If the access control table stores the correspondence between two service data tables corresponding to the target service table identifier and two preset table types, when the table type determination module 602 determines the table types respectively corresponding to the two service data tables based on the access control table, it specifically is used for:
[0158] If the access control table stores the correspondence between the service table sub-identifiers of two service data tables corresponding to the target service table identifier and two preset table types, then for each service data table, the table type corresponding to the service table sub-identifier of the service data table in the access control table is used as the table type corresponding to the service data table.
[0159] In an embodiment of the present application, it further includes a service table creation module, which specifically is used for:
[0160] Obtain a service table creation request, where the service table creation request includes a service table identifier to be created and service table initial configuration information;
[0161] Create two service data tables corresponding to the service table identifier to be created based on the service table initial configuration information.
[0162] In an embodiment of the present application, it further includes a service table initialization module, which specifically is used for:
[0163] If the access control table does not have the correspondence between two service data tables corresponding to the target service table identifier and the table type, select any one of the two service data tables to input full-update data, and store the correspondence between the two service data tables corresponding to the target service table identifier and the table type in the access control table.
[0164] In an embodiment of the present application, when the service table initialization module stores the correspondence between two service data tables corresponding to the target service table identifier and the table type in the access control table, it specifically is used for:
[0165] Set the table type corresponding to the service data table that has input full-update data in the access control table as the query type, and set the table type corresponding to the other service data table as the update type.
[0166] The device according to the embodiment of the present application can execute the method provided by the embodiment of the present application, and their implementation principles are similar. The actions performed by each module in the device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed function descriptions of each module of the device, reference can be specifically made to the descriptions in the corresponding methods shown above, and details are not repeated here.
[0167] An electronic device (computer device / equipment / system) is provided in an embodiment of the present application, including a memory, a processor, and a computer program stored on the memory. The processor executes the above computer program to implement the steps of the method for updating and querying a service table. Compared with the related art, it can achieve: by establishing two service data tables with the same structure, alternately serving as a service query table for querying data and a service update table for updating data, so that the technical solution of the embodiment of the present application can achieve read-write separation and accurately perform data query during the update process of the service data table.
[0168] In an optional embodiment, an electronic device is provided, as Figure 7 shown. Figure 7 As shown, the electronic device 4000 includes: a processor 4001 and a memory 4003. Among them, the processor 4001 and the memory 4003 are connected, such as connected through a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data, etc. It should be noted that in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation to the embodiment of the present application.
[0169] The processor 4001 may be a CPU (Central Processing Unit, central processor), a general-purpose processor, a DSP (Digital Signal Processor, data signal processor), an ASIC (Application Specific Integrated Circuit, application-specific integrated circuit), an FPGA (Field Programmable Gate Array, field programmable gate array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in combination with the disclosure of the present application. The processor 4001 may also be a combination that implements computing functions, such as a combination including one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0170] The bus 4002 may include a path for transmitting information between the above components. The bus 4002 can be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 7 it is only represented by a thick line in Figure 7 , but it does not mean that there is only one bus or one type of bus.
[0171] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or it can also be an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, which is not limited here.
[0172] The memory 4003 is used to store the computer program for implementing the embodiments of the present application and is controlled by the processor 4001 to execute. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.
[0173] Among them, the electronic device includes but is not limited to mobile terminals such as mobile phones, laptop computers, PADs, etc. and fixed terminals such as digital TVs, desktop computers, etc.
[0174] The embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiments can be implemented.
[0175] The embodiments of the present application also provide a computer program product, including a computer program. When the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiments can be implemented.
[0176] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the description, claims and the above-mentioned drawings of this application are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order other than the one illustrated or described in words.
[0177] It should be understood that although the flowcharts of the embodiments of this application indicate the respective operation steps by arrows, the implementation order of these steps is not limited to the order indicated by the arrows. Unless otherwise clearly stated in this article, in some implementation scenarios of the embodiments of this application, the implementation steps in each flowchart can be executed in other orders according to requirements. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage among these sub-steps or stages can also be executed at different times respectively. In the scenario where the execution times are different, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and the embodiments of this application do not limit this.
[0178] The above are only optional implementation manners of some implementation scenarios of this application. It should be noted that for those of ordinary skill in the art in this technical field, without departing from the technical concept of the solution of this application, adopting other similar implementation means based on the technical idea of this application also belongs to the protection scope of the embodiments of this application.
Claims
1. A method for updating and querying a business table, characterized in that, Including: When receiving a service table update request, detecting an access control table; The service table update request includes a target service table identifier and full - volume update data, and the target service table identifier corresponds to two service data tables with the same table structure; If the detection result is that the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, then based on the access control table, determining the table types respectively corresponding to the two service data tables, where the table types are update type or query type; Performing full - volume update on the service data table with the table type of update type based on the full - volume update data, and exchanging the table types respectively corresponding to the two service data tables recorded in the access control table; When receiving a data query request, if the service table identifier to be queried in the data query request is the target service table identifier, then determining the service data table with the current table type of query type by querying the access control table, and performing data query in the determined service data table.
2. The method for updating and querying a service table according to claim 1, wherein, The method further includes; Determining the update frequency of at least one original service table in the database; For each original service table, if the update frequency of the original service table is greater than a preset frequency threshold, then generating two service data tables with the same table structure corresponding to the original service table based on the original service table, and using the service table identifier of the original service table as the service table identifier corresponding to the two service data tables with the same table structure.
3. The method for updating and querying a service table according to claim 1, wherein Each service data table has a corresponding service table sub - identifier; The step of, if the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, and determining the table types respectively corresponding to the two service data tables based on the access control table, includes: If the access control table stores the correspondence between the service table sub - identifiers of the two service data tables corresponding to the target service table identifier and two preset table types, then for each service data table, using the table type corresponding to the service table sub - identifier of the service data table in the access control table as the table type corresponding to the service data table.
4. The method for updating and querying a service table according to claim 1, wherein The method further includes: Obtaining a service table creation request, where the service table creation request includes a service table identifier to be created and service table initial configuration information; Creating two service data tables corresponding to the service table identifier to be created based on the service table initial configuration information.
5. The method for updating and querying a service table according to any one of claims 1 - 4, after detecting the access control table, further including: If the access control table does not store the correspondence between the two service data tables corresponding to the target service table identifier and the table types, then selecting any one of the two service data tables to input the full - volume update data, and storing the correspondence between the two service data tables corresponding to the target service table identifier and the table types in the access control table.
6. The method for updating and querying a service table according to claim 5, wherein Storing the correspondence between the two service data tables corresponding to the target service table identifier and the table type in the access control table includes: In the access control table, setting the table type corresponding to the service data table into which the full update data is entered as the query type, and setting the table type corresponding to the other service data table as the update type.
7. An apparatus for updating and querying a service table, characterized in that, Including: An update request receiving module, configured to detect the access control table when a service table update request is received; The service table update request includes a target service table identifier and full update data, and the target service table identifier corresponds to two service data tables with the same table structure; A table type determination module, configured to, if the detection result is that the access control table stores the correspondence between the two service data tables corresponding to the target service table identifier and two preset table types, determine the table types respectively corresponding to the two service data tables based on the access control table, where the table type is an update type or a query type; A service table update module, configured to perform a full update on the service data table with the table type being the update type based on the full update data, and exchange the table types respectively corresponding to the two service data tables recorded in the access control table; A data query module, configured to, when a data query request is received, if the service table identifier to be queried in the data query request is the target service table identifier, determine the service data table with the current table type being the query type by querying the access control table, and perform data query in the determined service data table.
8. An electronic device, comprising a memory, a processor, and a computer program stored on the memory, characterized in that, The processor executes the computer program to implement the steps of the method for updating and querying a service table according to any one of claims 1-6.
9. A readable storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by the processor, the steps of the method for updating and querying a service table according to any one of claims 1-6 are implemented.
Citation Information
Patent Citations
Data storage method and device, electronic equipment and storage medium
CN111506559A
Business data table processing method and device, computer equipment and storage medium
CN111984740A