Instruction response method and apparatus
By configuring view data sources and master data sources in a microservice architecture, cross-database join queries can be implemented using mapped views, solving the problems of cumbersome cross-database query steps and low performance, simplifying the operation steps and improving performance.
Patent Information
- Application Number
- CN202210840689.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-18
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-07-18
AI Technical Summary
In a microservice architecture, cross-database join operations are cumbersome and inefficient, and existing technologies struggle to solve them efficiently.
Configure the view data source and the master data source in the target service. Create a mapped view of the external data table in the view data source and determine the target data source according to the instruction type. Execute the instruction using the view data source or the master data source to realize cross-database table join operations.
It simplifies the operation steps of cross-database queries, improves query performance, reduces the difficulty of system upgrades and maintenance, improves maintenance efficiency, and requires no additional middleware or changes to the original processing logic.
Smart Images

Figure CN115129367B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database, and particularly relates to an instruction response method and device. BACKGROUND
[0002] Under the micro-service architecture, according to different businesses, the system is split into different micro-services, each micro-service corresponds to a database instance, and each micro-service and the data corresponding to each micro-service are independent of each other. However, in the actual business processing process, it is often inevitable to have a business scenario of cross-database query data, which often involves databases under multiple micro-services and needs cross-database join table query.
[0003] The problem of cross-database join table query can be solved by setting redundant data or public tables in the database, but the setting of redundant data or public tables often has complicated steps and low query performance. SUMMARY
[0004] Therefore, the embodiments of the present application provide an instruction response method and device, which can simplify the operation steps of cross-database query and have high performance.
[0005] In a first aspect, the embodiments of the present application provide an instruction response method applied to a target service, wherein the target service is configured with a view data source and a main data source, the main data source is used to store internal data of the target service, and the method comprises the following steps:
[0006] determining an external data table required by the target service, wherein the external data table is a data table in a database corresponding to another service;
[0007] creating a mapping view corresponding to the external data table in the view data source;
[0008] receiving an execution instruction for the target service, and determining a target data source corresponding to the execution instruction from the view data source and the main data source;
[0009] responding to the execution instruction by using the target data source.
[0010] Optionally, the step of determining the target data source corresponding to the execution instruction from the view data source and the main data source comprises the following steps:
[0011] determining an instruction type of the execution instruction;
[0012] in a case where the instruction type is a cross-database operation instruction, determining that the view data source is the target data source;
[0013] in a case where the instruction type is an internal operation instruction, determining that the main data source is the target data source.
[0014] Optionally, the determining the instruction type of the execution instruction comprises:
[0015] determining whether the execution instruction involves an external data table of the target service;
[0016] in a case where the execution instruction involves an external data table of the target service, determining the instruction type as a cross-library operation instruction;
[0017] in a case where the execution instruction does not involve an external data table of the target service, determining the instruction type as an internal operation instruction.
[0018] Optionally, before the creating a mapping view corresponding to the external data table in the view data source, the method further comprises:
[0019] determining an external database corresponding to the target service, the external database being a database to which the external data table belongs;
[0020] creating a view user and assigning the view user with query permission of the external database, query editing permission of the view data source and query permission of the main data source;
[0021] the creating a mapping view corresponding to the external data table in the view data source comprises:
[0022] creating, by the view user, a mapping view corresponding to the external data table in the view data source.
[0023] Optionally, the responding to the execution instruction by using the target data source comprises:
[0024] in a case where the target data source is the view data source, calling, by the view user, data in the view data source in response to the execution instruction.
[0025] Optionally, before the responding to the execution instruction by using the target data source, the method further comprises:
[0026] creating a main user and assigning the main user with query permission of the view data source and query editing permission of the main data source;
[0027] the responding to the execution instruction by using the target data source comprises:
[0028] in a case where the target data source is the main data source, calling, by the main user, data in the main data source in response to the execution instruction.
[0029] Optionally, the target service integrates a plurality of alternative frameworks;
[0030] The target data source corresponding to the execution instruction is determined from the view data source and the main data source.
[0031] A target framework corresponding to the execution instruction is determined from the plurality of alternative frameworks.
[0032] The execution instruction is parsed according to the target framework.
[0033] The target data source is determined according to a parsing result of the execution instruction.
[0034] Optionally, the target data source is used to respond to the execution instruction, including:
[0035] Data information corresponding to the execution instruction is obtained from the target data source.
[0036] A return result corresponding to the data information is generated according to the target framework.
[0037] The return result is sent.
[0038] Optionally, after the mapping view corresponding to the external data table is created in the view data source, the method further includes:
[0039] External table change information is obtained.
[0040] A view editing instruction corresponding to the external table change information is generated, and the view editing instruction includes at least one of a view creation instruction, a view deletion instruction, and a view modification instruction.
[0041] The view editing instruction is executed in the view data source.
[0042] In a second aspect, an embodiment of the present application provides an instruction response device applied to a target service, the target service being configured with a view data source and a main data source, the main data source being used to store internal data of the target service, and the instruction response device including:
[0043] A table determination module is configured to determine an external data table required by the target service, the external data table being a data table in a database corresponding to another service.
[0044] A view creation module is configured to create a mapping view corresponding to the external data table in the view data source.
[0045] A data source determination module is configured to receive an execution instruction for the target service, and determine a target data source corresponding to the execution instruction from the view data source and the main data source.
[0046] a response module, configured to respond to the execution instruction by using the target data source.
[0047] Optionally, the data source determination module is specifically configured to:
[0048] determine a type of the execution instruction;
[0049] in a case where the type of the execution instruction is a cross-library operation instruction, determine that the view data source is the target data source;
[0050] in a case where the type of the execution instruction is an internal operation instruction, determine that the main data source is the target data source.
[0051] Optionally, the data source determination module is further configured to:
[0052] determine whether the execution instruction involves an external data table of the target service;
[0053] in a case where the execution instruction involves the external data table of the target service, determine that the type of the execution instruction is the cross-library operation instruction;
[0054] in a case where the execution instruction does not involve the external data table of the target service, determine that the type of the execution instruction is the internal operation instruction.
[0055] In a third aspect, an electronic device is provided, including:
[0056] one or more processors;
[0057] a storage device configured to store one or more programs,
[0058] when the one or more programs are executed by the one or more processors, the one or more processors implement the method in any of the above embodiments.
[0059] In a fourth aspect, a computer readable medium is provided, which stores a computer program, and the program is executed by a processor to implement the method in any of the above embodiments.
[0060] In a fifth aspect, a computer program product is provided, which includes a computer program, and the program is executed by a processor to implement the method in any of the above embodiments.
[0061] The above embodiment has the following advantages or beneficial effects: the target service is configured with a view data source and a main data source. A mapping view corresponding to an external data table required by the target service is created in the view data source. When an execution instruction is received, a target data source corresponding to the execution instruction is determined from the view data source and the main data source, and the target data source is used to respond to the execution instruction.
[0062] If the instruction type is a cross-library operation instruction, the view data source is determined as the target data source. With the mapping view in the view data source, the complex operations of calling, querying and aggregating brought by the aggregation service can be reduced, and the cross-library join table operation can be simply and efficiently implemented. The scheme of the embodiment of the present application does not need to establish a synchronization mechanism, does not introduce additional middleware, and does not need to change the original processing logic of each service. Therefore, the operation steps of the cross-library query can be simplified and the performance is high.
[0063] In addition, according to different stored data, the view data source and the main data source are respectively set, and through mutual coordination and cooperation of data in the view data source and the main data source, the final service function is realized. Compared with storing all data in the same data source, the mutual influence between different stored data can be reduced, the difficulty of system upgrade and maintenance is reduced, and the operation and maintenance efficiency of the system is improved.
[0064] The further effects of the above-mentioned non-conventional optional mode will be described in the following combined with the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0065] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application. Among them:
[0066] Figure 1 is a flowchart of a method for responding to an instruction provided by a first embodiment of the present application;
[0067] Figure 2 is a flowchart of a method for responding to an instruction provided by a second embodiment of the present application;
[0068] Figure 3 is a flowchart of a method for responding to an instruction provided by a third embodiment of the present application;
[0069] Figure 4 is a system structure diagram of a micro-service architecture provided by a fourth embodiment of the present application;
[0070] Figure 5 is a structure diagram of an instruction responding device provided by an embodiment of the present application;
[0071] Figure 6 is a structure diagram of a computer system of a terminal device or a server suitable for implementing the embodiments of the present application. DETAILED DESCRIPTION
[0072] Exemplary embodiments of the present application are described herein below with reference to the accompanying drawings, in which various specific details are set forth to facilitate explanation of the present application. However, it should be noted that the present application can be practiced without such specific details. In other instances, well known methods, structures and techniques have not been shown in detail in order not to obscure the understanding of this description. It is to be understood that the phraseology and terminology used herein is for the purpose of description and explanation only. Thus, the methods and systems described herein are not intended to be limited to the various embodiments described herein. Many modifications and other embodiments of the methods and systems described herein set forth herein will come to mind to one skilled in the art to which the present application pertains upon review of the description. Therefore, it is to be understood that the methods and systems described herein are not limited to the specific embodiments disclosed and that modifications and other embodiments are intended to be included.
[0073] The acquisition, storage, use, processing and the like of data in the technical solutions of the present application comply with relevant provisions of national laws and regulations.
[0074] Figure 1 is a flowchart of a method of responding to an instruction provided by the first embodiment of the present application, the method being applied to a target service, the target service being configured with a view data source and a main data source, as shown in Figure 1 The method comprises the following steps.
[0075] Step 101: Determine the external data table required by the target service, the external data table being a data table in a database corresponding to another service.
[0076] The same system is split into different services according to business functions, each service corresponding to a different database, and each service and the database corresponding to each service are independent of each other. The target service and the other service can be different services under the same system. The target service and the other service provide different business functions, respectively. The target service and the other service are independent of each other, and the database corresponding to the target service and the database corresponding to the other service are independent of each other.
[0077] The external data table is a data table in a database corresponding to another service required by the target service in the process of providing a business function. Since the database corresponding to the target service and the database corresponding to the other service are independent of each other, the target service often cannot directly access the external data table.
[0078] There are many ways to determine the external data table required by the target service. The development requirement document of the target service can be analyzed to obtain the external data table required by the target service. A mapping relationship between the service and the external data table can also be set, and the external data table required by the target service can be determined according to the mapping relationship.
[0079] Step 102: Create a mapping view corresponding to the external data table in the view data source.
[0080] The target service is provided with a view data source and a main data source. A mapping view corresponding to the external table is created in the view data source. The mapping view is a virtual table of the external table in the view data source. The data in the mapping view comes from the table referenced when the mapping view is defined. The data in the mapping view is dynamically generated from the table referenced when the mapping view is referenced. Therefore, the complexity of calling, querying and aggregating brought by the aggregation service can be avoided by using the mapping view, the cross-database query problem can be efficiently solved, and the data synchronization problem does not need to be considered.
[0081] The main data source is used for storing internal data of the target service and responding to instructions without cross-database query. The internal data of the target service is data required during running of the target service except the external data. The external data is data from the external data table.
[0082] Step 103: Receiving an execution instruction for the target service, and determining a target data source corresponding to the execution instruction from the view data source and the main data source.
[0083] The instruction type corresponding to the execution instruction can be determined, and the correspondence between the instruction type and the data source can be set according to specific requirements. For example, when the instruction type is a cross-database query instruction, the view data source is determined as the target data source. When the instruction type is a cross-database editing instruction, a prompt message indicating that operation is not allowed is displayed. When the instruction type is an internal operation instruction, the main view is determined as the target data source. The internal operation instruction can include an internal query instruction and an internal editing instruction.
[0084] Step 104: Responding to the execution instruction by using the target data source.
[0085] In the embodiment of the application, the target service is provided with a view data source and a main data source. A mapping view corresponding to the external data table required by the target service is created in the view data source. When an execution instruction is received, a target data source corresponding to the execution instruction is determined from the view data source and the main data source, and the execution instruction is responded by using the target data source.
[0086] If the instruction type is a cross-database operation instruction, the view data source is determined as the target data source. The mapping view in the view data source can be used to simply and efficiently implement cross-database table operation. The scheme of the embodiment of the application does not need to establish a synchronization mechanism, does not introduce additional middleware, and does not need to change the original processing logic of each service. Therefore, the operation steps of cross-database query can be simplified and high performance can be achieved.
[0087] In addition, according to different stored data, a view data source and a main data source are respectively arranged, and through mutual coordination and cooperation of data in the view data source and the main data source, a final service function is realized. Compared with uniformly storing all data in the same data source, mutual influence between different stored data can be reduced, and difficulty of system upgrade and operation and maintenance is reduced and operation and maintenance efficiency of the system is improved.
[0088] Figure 2 is a flowchart of an instruction response method provided by the second embodiment of the present application, the method is applied to a target service, the target service is configured with a view data source and a main data source, as shown in Figure 2 , the method comprises the following steps.
[0089] Step 201: Determine the external data table required by the target service, the external data table is a data table in a database corresponding to another service.
[0090] Step 202: Create a mapping view corresponding to the external data table in the view data source.
[0091] Step 203: Receive an execution instruction for the target service, and determine the instruction type of the execution instruction.
[0092] The instruction type can be determined by the following methods: determining whether the execution instruction involves the external data table of the target service; in the case that the execution instruction involves the external data table of the target service, determining that the instruction type is a cross-database operation instruction; in the case that the execution instruction does not involve the external data table of the target service, determining that the instruction type is an internal operation instruction.
[0093] In the case that the instruction type is a cross-database operation instruction, it can be further determined that a database keyword is executed, and according to the database keyword, it is determined that the instruction type is a cross-database query instruction or a cross-database editing instruction.
[0094] According to the instruction type of the execution instruction, step 204 or step 206 is executed.
[0095] Step 204: In the case that the instruction type is a cross-database operation instruction, the view data source is determined as the target data source.
[0096] The view data source stores a mapping view corresponding to the external table, and the mapping view can be used to respond to the cross-database operation instruction. If the instruction type is a cross-database query instruction, the view data source is determined as the target data source.
[0097] Further, if the instruction type is a cross-database editing instruction, it is determined whether the external data table can be edited through the mapping view. In the case that the external data table can be edited through the mapping view, the view data source is determined as the target data source; in the case that the external data table cannot be edited through the mapping view, a prompt information that operation is not allowed is sent.
[0098] Step 205: responding to the execution instruction by using the view data source.
[0099] Step 206: in the case that the instruction type is an internal operation instruction, determining that the main data source is the target data source.
[0100] The main data source is used to store relevant data in the target service. Since the internal operation instruction only involves the data table in the database corresponding to the target service, the main data source is determined as the target data source for responding to the execution instruction.
[0101] Step 207: responding to the execution instruction by using the main data source.
[0102] In the embodiment of the present application, the view data source and the main data source are respectively set according to different data. According to the instruction type of the execution instruction, the target data source is determined from the view data source and the main data source, thereby realizing the technical effect of responding to different types of execution instructions by different data sources.
[0103] In an embodiment of the present application, two data sources, i.e., the view data source and the main data source, are configured for the target service. The view data source and the main data source are respectively used to store different data. In order to separate the two data sources, clarify their responsibilities, and reduce the difficulty of development and operation, different users can be respectively set for the two data sources to manage the two data sources.
[0104] The view user can be created in the following manner, and the view user is used to manage the view data source: determining the external database corresponding to the target service, the external database being the database to which the external data table belongs; creating the view user, and assigning the query permission of the external database, the query and editing permission of the view data source, and the query permission of the main data source to the view user; and creating the mapping view corresponding to the external data table in the view data source by using the view user.
[0105] In the case that the execution instruction is received and the target data source is the view data source, the data in the view data source is called by using the view user to respond to the execution instruction.
[0106] The main user can be created in the following manner, and the main user is used to manage the main data source: creating the main user, and assigning the query permission of the view data source and the query and editing permission of the main data source to the main user. In the case that the execution instruction is received and the target data source is the main data source, the data in the main data source is called by using the main user to respond to the execution instruction.
[0107] In one embodiment of the present application, the target service integrates multiple alternative frameworks; the target data source corresponding to the execution instruction is determined from the view data source and the master data source, including: determining the target framework corresponding to the execution instruction from the multiple alternative frameworks; parsing the execution instruction according to the target framework; and determining the target data source according to the parsing result of the execution instruction.
[0108] The alternative frameworks can be set according to specific requirements. The alternative frameworks can include JDBC, Hibernate, Mybatis, etc. The developer can select different target frameworks according to actual business requirements. The system parses the execution instruction according to the target framework and determines the target data source.
[0109] When responding to the execution instruction, the data information obtained from the target data source is assembled according to the target framework to generate a return result. Specifically, the data information corresponding to the execution instruction is obtained from the target data source; the return result corresponding to the data information is generated according to the target framework; and the return result is sent.
[0110] Figure 3 is a flowchart of an instruction response method provided by the third embodiment of the present application. The method is applied to a target service, the target service is configured with a view data source and a master data source, as shown in Figure 3 The method includes the following steps.
[0111] Step 301: Determine the external data table required by the target service. The external data table is a data table in the database corresponding to other services.
[0112] Step 302: Create a mapping view corresponding to the external data table in the view data source.
[0113] Step 303: Obtain external table change information.
[0114] Step 304: Generate a view editing instruction corresponding to the external table change information.
[0115] The view editing instruction includes at least one of the following: a view creation instruction, a view deletion instruction, and a view modification instruction.
[0116] The external table change information can be caused by external table change or business requirement change. For example, the business requirement changes, and the target service needs to obtain data in a new external table to provide corresponding business services. The view editing instruction is a view creation instruction for the new external table to increase the corresponding mapping view of the new external table in the view data source.
[0117] For another example, the table structure of the external table changes, and the view editing instruction is a view modification instruction for the external table to cause the structure of the mapping view corresponding to the external table in the view data source to change accordingly.
[0118] Step 305: In the view data source, execute the view editing command.
[0119] Step 306: Receive the execution instruction for the target service, and determine the target data source corresponding to the execution instruction from the view data source and the main data source.
[0120] Step 307: Utilize the target data source to respond to the execution command.
[0121] Since external tables and business requirements can change, view editing instructions are generated to correspond to the changes in external tables and business requirements. These instructions are then used to adjust the mapped views in the view data source in a timely manner, thereby reducing the adverse effects of changes in external tables or business requirements.
[0122] Figure 4 This is a schematic diagram of a microservice architecture provided in the fourth embodiment of the present invention. Figure 4 As shown: User Service, Reporting Service, and Product Service are all microservices within the same system. User Service corresponds to the database (userdb), Reporting Service to the database (rptdb), and Product Service to the database (pmsdb). User Service and Product Service do not require cross-database query operations. Interfaces requiring cross-database queries are integrated into the Reporting Service, which then performs cross-database query operations.
[0123] To ensure data scalability and ease of development, the reporting service integrates three frameworks: JDBC, Hibernate, and Mybatis. Developers can choose different query schemes based on their actual business needs.
[0124] The core of the reporting service lies in solving the problem of cross-database queries. Based on a table-view query scheme, two data sources are configured for the database (rptdb): a primary data source and a view data source. Unlike the traditional approach where a microservice switches back and forth between data sources for database and table queries, all data in the reporting service comes from the same database (rptdb). The reporting service primarily achieves the purpose of obtaining different data by pre-creating views.
[0125] Main data source (rptDataSource): This data source is mainly used to store relevant data generated internally by the reporting service, such as data from daily batch reporting.
[0126] View Data Source (rptViewDataSource): This data source is used to store mapped views created in the database (rptdb). It maps external data tables from other microservices to mapped views in the reporting service's corresponding database (rptdb), thereby resolving cross-database query issues.
[0127] In order to separate two data sources and define the responsibilities of the two, two independent users are created for the two data source distributions, and the permissions are as follows:
[0128] The main user (rptUser) is mainly used for managing data in the main data source and has all permissions of the database (rptdb).
[0129] The view user (rptViewUser) is mainly used for managing data in the view data source and has query permissions of the databases of other microservices and all permissions of the database (rptdb).
[0130] As shown by the dashed arrow in Figure 4 In order to maintain the integrity of the view, the view is initialized each time the deployment is performed, and for this purpose, an initialization stored procedure is established, which is used to complete the creation of the mapping view of the external table. The initialization stored procedure is mainly completed by the view user, and since the view user has query permissions of the databases of other microservices and all permissions of the database (rptdb), the corresponding mapping view of the external table can be created in the database (rptdb). According to the business requirements, the technical personnel can increase or decrease the mapping view as needed to avoid the phenomenon of data redundancy.
[0131] The scheme of the embodiment of the application realizes the cross-database join table query operation under the microservice framework at a small cost, and does not cause the problem of data consistency, reduces the call between services, and reduces the memory consumption and network consumption. In addition, three different data frameworks, JDBC, Hibernate and Mybatis, are integrated, and in actual use, different schemes can be selected according to specific business scenarios, which provides great convenience for developers. In addition, some condition restrictions of the traditional table view query scheme are avoided, such as the database account password must be the same, and the problem of cross-database query is solved by establishing a dedicated user and a data source, and the logical level is more clear. In addition, the scheme of the embodiment of the application can solve the cross-database query problem without middleware, avoids the additional learning cost required by using middleware, and enables the project to be quickly developed and iterated.
[0132] Figure 5 is a structural schematic diagram of an instruction response device provided by an embodiment of the application, which is applied to a target service, the target service is configured with a view data source and a main data source, the main data source is used for storing internal data of the target service, as Figure 5 shown, the device comprises:
[0133] A table determination module 501 is configured to determine an external data table required by the target service, the external data table being a data table in a database of another service.
[0134] a view creating module 502, configured to create a mapping view corresponding to the external data table in the view data source;
[0135] a data source determining module 503, configured to receive an execution instruction for the target service, and determine a target data source corresponding to the execution instruction from the view data source and the main data source;
[0136] a response module 504, configured to respond to the execution instruction by using the target data source.
[0137] Optionally, the data source determining module 503 is specifically configured to:
[0138] determine a type of the execution instruction;
[0139] in a case where the type of the execution instruction is a cross-database operation instruction, determine that the view data source is the target data source;
[0140] in a case where the type of the execution instruction is an internal operation instruction, determine that the main data source is the target data source.
[0141] Optionally, the data source determining module 503 is further configured to:
[0142] determine whether the execution instruction involves an external data table of the target service;
[0143] in a case where the execution instruction involves the external data table of the target service, determine that the type of the execution instruction is the cross-database operation instruction;
[0144] in a case where the execution instruction does not involve the external data table of the target service, determine that the type of the execution instruction is the internal operation instruction.
[0145] Optionally, the method further comprises:
[0146] a user creating module 505, configured to determine an external database corresponding to the target service, the external database being a database to which the external data table belongs;
[0147] create a view user, and assign query permission of the external database, query editing permission of the view data source, and query permission of the main data source to the view user;
[0148] the view creating module 502 is specifically configured to:
[0149] create, by using the view user, a mapping view corresponding to the external data table in the view data source.
[0150] Optionally, the response module 504 is specifically configured to:
[0151] In a case where the target data source is the view data source, the view user is used to call data in the view data source, and the execution instruction is responded.
[0152] Optionally, the user creation module 505 is further used for:
[0153] creating a master user, and assigning the master user with query permission of the view data source and query editing permission of the master data source;
[0154] The response module 504 is specifically used for:
[0155] In a case where the target data source is the master data source, the master user is used to call data in the master data source, and the execution instruction is responded.
[0156] Optionally, the target service integrates a plurality of alternative frameworks;
[0157] The data source determination module 503 is specifically used for:
[0158] determining a target framework corresponding to the execution instruction from the plurality of alternative frameworks;
[0159] parsing the execution instruction according to the target framework;
[0160] determining the target data source according to a parsing result of the execution instruction.
[0161] Optionally, the response module 504 is specifically used for:
[0162] obtaining data information corresponding to the execution instruction from the target data source;
[0163] generating a return result corresponding to the data information according to the target framework;
[0164] sending the return result.
[0165] Optionally, the apparatus further includes:
[0166] a view editing module 506, configured to obtain external table change information;
[0167] generate a view editing instruction corresponding to the external table change information, the view editing instruction including at least one of a view creation instruction, a view deletion instruction and a view modification instruction;
[0168] execute the view editing instruction in the view data source.
[0169] An electronic device is provided in the embodiment of the application, and the electronic device includes:
[0170] one or more processors;
[0171] a storage device for storing one or more programs,
[0172] When the one or more programs are executed by the one or more processors, the one or more processors implement the methods of any of the above embodiments.
[0173] An embodiment of the present application provides a computer program product comprising a computer program which, when executed by a processor, implements the enterprise risk assessment method in an embodiment of the present application.
[0174] Reference is made below to Figure 6 which shows a structural schematic diagram of a computer system 600 suitable for realizing a terminal device of an embodiment of the present application. Figure 6 The terminal device shown is merely an example and should not bring any limitation to the functions and use range of the embodiments of the present application.
[0175] As shown in Figure 6 , the computer system 600 comprises a central processing unit (CPU) 601 which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or programs loaded from a storage portion 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the system 600 are also stored in the RAM 603. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0176] The following components are connected to the I / O interface 605: an input portion 606 comprising a keyboard, a mouse, and the like; an output portion 607 comprising a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), and the like, and a speaker, and the like; a storage portion 608 comprising a hard disk, and the like; and a communication portion 609 comprising a network interface card such as a LAN card, a modem, and the like. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as necessary. A removable recording medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like is attached to the drive 610 as necessary, so that a computer program read therefrom is installed in the storage portion 608 as necessary.
[0177] In particular, the processes described above with reference to the flow charts can be implemented as a computer software program in accordance with the embodiments disclosed herein. For example, embodiments disclosed herein include a computer program product which includes a computer program tangibly embodied on a computer readable medium, the computer program including program code for executing the methods illustrated by the flow charts. In such embodiments, the computer program can be downloaded and installed from a network via the communication portion 609 and / or installed from the removable media 611. When the computer program is executed by the central processing unit (CPU) 601, the above-described functions defined in the system of the present application are executed.
[0178] It should be noted that the computer readable medium shown in the present application can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present application, the computer readable signal medium can include a data signal carried in a baseband or as a carrier wave in a propagated data signal, in which the computer readable program code is carried. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable medium that can send, propagate or transfer a program for use by or in connection with an instruction execution system, device or apparatus. The program code contained on the computer readable medium can be transmitted using any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0179] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0180] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be located in a processor, and for example, can be described as: a table determination module, a view creation module, a data source determination module, and a response module. The names of these modules do not necessarily limit the module itself; for example, the table determination module can also be described as "a module that determines the external data tables required by the target service, wherein the external data tables are data tables in the database corresponding to other services."
[0181] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to include:
[0182] Identify the external data tables required by the target service, where the external data tables are data tables in the databases corresponding to other services;
[0183] Create a mapped view corresponding to the external data table in the view data source;
[0184] Receive an execution instruction for the target service, and determine the target data source corresponding to the execution instruction from the view data source and the main data source;
[0185] The execution command is responded to using the target data source.
[0186] According to the technical scheme of the embodiment of the present application, the target service is configured with a view data source and a main data source. A mapping view corresponding to an external data table required by the target service is created in the view data source. When an execution instruction is received, the target data source corresponding to the execution instruction is determined from the view data source and the main data source, and the target data source is used to respond to the execution instruction.
[0187] If the instruction type is a cross-database operation instruction, the view data source is determined as the target data source. The mapping view in the view data source can be used to simply and efficiently implement cross-database join operation. The scheme of the embodiment of the present application does not need to establish a synchronization mechanism, does not introduce additional middleware, and does not need to change the original processing logic of each service. Therefore, the operation steps of cross-database query can be simplified and have high performance.
[0188] The above specific embodiments do not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. An instruction response method, characterized by, The application is applied to a target service, the target service is configured with a view data source and a main data source, the main data source is used for storing internal data of the target service, and the internal data comprises: An external data table required by the target service is determined, the external data table is a data table in a database corresponding to other services, wherein the same system is split into different services according to business functions, each service corresponds to a different database, and each service and the database corresponding to each service are independent of each other; A mapping view corresponding to the external data table is created in the view data source, wherein the mapping view is a virtual table of the external table in the view data source, and data in the mapping view comes from a table referenced when the mapping view is defined; An execution instruction for the target service is received, and a target data source corresponding to the execution instruction is determined from the view data source and the main data source, comprising: the target service integrates a plurality of alternative frameworks; the target framework corresponding to the execution instruction is determined from the plurality of alternative frameworks; the execution instruction is parsed according to the target framework; and the target data source is determined according to the parsing result of the execution instruction; A main user is created, and query permission of the view data source and query and edit permission of the main data source are given to the main user; and the target data source is used to respond to the execution instruction, comprising: in the case that the target data source is the main data source, data in the main data source is called by using the main user to respond to the execution instruction.
2. The method of claim 1, wherein, The target data source corresponding to the execution instruction is determined from the view data source and the main data source, comprising: The instruction type of the execution instruction is determined; In the case that the instruction type is a cross-database operation instruction, the view data source is determined as the target data source; In the case that the instruction type is an internal operation instruction, the main data source is determined as the target data source.
3. The method of claim 2, wherein, The instruction type of the execution instruction is determined, comprising: It is determined whether the execution instruction involves the external data table of the target service; In the case that the execution instruction involves the external data table of the target service, the instruction type is determined as a cross-database operation instruction; In the case that the execution instruction does not involve the external data table of the target service, the instruction type is determined as an internal operation instruction.
4. The method of claim 1, wherein, Before the mapping view corresponding to the external data table is created in the view data source, the following steps are further included: An external database corresponding to the target service is determined, the external database is a database to which the external data table belongs; A view user is created, and query permission of the external database, query and edit permission of the view data source and query permission of the main data source are given to the view user; The mapping view corresponding to the external data table is created in the view data source, comprising: The mapping view corresponding to the external data table is created in the view data source by using the view user.
5. The method of claim 1, wherein, The target data source is used to respond to the execution instruction, comprising: In a case where the target data source is the view data source, data in the view data source is invoked by using the view user to respond to the execution instruction.
6. The method of claim 1, wherein, The responding to the execution instruction by using the target data source comprises: obtaining data information corresponding to the execution instruction from the target data source; generating a return result corresponding to the data information according to the target framework; and sending the return result.
7. The method of claim 1, wherein, After the mapping view corresponding to the external data table is created in the view data source, the method further comprises: obtaining external table change information; generating a view editing instruction corresponding to the external table change information, the view editing instruction comprising at least one of a view creation instruction, a view deletion instruction and a view modification instruction; and executing the view editing instruction in the view data source.
8. An instruction responding apparatus characterized by comprising: The target service is configured with a view data source and a main data source, and the main data source is used to store internal data of the target service, and the method comprises: a table determination module configured to determine an external data table required by the target service, the external data table being a data table in a database corresponding to another service; wherein the same system is split into different services according to business functions, each service corresponding to a different database, and each service and each database corresponding to the service are independent of each other; a view creation module configured to create a mapping view corresponding to the external data table in the view data source; wherein the mapping view is a virtual table of the external table in the view data source, and data in the mapping view comes from a table referenced when the mapping view is defined; a data source determination module configured to receive an execution instruction for the target service, and determine a target data source corresponding to the execution instruction from the view data source and the main data source, comprising: the target service integrates a plurality of alternative frameworks; a target framework corresponding to the execution instruction is determined from the plurality of alternative frameworks; the execution instruction is parsed according to the target framework; and the target data source is determined according to the parsing result of the execution instruction; a response module configured to create a main user, and give the main user query permissions of the view data source and query and edit permissions of the main data source; and the responding to the execution instruction by using the target data source comprises: in a case where the target data source is the main data source, data in the main data source is invoked by using the main user to respond to the execution instruction.
9. The apparatus of claim 8, wherein, The data source determination module is specifically configured to: determine a type of the execution instruction; in a case where the type of the execution instruction is a cross-database operation instruction, determine that the view data source is the target data source; in a case where the type of the execution instruction is an internal operation instruction, determine that the main data source is the target data source.
10. The apparatus of claim 9, wherein, The data source determination module is further configured to: determine whether the execution instruction involves an external data table of the target service; in a case where the execution instruction involves the external data table of the target service, determine that the type of the execution instruction is the cross-database operation instruction; in a case where the execution instruction does not involve the external data table of the target service, determine that the type of the execution instruction is the internal operation instruction.
11. An electronic device, comprising: comprising: one or more processors; a memory device for storing one or more programs, when the one or more programs are executed by the one or more processors, cause the one or more processors to carry out the method of any one of claims 1-7.
12. A computer readable medium having stored thereon a computer program, characterized in that the program, when executed by a processor, causes the method of any one of claims 1-7 to be carried out.
13. A computer program product comprising a computer program, characterized in that, the program, when executed by a processor, causes the method of any one of claims 1-7 to be carried out.
Citation Information
Patent Citations
Multilayer analysis method of structured query statement, computer equipment and storage medium
CN114756569A