Disclosure of Invention
The embodiment of the application aims to solve the problem of low data query efficiency in the process of updating the data table.
In a first aspect, a method for updating and querying a service table is provided, the method comprising:
when a service table update request is received, detecting an access control table, wherein the service table update request comprises a target service table identifier and full-quantity 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 corresponding relation between the two business data tables corresponding to the target business table identifier and the preset two table types is stored in the access control table, determining the table types corresponding to the two business data tables respectively based on the access control table, wherein the table types are update types or query types;
based on the total update data, carrying out total update on a service data table with the table type being the update type, and exchanging the table types respectively corresponding to the two service data tables recorded in the access control table;
when a data query request is received, if the service table identifier to be queried in the data query request is a target service table identifier, determining a service data table with the current table type being the query type through querying the access control table, and performing data query in the determined service data table.
In an alternative embodiment of the first aspect, the method further comprises;
determining the update frequency of at least one original service table in a database;
For each original service table, if the update frequency of the original service table is greater than a preset frequency threshold, generating two service data tables with the same table structure corresponding to the original service table based on the original service table, and taking the service table identifier of the original service table as the service table identifier corresponding to the service data tables with the same table structure.
In an alternative embodiment of the first aspect, each service data table has a corresponding service table sub-identifier;
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, determining the table types corresponding to the two service data tables respectively based on the access control table, including:
If the access control table stores the corresponding relation between the service table sub-identifiers of the two service data tables corresponding to the target service table identifier and the preset two table types, 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.
In an alternative embodiment of the first aspect, the method further comprises:
acquiring a service table creation request, wherein the service table creation request comprises a service table identifier to be created and service table initial configuration information;
And creating two service data tables corresponding to the service table identifiers to be created based on the service table initial configuration information.
In an optional embodiment of the first aspect, after detecting the access control table, the method further comprises:
if the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type does not exist in the access control table, selecting any business data table from the two business data tables to input the full-quantity updated data, and storing the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type in the access control table.
In an optional embodiment of the first aspect, storing, in the access control table, a correspondence between two service data tables corresponding to the target service table identifier and a table type, includes:
In the access control table, the table type corresponding to the business data table in which the total update data is recorded is set as a query type, and the table type corresponding to the other business data table is set as an update type.
In a second aspect, there is provided an apparatus for updating and querying a service table, the apparatus comprising:
The system comprises an updating request receiving module, a service table updating module and a service table updating module, wherein the updating request receiving module is used for detecting an access control table when receiving a service table updating request, and the service table updating request comprises a target service table identifier and full-quantity updating data, wherein the target service table identifier corresponds to two service data tables with the same table structure;
The table type determining module is used for determining the table types respectively corresponding to the two business data tables based on the access control table if the detection result is that the corresponding relation between the two business data tables corresponding to the target business table identifier and the preset two table types is stored in the access control table, and the table types are update types or query types;
The business table updating module is used for carrying out total updating on the business data table with the table type being the updating type based on the total updating data, and exchanging the table types respectively corresponding to the two business data tables recorded in the access control table;
And the data query module is used for determining the service data table with the current table type as the query type by querying the access control table if the service table identifier to be queried in the data query request is the target service table identifier when the data query request is received, and performing data query in the determined service data table.
In an optional embodiment of the second aspect, the system further includes a service data table generating module, specifically configured to:
determining the update frequency of at least one original service table in a database;
For each original service table, if the update frequency of the original service table is greater than a preset frequency threshold, generating two service data tables with the same table structure corresponding to the original service table based on the original service table, and taking the service table identifier of the original service table as the service table identifier corresponding to the service data tables with the same table structure.
In an alternative embodiment of the second aspect, each service data table has a corresponding service table sub-identification;
If 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, the table type determining module is specifically configured to:
If the access control table stores the corresponding relation between the service table sub-identifiers of the two service data tables corresponding to the target service table identifier and the preset two table types, 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.
In an optional embodiment of the second aspect, the method further includes a service table creation module, specifically configured to:
acquiring a service table creation request, wherein the service table creation request comprises a service table identifier to be created and service table initial configuration information;
And creating two service data tables corresponding to the service table identifiers to be created based on the service table initial configuration information.
In an optional embodiment of the second aspect, the method further includes a service table initializing module, specifically configured to:
if the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type does not exist in the access control table, selecting any business data table from the two business data tables to input the full-quantity updated data, and storing the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type in the access control table.
In an optional embodiment of the second aspect, 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, the service table initialization module is specifically configured to:
In the access control table, the table type corresponding to the business data table in which the total update data is recorded is set as a query type, and the table type corresponding to the other business data table is set as an update type.
In a third aspect, an electronic device is provided, the electronic device comprising:
the system comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the method for updating and inquiring the service table in any embodiment when executing the program.
In a fourth aspect, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the method of updating and querying a service table according to any of the embodiments described above.
In a fifth aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The computer instructions are read from a computer-readable storage medium by a processor of a computer device, which executes the computer instructions, such that the computer device, when executed, implements the method provided in the embodiments of the first aspect.
According to the method for updating and inquiring the service table, when the service table updating request is received, the access control table is detected, if the detection result is that the corresponding relation between the two service data tables corresponding to the target service table identifier and the preset two table types is stored in the access control table, the table types corresponding to the two service data tables respectively are determined from the access control table, the service data tables with the table types being the updating types can be updated in a full amount, 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 in the updating process, querying the access control table, and performing data query in the service data table with the determined table type being the query type. By establishing two service data tables with the same structure, the method alternately serves as a service inquiry table for inquiring data and a service update table for updating data, so that the technical scheme of the embodiment of the application can realize read-write separation, and the technical effect of accurately inquiring the data in the process of updating the service data tables can be achieved.
Detailed Description
Embodiments of the present application are described below with reference to the drawings in the present application. It should be understood that the embodiments described below with reference to the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and the technical solutions of the embodiments of the present application are not limited.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and "comprising," when used in this specification, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, all of which may be included in the present specification. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates that at least one of the items defined by the term, e.g., "a and/or B" may be implemented as "a", or as "B", or as "a and B".
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
The embodiment of the application provides a method for updating and inquiring a service table, which can be realized by equipment/system provided with a database. The device/system related to the embodiment of the application can be used as a service inquiry table for inquiring data and a service update table for updating data in turn by establishing two service data tables with the same structure, so that the technical scheme of the embodiment of the application can realize read-write separation and can accurately perform the technical effect of data inquiry in the process of updating the service data tables.
The technical solutions of the embodiments of the present application and technical effects produced by the technical solutions of the present application are described below by describing several exemplary embodiments. It should be noted that the following embodiments may be referred to, or combined with each other, and the description will not be repeated for the same terms, similar features, similar implementation steps, and the like in different embodiments.
The method for updating and inquiring the service table provided by the embodiment of the application can be applied to the terminal and the server.
As will be appreciated by those skilled in the art, a "terminal" as used herein may be a personal computer, a cell phone, a tablet, a PDA (personal digital assistant), a MID (MobileInternetDevice ), or the like.
The embodiment of the application provides a method for updating a service table, as shown in fig. 1, which comprises the following steps:
In step S101, when a service table update request is received, an access control table may be detected, where the service table update request may include 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.
The method for updating and inquiring the service table can be applied to all databases or data processing systems needing to update the table in full. Taking a database as an example, a plurality of service tables can be stored in the database to meet the requirements of data query and processing.
When a service table update request is received, the service table update request may include a target service table identifier and full-quantity update data, and a service table to be updated may be determined from various service tables in the database based on the target service table identifier.
Specifically, in the method for updating and querying the service table provided by the application, one target service table identifier can correspond to two service data tables with the same table structure, and each service data table is provided with a service table sub identifier of the own besides the corresponding target service table identifier.
The target service table identifier may be a target service table name, such as "a user's consumption amount statistics table", and the service table sub-identifiers of the two service data tables corresponding to the target service table identifier may be "a user's consumption amount statistics table 1" and "a user's consumption amount statistics table 2".
Step S102, if the detection result is that the corresponding relation between two business data tables corresponding to the target business table identifier and two preset table types is stored in the access control table, determining the table types corresponding to the two business data tables respectively based on the access control table, wherein the table types can be update types or query types;
The preset two table types comprise an update type and a query type, when the table type corresponding to one service data table is the update type, the service data table can be used as a service update table, and similarly, when the table type of one service data table is the query type, the service data table can be used as a service query table.
In the embodiment of the application, each service data table may have a corresponding service table sub-identifier, and 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 the preset two table types, 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 for each service data table.
Specifically, the manner of storing the correspondence between the service table sub-identifiers of the two service data tables and the preset two table types in the access control table may include, but is not limited to, that there are fields corresponding to the two table types in the access control table, for example, the two fields may be set to a "service update table" (corresponding to an update type) and a "service query table" (corresponding to a query type), and the values of the two fields may be set to service table sub-identifiers, so as to establish the correspondence between the two table types and the service table sub-identifiers of the two service data tables, and further determine the table types of the two service data tables.
For example, when the service table sub-identifications of the two service data tables corresponding to the target service table identification are "the consumption amount statistics table 1 of the a user" and "the consumption amount statistics table 2 of the a user", the value of the "service update table" field corresponding to the target service table identification in the access control table may be "the consumption amount statistics table 1 of the a user", and the value of the "service lookup table" field may be "the consumption amount statistics table 2 of the a user". The table type of the service data table with the service sub-identifier of "the consumption amount statistics table 1 of the a user" can be determined as the update type from the access control table based on the target service table identifier and the service sub-identifier, and the table type of the service data table with the service sub-identifier of "the consumption amount statistics table 2 of the a user" is the query type.
It should be noted that, the specific forms and contents of the service table identifier and the service table sub-identifier are only used as examples, and the identifier may be in different forms according to different grammars of different databases, including but not limited to english letters, chinese characters, symbols, numerical numbers, and the like.
In the embodiment of the application, each service table identifier can correspond to a respective access control table.
In the method for updating and querying the service table provided by the application, the access control table is detected, if the corresponding relation between the service table sub-identifiers of the two service data tables corresponding to the target service table identifier and the preset two table types is stored in the access control table, the table types corresponding to the two service data tables respectively are determined from the access control table based on the target service table identifier and the service table sub-identifier, and the method specifically comprises the following steps:
(1) The method comprises the steps of determining a target access control table based on a target service table identifier, wherein the target access control table can contain a field with a value being the target service table identifier, and the field can be matched with a corresponding target access control table through the target service table identifier;
(2) Detecting a target access control table, and if the target access control table stores the corresponding relation between the service table sub-identifiers of the two service data tables corresponding to the target service table identifier and the preset two table types, determining the table types corresponding to the two service data tables respectively from the target access control table based on the target service table identifier and the service table sub-identifier.
In some embodiments, the access control table may also be a total table, where the access control table includes some attribute information corresponding to some service table identifiers respectively. And searching corresponding attribute information in the access control table according to the service table identification.
As an alternative, the access control table may include a "service update table" and a "service lookup table" field corresponding to each recorded service table identifier.
For any service table identifier with the corresponding relation between the service sub-identifier and the table type recorded in the access control table, the table type corresponding to the two service data tables corresponding to the service table identifier can be determined by inquiring the values of the two fields. Specifically, the table type corresponding to the business data table corresponding to the business table sub-identifier as the value of the business update table field is an update type, and the table type corresponding to the business data table corresponding to the business table sub-identifier as the value of the business query table field is a query type.
Step S103, based on the total update data, the total update is carried out on the business data table with the table type being the update type, and the table types corresponding to the two business data tables recorded in the access control table are exchanged.
Specifically, the current data in the service data table with the table type being the update type can be cleared first, and the total update data is imported into the service data table, so as to realize total update.
In the embodiment of the application, if each service table identifier corresponds to a respective access control table, after the service data table with the table type being the service update table is updated in a full amount based on the full amount update data, table types respectively corresponding to the service table sub identifiers of two service data tables in the target access control table corresponding to the target service table identifier can be exchanged.
Specifically, when the values of the "service update table" and the "service lookup table" fields corresponding to the two table types in the target access control table are the service table sub-identifications of the two service data tables, after the full-size update is completed, the values of the "service update table" and the "service lookup table" fields in the target access control table can be interchanged. For example, before the total update, the value of the "service update table" field is "service table sub-identifier 1", the value of the "service lookup table" field is "service table sub-identifier 2", after the total update, the values of the "service update table" and "service lookup table" fields are exchanged, so that the value of the "service update table" field is "service table sub-identifier 2", the value of the "service lookup table" field is "service table sub-identifier 2", and the table types corresponding to the service table sub-identifiers of the two service data tables after the exchange are exchanged.
In one example, the table types respectively corresponding to the two service data tables corresponding to the target service table identifier are not invariable in the process of multiple updating, but dynamically change according to the updating times.
Assume that the service table sub-identifications of the two service data tables corresponding to the target service table identification are "a user consumption amount statistics table 1" and "a user consumption amount statistics table 2" respectively. The current corresponding relation stored in the target access control table corresponding to the target service table identifier is that the table type corresponding to the user consumption amount statistical table 1 is an updating type, and the table type corresponding to the user consumption amount statistical table 2 is a query type.
In the process of updating after the first time of receiving the service table updating request, the table type of the service data table with the service table sub-identifier of "A user consumption amount statistical table 1" is determined to be an updating type based on the target access control table, the table type of the service data table with the service table sub-identifier of "A user consumption amount statistical table 2" is a query type, and the service data table with the updating type (namely, the service data table corresponding to "A user consumption amount statistical table 1") can be updated in a full amount by using the full amount updating data. After the full-volume updating is completed, the table types corresponding to the business table sub-identifiers of the two business data tables in the target access control table corresponding to the target business table identifiers are exchanged, so that the table type corresponding to the user consumption amount statistical table 1 is the query type, and the table type corresponding to the user consumption amount statistical table 2 is the updating type.
In the process of updating after receiving the service table updating request for the second time, the table type of the service data table with the service table sub-identifier of "A user consumption amount statistical table 1" is determined to be the query type based on the target access control table, the table type of the service data table with the service table sub-identifier of "A user consumption amount statistical table 2" is determined to be the updating type, and the service data table with the updating type (namely, the service data table corresponding to "A user consumption amount statistical table 2") can be updated in a full amount by using the full amount updating data. And similarly, after the full updating is completed, the table types corresponding to the business table sub-identifiers of the two business data tables in the target access control table corresponding to the target business table identifier are exchanged, so that the table type corresponding to the user consumption amount statistical table 1 is an updating type, and the table type corresponding to the user consumption amount statistical table 2 is a query type.
And when the subsequent updating is performed for a plurality of times, the processing can be performed according to the method, and redundant discussion is omitted.
Step S104, when receiving the data query request, if the service table identification to be queried in the data query request is the target service table identification, determining the service data table with the current table type being the query type by querying the access control table, and performing data query in the determined service data table. It will be appreciated that step S104 may occur after step S103, or may occur at any time node between step S101 and step S103, and when a data query request is received, it is only necessary to determine, based on the access control table, a service data table whose current table type is a query type, and perform data query.
According to the method for updating and inquiring the service table, when the service table updating request is received, the access control table is detected, if the detection result is that the corresponding relation between the two service data tables corresponding to the target service table identifier and the preset two table types is stored in the access control table, the table types corresponding to the two service data tables respectively are determined from the access control table, the service data tables with the table types being the updating types can be updated in a full amount, 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 in the updating process, querying the access control table, and performing data query in the service data table with the determined table type being the query type. By establishing two service data tables with the same structure, the method alternately serves as a service inquiry table for inquiring data and a service update table for updating data, so that the technical scheme of the embodiment of the application can realize read-write separation, and the technical effect of accurately inquiring the data in the process of updating the service data tables can be achieved.
In one example, the schematic structure of the target access control table corresponding to the target service table identifier may be shown in fig. 2a, where the target access control table may include five fields of "number", "service table identifier", "chinese name", "service update table" and "service lookup table", and the values of the five fields are shown in the second row in fig. 2 a.
When the target service table identifier is "CONSUMPTION_ STATISTICS", the value of the "service table identifier" field in the target access control table corresponding to the target service table identifier is also "CONSUMPTION_ STATISTICS". The target business table identification here consists of letters, for example only, to conform to the syntax of the specified database. The value of the 'Chinese name' field in the target access control list describes the Chinese meaning of the target service list mark composed by the letters, and the service data list corresponding to the target service list mark is used for recording the consumption amount of the user.
When the service table sub-identifiers of the two corresponding service data tables are respectively "CONSUMPTION_ STATISTICS _A" and "CONSUMPTION_ STATISTICS _B", the service data table whose service table sub-identifier ends with "_A" is referred to as an A table, and the service data table whose service table ends with "_B" is referred to as a B table.
And determining that the table type corresponding to the current A table is an update type table and the table type corresponding to the B table is a query type based on the target access control table.
After receiving the service table update request and performing total update on the A table with the table type being the service update table by using the total update data, the table types corresponding to the service table sub-identifiers of the two service data tables in the target access control table can be exchanged, so that the table types corresponding to the two service data tables can be exchanged.
The exchanged target access control table may exchange the values of the "service update table" and "service lookup table" fields as shown in fig. 2 b.
The embodiment of the application provides a possible implementation mode, and the method for updating and inquiring the service table further comprises the following steps:
(1) The method comprises the steps of obtaining a service table creation request, wherein the service table creation request comprises a service table identifier to be created and service table initial configuration information, and the service table initial configuration information comprises a plurality of attributes corresponding to the service table identifier to be created, wherein each attribute can consist of a column name, a data type and a plurality of integrity constraint conditions of the column;
(2) And creating two service data tables corresponding to the service table identifiers to be created and an access control table corresponding to the service table identifiers to be created based on the service table initial configuration information, wherein the two service data tables corresponding to the service table identifiers to be created have the same structure.
In the embodiment of the application, two service data tables are not created for each service table identifier to be created, and the two service data tables can be created for the service table identifier to be created corresponding to the service data which may have total updating requirements.
Specifically, the user may set some keywords, such as "statistics", "total amount", "daily", "monthly" and "yearly", and when the service table identifier to be created includes at least one of the preset keywords, two service data tables corresponding to the service table identifier to be created are created.
In one possible implementation manner provided in the embodiment of the present application, when an original service table of a data table with the same result of two tables is not created in a database, the method for updating and querying the service table provided in the present application may further include the following steps:
determining the update frequency of at least one original service table in a database;
For each original service table, if the update frequency of the original service table is greater than a preset frequency threshold, generating two service data tables with the same table structure corresponding to the original service table based on the original service table, and taking the service table identifier of the original service table as the service table identifier corresponding to the service data tables with the same table structure.
The embodiment of the application provides a possible implementation manner, and after detecting the access control table, the method further comprises the following steps:
if the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type does not exist in the access control table, any business data table can be selected from the two business data tables to input the full-quantity updated data, and the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type is stored in the access control table.
It will be appreciated that the service table update process includes not only updating the service data table already containing data, but also selecting any service data table from the new service data table to enter the full amount of update data when a new service data table is created, where the full amount of update data may be initial service data.
In the embodiment of the application, after any service data table is selected to record initial service data, at this time, for the group of service data tables, one service data table records service initial data, and the other service data table does not store data at this time, the following steps can be executed, namely, the table type corresponding to the service data table with the total update data recorded therein is set as a query type, and the table type corresponding to the other service data table is set as an update type in the access control table.
Specifically, after any service data table inputs initial service data, the access control table corresponding to the service data table of the group may be further initialized, so that the table type corresponding to the service table sub-identifier of the service data table inputting the full amount of update data in the access control table is a query type, and the table type corresponding to the service table sub-identifier of the other service data table is an update type.
When a service table updating request aiming at the group of service data tables is received next time, the service data tables which are not input with data are updated in full quantity, and before the second updating is completed, if a data query request is received, the data query is carried out in the service data tables which are input with service initial data.
In one embodiment, the process of updating the business table may be as shown in FIG. 3, including two situations, a process of first entering data into the business data table after creating a set of business data tables, and a process of updating the set of business data tables for which data has been entered after entering data. The set of service data tables refers to two service data tables corresponding to one service table identifier, and the set of service data tables with data entered can refer to any service data table in the set of service data tables in which data is stored.
The method comprises the following specific steps:
Step S301, receiving a service table update request, wherein the service update request can comprise a target service table identifier and service data, the target service table identifier can correspond to two service data tables with the same table structure, such as an A table and a B table, each service data table has a corresponding service table sub-identifier, the service table sub-identifier of the A table can be a service data table A, and the service table sub-identifier of the B table can be a service data table B;
Step S302, detecting whether the corresponding relation between the business table sub-identifiers of the A table and the B table and the table types exists in the access control table, if yes, entering step S303, otherwise, entering step S305;
Step S303, determining the form types corresponding to the A form and the B form respectively from the access control form based on the target business form identifier and the business form sub identifiers of the A form and the B form;
Step S304, based on the business data, the business data table with the table type being the business update table is updated in full quantity, and the table types corresponding to the business table sub-identifiers of the table A and the table B in the access control table are exchanged, and the process is ended; for example, if before updating, the table type corresponding to the table a is a service update table (i.e. update type), and the table type corresponding to the table B is a service query table (i.e. query type), then the table a is updated in full, and the table types corresponding to the table sub-identifiers of the table a and the table B in the control table are accessed to be exchanged, after the exchange, the table sub-identifiers of the table a correspond to the service query table, the table sub-identifiers of the table B correspond to the service update table, so that the table types corresponding to the two service sub-identifiers are exchanged, and the table types of the two service data tables are exchanged;
step S305, which illustrates that no data is entered after the tables A and B are created, any business data table can be selected from the tables A and 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 entering the business data in the access control table after the initialization is a business lookup table, the table type corresponding to the business table sub-identifier of the other business data table is a business update table, for example, if the business data is entered in the table A, the table type corresponding to the business table sub-identifier of the table A in the access control table is a business lookup table (i.e. query type), the table type corresponding to the business table sub-identifier of the table B in the access control table is a business update table (i.e. update type), and the process is ended.
In one possible implementation manner provided in the embodiment of the present application, as shown in fig. 4, the method for updating and querying a service table provided in the present application may further include the following steps:
Step S401, receiving a data query request, wherein the data query request comprises a service table identifier to be queried, and the service table identifier to be queried can be a target service table identifier in the updating process or other service table identifiers in a database;
Step S402, determining an access control table corresponding to the service table identifier to be queried, specifically, determining the access control table corresponding to the service table identifier to be queried based on the service table identifier to be queried;
In step S403, the business table sub-identifier of which the table type is the business lookup table is determined from the access control table corresponding to the business table identifier to be queried, and the data is queried in the business data table corresponding to the determined business table sub-identifier, specifically, the business table identifier to be queried can be corresponding to two business data tables with the same table structure, the corresponding relation 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 is stored in the access control table corresponding to the business table identifier to be queried, the business table sub-identifier of which the table type is the query type can be determined from the access control table, then the business data table is further determined based on the determined business table sub-identifier, and the data is queried in the determined business data table.
The embodiment of the application provides a possible implementation manner, and the method for updating and inquiring the service table provided by the application can further comprise the following steps:
(1) Acquiring a data processing request, wherein the data processing request comprises a request identifier and a service table identifier to be processed, and the service table identifier to be processed can be a target service table identifier in an updating process or a service table identifier to be queried in a data query process;
(2) The request type of the data processing request is determined based on the request identifier, wherein the request type can comprise a service table update request and a data query request, the request identifier can be simply set to be a number, for example, the request identifier corresponding to the request type of the service table update request can be set to be 1, and the request identifier corresponding to the request type of the data query request is set to be 0;
(3) For different request types, the following two corresponding treatments may be taken:
A. when the request type of the data processing request is a service table updating request, the service table identifier to be processed is used as a target service table identifier, and an access control table corresponding to the target service table identifier is detected;
The subsequent step can perform corresponding processing according to the received service table update request, for example, if the corresponding relation between the service table sub-identifiers of the two service data tables corresponding to the target service table identifier and the preset two table types is stored in the access control table, determining the table types corresponding to the two service data tables respectively from the access control table based on the target service table identifier and the service table sub-identifier, wherein the table types comprise an update type and a query type;
B. When the request type of the data processing request is a data query request, the service table identifier to be processed is used as a service table identifier to be queried, and an access control table corresponding to the service table identifier to be queried is determined;
The subsequent steps can perform corresponding processing according to the received data query request, for example, determine the service table sub-identifier with the table type being the query type from the access control table corresponding to the service table identifier to be queried, and query the data in the service data table corresponding to the determined service table sub-identifier.
In order to more clearly illustrate the method for updating and querying a service table according to the present application, a method for updating and querying a service table will be further described with reference to specific alternative embodiments.
The time schematic of the method for updating and querying the service table provided in this alternative embodiment may be shown in fig. 5. In this embodiment, the method for updating and querying the service table may include updating and querying two parts, where the querying operation may occur at any time node in the present process, and for data query requests initiated by different time nodes, corresponding various processing schemes are described in detail below. In addition, in the present embodiment, the query type is referred to by a service query table, the update type is referred to by a service update table,
The method for updating and querying the service table in the embodiment specifically may include the following steps:
The first step, two service tables (service data tables) with the same structure and an access control table can be created, wherein the two service tables with the same structure can be an A table and a B table;
the second step, when the data is imported for the first time, optionally importing initial service data from one of the table a and the table B, for example, selecting to import the initial service data into the table a, and initializing the access control table; specifically, the value of the "service lookup table" field of the table type in the access control table may be set as the service table sub-identifier of the table a, and the value of the "service update table" field may be set as the service table sub-identifier of the table B;
After importing data into the table A, before updating the service table next time, the table type corresponding to the table A is a service lookup table, and the table type corresponding to the table B is a service update table. If a data query request is received at this time, the data is queried using the A table.
Fourth, receiving a service table update request, wherein the table type corresponding to the B table is the service update table, so that the B table is updated in full quantity, and the data is imported for the second time. Wherein, the full update means to empty the data in the B table and import the service update data in the service update request;
In the process of updating the B table in full (not updated), the table types of the A table and the B table are not exchanged yet, and if a data query request is received, the A table is still used for querying the data.
After the total updating of the table B is completed, the table types corresponding to the table A and the table B can be interchanged, specifically, the values of two fields, namely a service lookup table and a service update table, of the table types in the access control table can be interchanged, the table types respectively corresponding to the table A and the table B after interchange are shown as a third oval frame on the right side, at this time, the table B corresponds to the service lookup table, and the table A corresponds to the service update table.
If the data query request is received after the total update of the B table is completed, the data is queried by using the B table because the table type corresponding to the B table is the service query table at the moment.
And fifthly, receiving a service table update request, wherein the table type corresponding to the A table is the service update table, so that the A table is updated in full quantity, and the data is imported for the third time.
In the process of updating the whole amount of the table A (the updating is not completed yet), the table types of the table A and the table B are not exchanged yet, and if a data query request is received, the table type corresponding to the table B of the service query table is adopted to query the data.
After the total update of the table a is completed, the table types corresponding to the table a and the table B can be interchanged, specifically, the values of the two fields of the "service lookup table" and the "service update table" which represent the table types in the access control table can be interchanged, the table types respectively corresponding to the table a and the table B after the interchange are shown as a fourth oval frame on the right side, at this time, the table a corresponds to the service lookup table, and the table B corresponds to the service update table.
If the data query request is received after the total update of the A table is completed, the data is queried by using the A table because the table type corresponding to the A table is the service query table at the moment.
If there are more than one update, the update can be processed according to the above flow, and will not be discussed.
The embodiment of the application provides a device for updating and querying a service table, as shown in fig. 6, the device 60 for updating and querying a service table may include an update request receiving module 601, a table type determining module 602, a service table updating module 603 and a data querying module 604, wherein,
The update request receiving module 601 is configured to detect an access control table when a service table update request is received, where 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;
The table type determining module 602 is configured to determine, based on the access control table, a table type corresponding to the two service data tables respectively, if the detection result is that a correspondence between two service data tables corresponding to the target service table identifier and two preset table types is stored in the access control table, where the table type is an update type or a query type;
The service table updating module 603 is configured to perform total update on a service data table with a table type being an update type based on the total update data, and exchange table types corresponding to two service data tables recorded in the access control table respectively;
And the data query module 604 is configured to determine, when the data query request is received, that the current table type is a query type service data table by querying the access control table if the service table identifier to be queried in the data query request is the target service table identifier, and perform data query in the determined service data table.
The device for updating and inquiring the service table detects the access control table when receiving the service table updating request, determines the table types respectively corresponding to the two service data tables from the access control table if the detection result is that the corresponding relationship between the two service data tables corresponding to the target service table identifier and the preset two table types is stored in the access control table, and can update the service data table with the updated table type in full quantity and exchange the table types corresponding to the two service data tables recorded in the access control table. If a data query request is received in the updating process, querying the access control table, and performing data query in the service data table with the determined table type being the query type. By establishing two service data tables with the same structure, the method alternately serves as a service inquiry table for inquiring data and a service update table for updating data, so that the technical scheme of the embodiment of the application can realize read-write separation, and the technical effect of accurately inquiring the data in the process of updating the service data tables can be achieved.
The embodiment of the application further comprises a service data table generating module, which is specifically used for:
determining the update frequency of at least one original service table in a database;
For each original service table, if the update frequency of the original service table is greater than a preset frequency threshold, generating two service data tables with the same table structure corresponding to the original service table based on the original service table, and taking the service table identifier of the original service table as the service table identifier corresponding to the service data tables with the same table structure.
In the embodiment of the application, each service data table is provided with a corresponding service table sub-identifier;
if 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, the table type determining module 602 is specifically configured to:
If the access control table stores the corresponding relation between the service table sub-identifiers of the two service data tables corresponding to the target service table identifier and the preset two table types, 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.
The embodiment of the application further comprises a service table creation module, which is specifically used for:
acquiring a service table creation request, wherein the service table creation request comprises a service table identifier to be created and service table initial configuration information;
And creating two service data tables corresponding to the service table identifiers to be created based on the service table initial configuration information.
In the embodiment of the application, the method also comprises a service table initializing module which is specifically used for:
if the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type does not exist in the access control table, selecting any business data table from the two business data tables to input the full-quantity updated data, and storing the corresponding relation between the two business data tables corresponding to the target business table identifier and the table type in the access control table.
In the embodiment of the application, when the service table initialization module stores the corresponding relation between two service data tables corresponding to the target service table identifier and the table types in the access control table, the service table initialization module is specifically used for:
In the access control table, the table type corresponding to the business data table in which the total update data is recorded is set as a query type, and the table type corresponding to the other business data table is set as an update type.
The device of the embodiment of the present application may perform the method provided by the embodiment of the present application, and its implementation principle is similar, and actions performed by each module in the device of the embodiment of the present application correspond to steps in the method of the embodiment of the present application, and detailed functional descriptions of each module of the device may be referred to the descriptions in the corresponding methods shown in the foregoing, which are not repeated herein.
The embodiment of the application provides an electronic device (computer device/system), which comprises a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to realize the steps of a method for updating and inquiring a service table, and compared with the related technology, the method can realize the following steps: by establishing two service data tables with the same structure, the service data tables are alternately used as a service query table for querying data and a service update table for updating data, so that the technical scheme of the embodiment of the application can realize read-write separation and can accurately perform the technical effect of data query in the process of updating the service data tables.
In an alternative embodiment, an electronic device is provided, as shown in FIG. 7, the electronic device 4000 shown in FIG. 7 comprising a processor 4001 and a memory 4003. Wherein the processor 4001 is coupled to the memory 4003, such as via a bus 4002. Optionally, the electronic device 4000 may further comprise a transceiver 4004, the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of 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 is not limited to the embodiment of the present application.
The processor 4001 may be a CPU (central processing unit), general purpose processor, DSP (digital signal processor), ASIC (ApplicationSpecificIntegratedCircuit ), FPGA (Field ProgrammableGateArray, field programmable gate array) or other programmable logic device, transistor logic device, hardware component, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. The processor 4001 may also be a combination that implements computing functionality, e.g., comprising one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
Bus 4002 may include a path to transfer information between the aforementioned components. Bus 4002 may be a PCI (PeripheralComponentInterconnect, peripheral component interconnect standard) bus or an EISA (ExtendedIndustryStandardArchitecture ) bus, or the like. The bus 4002 can be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 7, but not only one bus or one type of bus.
The memory 4003 may be a ROM (read only memory) or other type of static storage device that can store static information and instructions, a RAM (RandomAccess Memory ) or other type of dynamic storage device that can store information and instructions, an EEPROM (ElectricallyErasableProgrammableReadOnly Memory ), a CD-ROM (CompactDiscReadOnly Memory, compact disc read only memory) or other optical disk storage, optical disk storage (including compact 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 a computer program and that can be read by a computer, without limitation.
The memory 4003 is used for storing a computer program for executing an embodiment of the present application, and is controlled to be executed by the processor 4001. The processor 4001 is configured to execute a computer program stored in the memory 4003 to realize the steps shown in the foregoing method embodiment.
Among them, the electronic device includes, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a PAD, etc., and a fixed terminal such as a digital TV, a desktop computer, etc.
Embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of the foregoing method embodiments and corresponding content.
The embodiment of the application also provides a computer program product, which comprises a computer program, wherein the computer program can realize the steps and corresponding contents of the embodiment of the method when being executed by a processor.
The terms "first," "second," "third," "fourth," "1," "2," and the like in the description and in the claims and in the above figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate, such that the embodiments of the application described herein may be implemented in other sequences than those illustrated or otherwise described.
It should be understood that, although various operation steps are indicated by arrows in the flowcharts of the embodiments of the present application, the order in which these steps are implemented is not limited to the order indicated by the arrows. In some implementations of embodiments of the application, the implementation steps in the flowcharts may be performed in other orders as desired, unless explicitly stated herein. Furthermore, some or all of the steps in the flowcharts may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or phases may be performed at the same time, or each of these sub-steps or phases may be performed at different times, respectively. In the case of different execution time, the execution sequence of the sub-steps or stages can be flexibly configured according to the requirement, which is not limited by the embodiment of the present application.
The foregoing is merely an optional implementation manner of some of the implementation scenarios of the present application, and it should be noted that, for those skilled in the art, other similar implementation manners based on the technical ideas of the present application are adopted without departing from the technical ideas of the scheme of the present application, and the implementation manner is also within the protection scope of the embodiments of the present application.