Data query method and device, electronic equipment and storage medium
By maintaining the second mapping relationship between the search field and the searched primary key data in a non-relational database, and maintaining the first mapping relationship between the searched primary key data and the searched data in a relational database, the relationship type is solved The problem of the bottleneck of database query efficiency achieves efficient and accurate data query.
Patent Information
- Application Number
- CN202411628353.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-07
AI Technical Summary
As the data volume increases, there is a bottleneck in querying information retrieval based on a relational database.
By maintaining the second mapping relationship between the search field and the searched primary key data in a non-relational database, and maintaining the first mapping relationship between the searched primary key data and the searched data in a relational database, the data query is realized Efficiency.
Improve the database data query efficiency and data query accuracy, and avoid loss or inaccuracy caused by data conversion.
Smart Images

Figure CN119396858A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a data query method, device, electronic equipment and storage medium. Background Art
[0002] In the process of information processing, database and information query are two important technical fields. Among them, database technology mainly organizes, stores and manages data by establishing a database to facilitate efficient data query and update. Information query technology refers to finding the required information quickly and accurately from a large amount of unstructured data.
[0003] As known from the related art, currently relational databases are often used for data storage, and information retrieval and query are performed based on relational databases. However, as the volume of data increases, information retrieval and query based on relational databases will encounter query efficiency bottlenecks.
[0004] Therefore, how to improve the efficiency of database data query has become a current research hotspot. Summary of the invention
[0005] The present invention provides a data query method, device, electronic equipment and storage medium, which can improve the data query efficiency and data query accuracy of a database.
[0006] The present invention provides a data query method, which includes: obtaining a query instruction, wherein the query instruction includes a target search field for data query; based on the target search field, determining target searched primary key data corresponding to the target search field; calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different searched primary key data and different searched data; based on the target searched primary key data and the first mapping relationship, querying in the relational database to obtain the searched data corresponding to the query instruction.
[0007] According to a data query method provided by the present invention, before determining the target retrieved primary key data corresponding to the target retrieval field based on the target retrieval field, the method also includes: calling a pre-maintained non-relational database, wherein the non-relational database includes a second mapping relationship between different retrieval fields and different retrieved primary key data; determining the target retrieved primary key data corresponding to the target retrieval field based on the target retrieval field specifically includes: based on the target retrieval field and the second mapping relationship, querying in the non-relational database to obtain the target retrieved primary key data corresponding to the target retrieval field.
[0008] According to a data query method provided by the present invention, the second mapping relationship in the non-relational database is maintained in the following manner: according to the retrieved data that has undergone incremental changes in the relational database, the search field in the non-relational database is correspondingly incrementally processed to obtain an incremental search field; based on the incremental search field and incremental retrieved primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the incremental retrieved primary key data corresponds to the retrieved data that has undergone incremental changes in the relational database.
[0009] According to a data query method provided by the present invention, the search fields in the non-relational database are correspondingly incrementally processed according to the retrieved data that has undergone incremental changes in the relational database to obtain incremental search fields, which specifically includes: when the retrieved data that has undergone incremental changes is existing data in the relational database, the search fields in the non-relational database are fully incrementally processed according to the retrieved data that has undergone incremental changes in the relational database to obtain incremental search fields.
[0010] According to a data query method provided by the present invention, the search field in the non-relational database is correspondingly incrementally processed according to the retrieved data that has undergone incremental changes in the relational database to obtain the incremental search field, which specifically includes: when the retrieved data that has undergone incremental changes is incremental data in the relational database, the search field in the non-relational database is periodically incrementally processed according to the retrieved data that has undergone incremental changes in the relational database to obtain the incremental search field.
[0011] According to a data query method provided by the present invention, the second mapping relationship in the non-relational database is maintained in the following manner: according to the retrieved data that has undergone data changes in the relational database, the search field in the non-relational database is correspondingly changed to obtain a changed search field; based on the changed search field and the changed retrieved primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the changed retrieved primary key data corresponds to the retrieved data that has undergone data changes in the relational database.
[0012] According to a data query method provided by the present invention, the first mapping relationship includes a correspondence between retrieved primary key data and various attribute information data of the retrieved data; the querying in the relational database based on the target retrieved primary key data and the first mapping relationship to obtain the retrieved data corresponding to the query instruction specifically includes: querying in the relational database based on the target retrieved primary key data and the first mapping relationship to obtain various attribute information data of the retrieved data corresponding to the query instruction.
[0013] The present invention also provides a data query device, which includes: an acquisition module, used to acquire a query instruction, wherein the query instruction includes a target retrieval field for performing data query; a determination module, used to determine, based on the target retrieval field, target retrieved primary key data corresponding to the target retrieval field; a calling module, used to call a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different retrieved primary key data and different retrieved data; and a query module, used to query the relational database based on the target retrieved primary key data and the first mapping relationship to obtain the retrieved data corresponding to the query instruction.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned data query methods when executing the computer program.
[0015] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the data query method described above is implemented.
[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned data query methods.
[0017] The data query method, device, electronic device and storage medium provided by the present invention obtain a query instruction, wherein the query instruction includes a target search field for data query; based on the target search field, determining the target searched primary key data corresponding to the target search field; calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different searched primary key data and different searched data; based on the target searched primary key data and the first mapping relationship, querying in the relational database to obtain the searched data corresponding to the query instruction. Since the search query is not directly performed in the relational database, but the target searched primary key data corresponding to the target search field is first determined, and then the searched data corresponding to the target searched primary key data is queried in the relational database, the data query efficiency and data query accuracy of the database can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 This is one of the flow charts of the data query method provided by the present invention.
[0020] Figure 2 This is the second flow chart of the data query method provided by the present invention.
[0021] Figure 3 It is a schematic diagram of a flow chart of maintaining a second mapping relationship in a non-relational database provided by the present invention.
[0022] Figure 4 It is a structural schematic diagram of the data query device provided by the present invention.
[0023] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] In the data query method provided by the present invention, the master data (corresponding to the retrieved data) is stored in a relational database, such as a MySQL database, while the copy data (corresponding to the retrieval field and the retrieved primary key data) is stored in a non-relational database, such as Elasticsearch. Since the copy data is not the complete master data, for example, in a record, the master data has 10 fields, but the copy only stores the retrieval fields (for example, 2) + the master data primary key, through this combination, real-time, accurate and fast data search is achieved, thereby improving data retrieval efficiency and avoiding data loss or inaccuracy that may be caused by data conversion between different databases. Compared with the prior art, this solution can restore data attributes more accurately and completely, improving the accuracy and reliability of the data.
[0026] Figure 1 This is one of the flow charts of the data query method provided by the present invention.
[0027] The following will be combined Figure 1 The process of the data query method provided by the present invention is described.
[0028] In an exemplary embodiment of the present invention, Figure 1 It can be seen that the data query method may include steps 110 to 140, and each step will be introduced below.
[0029] In step 110, a query instruction is obtained, wherein the query instruction includes a target search field for data query.
[0030] In step 120, based on the target search field, target searched primary key data corresponding to the target search field is determined.
[0031] In one embodiment, a query instruction may be obtained. In one example, the query instruction may be an instruction issued by a user. The query instruction may include a target search field for data query. In the application process, the target search field may include one or two. In this embodiment, the number of target search fields is not specifically limited.
[0032] In another embodiment, the target searched primary key data corresponding to the target search field can be determined according to the target search field included in the query instruction. The primary key data can be one or more fields in a table, and its value is used to uniquely identify a record in the table. It can be understood that the target searched primary key data can identify the searched data.
[0033] In step 130, a pre-maintained relational database is called, wherein the relational database includes a first mapping relationship between different retrieved primary key data and different retrieved data.
[0034] In step 140, based on the target primary key data to be retrieved and the first mapping relationship, the retrieved data corresponding to the query instruction is queried in the relational database.
[0035] In one embodiment, a pre-maintained relational database may be called, wherein the relational database may be a MySQL database. Since the relational database includes a first mapping relationship between different retrieved primary key data and different retrieved data. Therefore, based on the target retrieved primary key data and the first mapping relationship, the retrieved data corresponding to the retrieved primary key data can be queried in the relational database, that is, the retrieved data corresponding to the query instruction can be queried. In this embodiment, since the retrieval query is not directly performed in the relational database, but the target retrieved primary key data corresponding to the target retrieval field is first determined, and then the retrieved data corresponding to the target retrieved primary key data is queried in the relational database, the data query efficiency and data query accuracy of the database can be improved.
[0036] In another exemplary embodiment of the present invention, the first mapping relationship may further include a correspondence between the retrieved primary key data and each attribute information data of the retrieved data; Wherein, based on the target retrieved primary key data and the first mapping relationship, querying in the relational database to obtain the retrieved data corresponding to the query instruction can be implemented in the following manner: Based on the target retrieved primary key data and the first mapping relationship, each attribute information data of the retrieved data corresponding to the query instruction is queried in the relational database.
[0037] In this embodiment, based on the target retrieved primary key data and the first mapping relationship, attribute information data of various attributes corresponding to the retrieved data can be obtained, thereby ensuring the comprehensiveness of the retrieved data obtained by the query.
[0038] The data query method provided by the present invention obtains a query instruction, wherein the query instruction includes a target search field for data query; based on the target search field, determining the target searched primary key data corresponding to the target search field; calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different searched primary key data and different searched data; based on the target searched primary key data and the first mapping relationship, querying in the relational database to obtain the searched data corresponding to the query instruction. Since the search query is not directly performed in the relational database, but the target searched primary key data corresponding to the target search field is first determined, and then the searched data corresponding to the target searched primary key data is queried in the relational database, the data query efficiency and data query accuracy of the database can be improved.
[0039] Figure 2 This is the second flow chart of the data query method provided by the present invention.
[0040] The following will be combined Figure 2 The process of another data query method is described.
[0041] In an exemplary embodiment of the present invention, Figure 2 It can be seen that the data query method may include steps 210 to 250, wherein step 210 is the same as or similar to step 110, and steps 240 to 250 are the same as or similar to steps 130 to 140, respectively. For specific implementation methods and beneficial effects, please refer to the previous description, which will not be repeated in this embodiment. Step 220 and step 230 will be introduced below respectively.
[0042] In step 220, a pre-maintained non-relational database is called, wherein the non-relational database includes a second mapping relationship between different search fields and different searched primary key data.
[0043] In step 230, based on the target search field and the second mapping relationship, the target searched primary key data corresponding to the target search field is queried in the non-relational database.
[0044] In one embodiment, the second mapping relationship between different search fields and different retrieved primary key data can be maintained in a non-relational database in advance, such as an Elasticsearch database. Furthermore, based on the target search field and the second mapping relationship in the non-relational database, the target retrieved primary key data corresponding to the target search field is queried in the non-relational database. In this embodiment, by storing the second mapping relationship in the Elasticsearch database, the primary key and other data (corresponding to the target retrieved primary key data) are found according to the Elasticsearch database through complex conditions when querying data, thereby improving the query performance. Compared with the prior art of directly querying data in a relational database, the query speed of Elasticsearch is relatively fast, which can effectively improve the query efficiency of the system.
[0045] In addition, in the present invention, the fields used for complex queries are stored in Elasticsearch, and the query results are restored from MySQL through data such as primary keys. Data conversion between non-relational databases and relational databases is avoided, thereby reducing the possibility of data loss or inaccuracy. This approach not only saves storage space, but also alleviates the problem of insufficient memory or insufficient computing resources that Elasticsearch may face, thereby improving the stability and reliability of the system. Compared with the prior art, this technical solution can restore data attributes more accurately and completely, improving the accuracy and reliability of data.
[0046] Furthermore, other field attributes required for the query result record are retrieved from the MySQL database through the primary key index, which avoids pushing too much data to the Elasticsearch database and improves the portability of the Elasticsearch database.
[0047] Figure 3 It is a schematic diagram of a flow chart of maintaining a second mapping relationship in a non-relational database provided by the present invention.
[0048] The following will be combined Figure 3 The process of maintaining the second mapping relationship in the non-relational database is described.
[0049] In an exemplary embodiment of the present invention, Figure 3 It can be known that maintaining the second mapping relationship in the non-relational database may include step 310 and step 320, and each step will be introduced below.
[0050] In step 310, according to the incrementally changed retrieved data in the relational database, the retrieval fields in the non-relational database are incrementally processed accordingly to obtain incremental retrieval fields.
[0051] In step 320, the second mapping relationship in the non-relational database is updated and maintained based on the incremental search field and the incremental searched primary key data, wherein the incremental searched primary key data corresponds to the searched data with incremental changes in the relational database.
[0052] It should be noted that the update status of the second mapping relationship in the non-relational database is determined according to the update or change status of the retrieved data in the relational database, thereby effectively ensuring that by storing the second mapping relationship in the Elasticsearch database, the primary key and other data (corresponding to the target retrieved primary key data) are found out from the Elasticsearch database through complex conditions when querying data, and the retrieved data corresponding to the target retrieved primary key data is further queried from the relational database, thereby improving the query performance.
[0053] In another embodiment, when the retrieved data in the relational database undergoes incremental changes, the search field in the non-relational database can be incrementally processed accordingly based on the retrieved data that undergoes incremental changes in the relational database, thereby obtaining the incremental search field; further, based on the incremental search field and the incremental retrieved primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the incremental retrieved primary key data corresponds to the retrieved data that undergoes incremental changes in the relational database. Through this embodiment, it can be achieved that the non-relational database is always matched with the relational database, so that the target retrieved primary key data corresponding to the target search field can be determined from the non-relational database, and then the retrieved data corresponding to the target retrieved primary key data can be queried from the relational database, thereby achieving the ability to improve the data query efficiency and data query accuracy of the database.
[0054] In yet another exemplary embodiment of the present invention, Figure 3 The above embodiment is used as an example to illustrate that, according to the incrementally changed searched data in the relational database, the search field in the non-relational database is processed incrementally to obtain the incremental search field, which can be implemented in the following manner: In the case where the retrieved data that has undergone incremental changes is stock data in a relational database, the retrieval fields in the non-relational database are fully incrementally processed based on the retrieved data that has undergone incremental changes in the relational database to obtain incremental retrieval fields.
[0055] In one embodiment, when the retrieved data that has undergone incremental changes is stock data in a relational database, that is, when the retrieved data that has undergone incremental changes is stock data that already exists in the relational database, the search fields in the non-relational database can be incrementally processed in full at one time based on the retrieved data that has undergone incremental changes in the relational database, so that all incremental search fields can be obtained, that is, all incremental search fields can be obtained after one full processing, thereby quickly implementing the update processing of the second mapping relationship in the non-relational database.
[0056] In yet another exemplary embodiment of the present invention, Figure 3 The above embodiment is used as an example to illustrate that, according to the incrementally changed searched data in the relational database, the search field in the non-relational database is processed incrementally to obtain the incremental search field, which can be implemented in the following manner: When the searched data with incremental changes is incremental data in a relational database, the search field in the non-relational database is incrementally processed periodically according to the searched data with incremental changes in the relational database to obtain an incremental search field.
[0057] In one embodiment, when the retrieved data that undergoes incremental changes is incremental data in a relational database, that is, when the retrieved data that undergoes incremental changes is incremental data that is added at any time, the retrieval fields in the non-relational database can be incrementally processed on a regular basis according to the retrieved data that undergoes incremental changes in the relational database to obtain incremental retrieval fields. Since the retrieved data that undergoes incremental changes is added at any time, in this embodiment, the retrieval fields in the non-relational database are incrementally processed on a regular basis according to the retrieved data that undergoes incremental changes in the relational database, which can ensure that no incremental retrieval fields are missed, thereby ensuring the comprehensiveness of the update of the second mapping relationship in the non-relational database.
[0058] In another exemplary embodiment of the present invention, the second mapping relationship in the non-relational database can be maintained in the following manner: According to the searched data that has been changed in the relational database, the search fields in the non-relational database are correspondingly changed to obtain the changed search fields; Based on the changed search field and the changed searched primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the changed searched primary key data corresponds to the searched data with data changes in the relational database.
[0059] In one embodiment, when the retrieved data in the relational database is changed, the search field in the non-relational database can be changed accordingly according to the retrieved data that has changed in the relational database to obtain the changed search field; further, based on the changed search field and the changed retrieved primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the changed retrieved primary key data corresponds to the retrieved data that has changed in the relational database. Through this embodiment, it can be ensured that the second mapping relationship in the non-relational database always matches the retrieved data or the first mapping relationship in the relational database.
[0060] In another embodiment, since the Elasticsearch database has a certain delay relative to the Mysql database, that is, the Elasticsearch database changes according to the changes in the Mysql database, during the application process, the data that changes in the Mysql database in real time (corresponding to the data changes in the retrieved data) can be pushed to the Elasticsearch database through binlog triggering, so that the Elasticsearch database updates and maintains the second mapping relationship in the non-relational database based on the changed search field and the changed retrieved primary key data.
[0061] It can be understood that the present invention stores data through the Elasticsearch database, and when querying data, the primary key and other data are found according to the Elasticsearch database through complex conditions, thereby reducing the dependence on relational databases such as MySQL databases and reducing the demand for memory and computing resources. Compared with the prior art, the present invention can more effectively utilize system resources and improve the stability and reliability of the system.
[0062] According to the foregoing analysis, the data query method provided by the present invention obtains a query instruction, wherein the query instruction includes a target search field for data query; based on the target search field, determining the target searched primary key data corresponding to the target search field; calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different searched primary key data and different searched data; based on the target searched primary key data and the first mapping relationship, querying in the relational database to obtain the searched data corresponding to the query instruction. Since the search query is not directly performed in the relational database, but the target searched primary key data corresponding to the target search field is first determined, and then the searched data corresponding to the target searched primary key data is queried in the relational database, the data query efficiency and data query accuracy of the database can be improved.
[0063] The data query device provided by the present invention is described below. The data query device described below and the data query method described above can be referenced to each other.
[0064] Figure 4 It is a structural schematic diagram of the data query device provided by the present invention.
[0065] The following will be combined Figure 4 The structure of the data query device provided by the present invention is described.
[0066] In an exemplary embodiment of the present invention, Figure 4It can be known that the data query device may include an acquisition module 410, a determination module 420, a call module 430, and a query module 440, and each module will be introduced below.
[0067] The acquisition module 410 may be configured to acquire a query instruction, wherein the query instruction includes a target search field for performing a data query; The determination module 420 may be configured to determine, based on the target search field, target searched primary key data corresponding to the target search field; The calling module 430 may be configured to call a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different retrieved primary key data and different retrieved data; The query module 440 may be configured to query the relational database to obtain the retrieved data corresponding to the query instruction based on the target retrieved primary key data and the first mapping relationship.
[0068] In an exemplary embodiment of the present invention, the determination module 420 may also be configured to: Calling a pre-maintained non-relational database, wherein the non-relational database includes a second mapping relationship between different search fields and different searched primary key data; The determination module 420 may determine the target searched primary key data corresponding to the target search field based on the target search field in the following manner: Based on the target search field and the second mapping relationship, the target searched primary key data corresponding to the target search field is queried in the non-relational database.
[0069] In an exemplary embodiment of the present invention, the determination module 420 may implement the maintenance of the second mapping relationship in the non-relational database in the following manner: According to the searched data that has undergone incremental changes in the relational database, corresponding incremental processing is performed on the search field in the non-relational database to obtain an incremental search field; Based on the incremental search field and the incremental searched primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the incremental searched primary key data corresponds to the searched data that has undergone incremental changes in the relational database.
[0070] In an exemplary embodiment of the present invention, the determination module 420 may implement the following method to perform corresponding incremental processing on the search field in the non-relational database according to the searched data that has undergone incremental changes in the relational database to obtain the incremental search field: In the case where the retrieved data that has undergone incremental changes is stock data in the relational database, the search fields in the non-relational database are fully incrementally processed based on the retrieved data that has undergone incremental changes in the relational database to obtain incremental search fields.
[0071] In an exemplary embodiment of the present invention, the determination module 420 may implement the following method to perform corresponding incremental processing on the search field in the non-relational database according to the searched data that has undergone incremental changes in the relational database to obtain the incremental search field: In the case that the retrieved data that undergoes incremental changes is incremental data in the relational database, the search field in the non-relational database is incrementally processed periodically according to the retrieved data that undergoes incremental changes in the relational database to obtain an incremental search field.
[0072] In an exemplary embodiment of the present invention, the determination module 420 may implement the maintenance of the second mapping relationship in the non-relational database in the following manner: According to the searched data that has been changed in the relational database, a corresponding change process is performed on the search field in the non-relational database to obtain a changed search field; Based on the changed search field and the changed searched primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the changed searched primary key data corresponds to the searched data in the relational database where the data change occurs.
[0073] In an exemplary embodiment of the present invention, the first mapping relationship includes a correspondence between the retrieved primary key data and each attribute information data of the retrieved data; The query module 440 may use the following method to query the relational database to obtain the retrieved data corresponding to the query instruction based on the target retrieved primary key data and the first mapping relationship: Based on the target retrieved primary key data and the first mapping relationship, each attribute information data of the retrieved data corresponding to the query instruction is queried in the relational database.
[0074] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the data query method, which includes: obtaining a query instruction, wherein the query instruction includes a target search field for data query; based on the target search field, determining the target searched primary key data corresponding to the target search field; calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different searched primary key data and different searched data; based on the target searched primary key data and the first mapping relationship, querying the relational database to obtain the searched data corresponding to the query instruction.
[0075] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0076] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the data query method provided by the above methods, the method including: obtaining a query instruction, wherein the query instruction includes a target retrieval field for data query; based on the target retrieval field, determining a target retrieved primary key data corresponding to the target retrieval field; calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different retrieved primary key data and different retrieved data; based on the target retrieved primary key data and the first mapping relationship, querying the relational database to obtain the retrieved data corresponding to the query instruction.
[0077] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the data query method provided by the above-mentioned methods, the method comprising: obtaining a query instruction, wherein the query instruction comprises a target retrieval field for data query; based on the target retrieval field, determining a target retrieved primary key data corresponding to the target retrieval field; calling a pre-maintained relational database, wherein the relational database comprises a first mapping relationship between different retrieved primary key data and different retrieved data; based on the target retrieved primary key data and the first mapping relationship, querying the relational database to obtain the retrieved data corresponding to the query instruction.
[0078] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0079] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0080] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data query method, characterized in that: The method comprises: Obtaining a query instruction, wherein the query instruction includes a target search field for data query; Based on the target search field, determining the target searched primary key data corresponding to the target search field; Calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different retrieved primary key data and different retrieved data; Based on the target retrieved primary key data and the first mapping relationship, the retrieved data corresponding to the query instruction is queried in the relational database.
2. The data query method according to claim 1, characterized in that: Before determining the target searched primary key data corresponding to the target search field based on the target search field, the method further includes: Calling a pre-maintained non-relational database, wherein the non-relational database includes a second mapping relationship between different search fields and different searched primary key data; The determining, based on the target search field, the target searched primary key data corresponding to the target search field specifically includes: Based on the target search field and the second mapping relationship, the target searched primary key data corresponding to the target search field is queried in the non-relational database.
3. The data query method according to claim 2, characterized in that: The second mapping relationship in the non-relational database is maintained in the following manner: According to the searched data that has undergone incremental changes in the relational database, corresponding incremental processing is performed on the search field in the non-relational database to obtain an incremental search field; Based on the incremental search field and the incremental searched primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the incremental searched primary key data corresponds to the searched data that has undergone incremental changes in the relational database.
4. The data query method according to claim 3, characterized in that: The step of performing corresponding incremental processing on the search field in the non-relational database according to the searched data that has undergone incremental changes in the relational database to obtain the incremental search field specifically includes: In the case where the retrieved data that has undergone incremental changes is stock data in the relational database, the search fields in the non-relational database are fully incrementally processed based on the retrieved data that has undergone incremental changes in the relational database to obtain incremental search fields.
5. The data query method according to claim 3, characterized in that: The step of performing corresponding incremental processing on the search field in the non-relational database according to the searched data that has undergone incremental changes in the relational database to obtain the incremental search field specifically includes: In the case that the retrieved data that undergoes incremental changes is incremental data in the relational database, the search field in the non-relational database is incrementally processed periodically according to the retrieved data that undergoes incremental changes in the relational database to obtain an incremental search field.
6. The data query method according to claim 2, characterized in that: The second mapping relationship in the non-relational database is maintained in the following manner: According to the searched data that has been changed in the relational database, a corresponding change process is performed on the search field in the non-relational database to obtain a changed search field; Based on the changed search field and the changed searched primary key data, the second mapping relationship in the non-relational database is updated and maintained, wherein the changed searched primary key data corresponds to the searched data in the relational database where the data change occurs.
7. The data query method according to any one of claims 1 to 6, characterized in that: The first mapping relationship includes a correspondence between the retrieved primary key data and each attribute information data of the retrieved data; The querying in the relational database to obtain the retrieved data corresponding to the query instruction based on the target retrieved primary key data and the first mapping relationship specifically includes: Based on the target retrieved primary key data and the first mapping relationship, each attribute information data of the retrieved data corresponding to the query instruction is queried in the relational database.
8. A data query device, characterized in that: The device comprises: An acquisition module, used for acquiring a query instruction, wherein the query instruction includes a target search field for data query; A determination module, configured to determine, based on the target search field, target searched primary key data corresponding to the target search field; A calling module, used for calling a pre-maintained relational database, wherein the relational database includes a first mapping relationship between different retrieved primary key data and different retrieved data; A query module is used to query the relational database to obtain the retrieved data corresponding to the query instruction based on the target retrieved primary key data and the first mapping relationship.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the data query method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data query method according to any one of claims 1 to 7 is implemented.