Query method and device of data, storage medium and electronic device
By expanding and filtering multiple data tables before data querying, the problem of low data query efficiency caused by Cartesian product is solved, and efficient data querying is achieved.
Patent Information
- Application Number
- CN202210297160.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-24
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2042-03-24
AI Technical Summary
In existing technologies, the Cartesian product data generated when using SQL for inequality joins is enormous, consuming a lot of system resources and resulting in low data query efficiency.
By receiving data query requests, multiple data tables are expanded into a third data table with filtering conditions based on reference data fields and target query conditions. Matching is performed before association, and only the successfully filtered data is associated, reducing the generation of Cartesian products.
It effectively reduces the Cartesian product, improves the efficiency of data query, and achieves a highly efficient data query process.
Smart Images

Figure CN114840557B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of smart home, in particular to a data query method and device, a storage medium and an electronic device. BACKGROUND
[0002] With the development of science and technology, big data has spread to every corner of social life. In many application scenarios, SQL (Structured Query Language) is used to associate data in multiple data tables with different values, and query the required data. However, in the prior art, the data amount of the Cartesian product generated by using SQL to associate data tables with different values is extremely large. As the data in the data tables increases, the problem of excessive Cartesian product becomes more and more prominent, which occupies too much system resources and causes great burden to the system for processing data, and the excessive Cartesian product reduces the query efficiency of data.
[0003] For the problem of low data query efficiency in the related art, an effective solution has not been proposed. SUMMARY
[0004] Embodiments of the present application provide a data query method and device, a storage medium and an electronic device to at least solve the problem of low data query efficiency in the related art.
[0005] According to an embodiment of the present application, a data query method is provided, comprising: receiving a data query request, wherein the data query request is used to request to query data in an associated data table between multiple data tables that meets a target query condition, and the target query condition is used to indicate a non-equality relationship between a query data field and a reference data field;
[0006] In response to the data query request, a first data table including the reference data field in the multiple data tables is expanded into a third data table according to the reference data field and the target query condition, wherein the third data table carries a screening condition used for pre-screening data;
[0007] According to a matching relationship between the query data field and the screening condition, a second data table and the third data table are associated to obtain a fourth data table, wherein the second data table is a data table including the query data field in the multiple data tables;
[0008] The data meeting the target query condition is queried from the fourth data table to obtain a target data table.
[0009] Optionally, the first data table including the reference data field in the plurality of data tables is expanded into a third data table according to the reference data field and the target query condition, including:
[0010] A target expansion field is added in the first data table according to the reference data field and the target query condition, and an expansion data table is obtained;
[0011] An expansion data value of the target expansion field corresponding to a reference data value of the reference data field is determined according to a relationship between the reference data value and the target expansion field, wherein the expansion data value of the target expansion field is used to indicate the screening condition;
[0012] The expansion data value is added to the expansion data table, and the third data table is obtained.
[0013] Optionally, the target expansion field is added in the first data table according to the reference data field and the target query condition, and an expansion data table is obtained, including:
[0014] The target expansion field is constructed according to the reference data field and the target query condition;
[0015] A data column corresponding to the target expansion field is added in the first data table, and the expansion data table is obtained.
[0016] Optionally, the second data table is associated with the third data table according to a matching relationship between a query data field and the screening condition, and a fourth data table is obtained, wherein the second data table is a data table including the query data field in the plurality of data tables, including:
[0017] Each query data value of the query data field in the second data table is matched with the screening condition in the third data table;
[0018] Each query data value of the query data field in the second data table is associated with data in which the screening condition in the third data table is matched successfully, and a fourth data table is obtained.
[0019] Optionally, the each query data value of the query data field in the second data table is matched with the screening condition in the third data table, including:
[0020] First data in the each query data value is compared with second data in each expansion data value of a target expansion field in the third data table, wherein the expansion data value of the target expansion field is used to indicate the screening condition;
[0021] In a case where the first data and the second data are consistent, it is determined that each query data value of the query data field in the second data table matches the filtering condition in the third data table successfully.
[0022] Optionally, the querying, from the fourth data table, of data satisfying the target query condition to obtain a target data table comprises:
[0023] The query data value of the query data field and the reference data value of the reference data field included in the fourth data table are obtained.
[0024] The data, in which the query data value and the reference data value do not satisfy the target query condition, is deleted from the fourth data table to obtain the target data table.
[0025] Optionally, the querying, from the fourth data table, of data satisfying the target query condition to obtain a target data table comprises:
[0026] The data, in which the query data value and the reference data value do not satisfy the target query condition, is deleted from the fourth data table to obtain a candidate data table.
[0027] The filtering condition is deleted from the candidate data table to obtain the target data table.
[0028] According to another embodiment of the embodiment of the application, a data query device is further provided, comprising:
[0029] A receiving module is configured to receive a data query request, wherein the data query request is used to request to query data satisfying a target query condition in an associated data table between a plurality of data tables, and the target query condition is used to indicate an inequality relationship between a query data field and a reference data field.
[0030] An expanding module is configured to, in response to the data query request, expand a first data table including the reference data field in the plurality of data tables into a third data table according to the reference data field and the target query condition, wherein the third data table carries a filtering condition used for pre-filtering data.
[0031] An associating module is configured to associate a second data table with the third data table according to a matching relationship between the query data field and the filtering condition to obtain a fourth data table, wherein the second data table is a data table including the query data field in the plurality of data tables.
[0032] A querying module is configured to query, from the fourth data table, data satisfying the target query condition to obtain a target data table.
[0033] According to a further aspect of the embodiments of the present application, a computer readable storage medium is also provided, which stores a computer program. The computer program is configured to perform the data query method when executed.
[0034] According to a further aspect of the embodiments of the present application, an electronic device is also provided, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor. The processor performs the data query method by executing the computer program.
[0035] In the embodiments of the present application, a data query request is received, wherein the data query request is used to request to query data of an associated data table between a plurality of data tables satisfying a target query condition, and the target query condition is used to indicate an inequality value relationship between a query data field and a reference data field. In response to the data query request, a first data table including the reference data field in the plurality of data tables is expanded into a third data table according to the reference data field and the target query condition, wherein the third data table carries a screening condition used for pre-screening data. A second data table is associated with the third data table according to a matching relationship between the query data field and the screening condition to obtain a fourth data table, wherein the second data table is a data table including the query data field in the plurality of data tables. Data satisfying the target query condition is queried from the fourth data table to obtain a target data table. After receiving the query request for querying the associated data table between the plurality of data tables, the data is queried according to the inequality value relationship between the query data field and the reference data field indicated by the target query condition. First, the first data table including the reference data field is expanded into the third data table, wherein the expansion content includes the screening condition used for pre-screening data. In the subsequent association process, the query data field and the screening condition are matched first, and only the data for which the query data field and the screening condition match successfully is associated, and the data for which the query data field and the screening condition do not match successfully is not associated. Through the pre-screening operation before association, the Cartesian product generated by association is greatly reduced, and the direct inequality value association of the plurality of associated data tables to generate a huge Cartesian product is avoided. The reduction of the Cartesian product can effectively improve the efficiency of data query. Finally, the data is efficiently queried in the fourth data table obtained by association according to the target query condition. By using the above technical solution, the problems such as low efficiency of data query in the related art are solved, and the technical effect of improving the efficiency of data query is achieved. BRIEF DESCRIPTION OF DRAWINGS
[0036] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the present application.
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced. Obviously, the drawings needed to be obtained by those of ordinary skill in the art without any creative work can also obtain other drawings.
[0038] Figure 1 A hardware environment schematic diagram of a data query method according to an embodiment of the present application is shown in FIG. 1.
[0039] Figure 2 A flowchart of a data query method according to an embodiment of the present application is shown in FIG. 2.
[0040] Figure 3 A schematic diagram of an associated data table according to an embodiment of the present application is shown in FIG. 3.
[0041] Figure 4 A schematic diagram of a third data table according to an embodiment of the present application is shown in FIG. 4.
[0042] Figure 5 A schematic diagram of a second data table and the third data table association process according to an embodiment of the present application is shown in FIG. 5.
[0043] Figure 6 A schematic diagram of a second data table (table A) and the third data table (table C) matching process according to an embodiment of the present application is shown in FIG. 6.
[0044] Figure 7 A schematic diagram of a target data table generation according to an embodiment of the present application is shown in FIG. 7.
[0045] Figure 8 A flowchart of a target data table generation according to an embodiment of the present application is shown in FIG. 8.
[0046] Figure 9 A schematic diagram of a data query method according to an embodiment of the present application is shown in FIG. 9.
[0047] Figure 10 A structural block diagram of a data query device according to an embodiment of the present application is shown in FIG. 10. DETAILED DESCRIPTION
[0048] In order to make the person skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without any creative work should belong to the scope of protection of the present application.
[0049] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0050] According to an aspect of an embodiment of the present application, a data query method is provided. The data query method is widely used in smart home (Smart Home), smart home, smart home device ecosystem, intelligence house (Intelligence House) ecosystem, and whole-house intelligent digital control application scenarios. Optionally, in the present embodiment, the above-mentioned data query method can be applied to the hardware environment composed of a terminal device 102 and a server 104 as shown in the figure. Figure 1 As shown in the figure, the server 104 is connected with the terminal device 102 through a network, which can be used to provide services (such as application services, etc.) for the terminal or the client installed on the terminal, a database can be set on the server or independently of the server, which is used to provide data storage services for the server 104, cloud computing and / or edge computing services can be configured on the server or independently of the server, which is used to provide data operation services for the server 104. Figure 1 As shown in the figure, the server 104 is connected with the terminal device 102 through a network, which can be used to provide services (such as application services, etc.) for the terminal or the client installed on the terminal, a database can be set on the server or independently of the server, which is used to provide data storage services for the server 104, cloud computing and / or edge computing services can be configured on the server or independently of the server, which is used to provide data operation services for the server 104.
[0051] The above-mentioned network can include but is not limited to at least one of the following: wired network, wireless network. The above-mentioned wired network can include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the above-mentioned wireless network can include but is not limited to at least one of the following: WIFI (Wireless Fidelity, Wireless Fidelity), Bluetooth. The terminal device 102 can not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart oven, smart refrigerator, smart oven, smart oven, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projection equipment, smart television, smart clothesline, smart curtain, smart audio and video, smart socket, smart sound, smart sound box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart window cleaning robot, smart mopping robot, smart air purification equipment, smart steamer, smart microwave oven, smart kitchen treasure, smart purifier, smart water dispenser, smart door lock, etc.
[0052] The embodiment provides a data query method, which is applied to the computer terminal, Figure 2 The embodiment provides a flowchart of a data query method, which comprises the following steps:
[0053] In step S202, a data query request is received, wherein the data query request is used for requesting to query data of an associated data table between a plurality of data tables which meets a target query condition, and the target query condition is used for indicating an inequality relationship between a query data field and a reference data field;
[0054] In step S204, in response to the data query request, a first data table including the reference data field in the plurality of data tables is expanded into a third data table according to the reference data field and the target query condition, wherein the third data table carries a screening condition used for pre-screening data;
[0055] In step S206, a second data table is associated with the third data table according to a matching relationship between the query data field and the screening condition, to obtain a fourth data table, wherein the second data table is a data table including the query data field in the plurality of data tables;
[0056] In step S208, data meeting the target query condition is queried from the fourth data table, to obtain a target data table.
[0057] Through the above steps, after receiving a query request for querying an associated data table between a plurality of data tables, the query is performed according to an inequality relationship between a query data field and a reference data field indicated by a target query condition. First, a first data table including the reference data field is expanded into a third data table, wherein the expansion content includes a screening condition used for pre-screening data. In a subsequent association process, the query data field and the screening condition are matched first, and only the data for which the query data field and the screening condition are matched successfully is associated, and the data for which the query data field and the screening condition are not matched successfully is not associated. Through the pre-screening operation before association, the Cartesian product generated by association is greatly reduced, and the generation of a huge Cartesian product by directly associating the plurality of associated data tables is avoided. The reduction of the Cartesian product can effectively improve the efficiency of data query. Finally, data is efficiently queried in the fourth data table obtained by association according to the target query condition. Through the above technical solution, the problem of low data query efficiency in the related art is solved, and the technical effect of improving the efficiency of data query is achieved.
[0058] In the technical solution provided in step S202, the data query request can be, but is not limited to, used to request to query data of an associated data table between a plurality of data tables that meets a target query condition, that is, a plurality of data tables can exist in the big data server, such as table A, table B, table C, table D, and the like, and the data query request can be used to query data of an associated data table (table A and table B) in table A, table B, table C, and table D.
[0059] Optionally, in this embodiment, the associated data table in the associated data table between the plurality of data tables can be, but is not limited to, a plurality of data tables having a data association relationship, such as, Figure 3 is a schematic diagram of an associated data table according to an embodiment of the present application, as Figure 3 shown, table A and table B are two data tables having a data association relationship, wherein the first column (device ID) of table A and table B is AAAA, and the remaining columns are all data information describing the device AAAA, for example, Event_tm in table A represents the event reporting time corresponding to the device AAAA, Power in table A represents the running power of the device AAAA at the corresponding event reporting time, On_tm in table B represents the boot time of the device AAAA, and Off_tm in table B represents the shutdown time of the device AAAA. Similarly, the plurality of data tables that jointly carry related data of the same associated subject are associated data tables.
[0060] Optionally, in this embodiment, the target query condition is used to indicate an inequality relationship between a query data field and a reference data field, for example, the target query condition can be On_tm≤Event_tm≤Off_tm, and the inequality relationship is used to indicate that the query data field (Event_tm) is greater than the reference data field (On_tm), and the query data field (Event_tm) is less than the reference data field (Off_tm).
[0061] Optionally, in this embodiment, the query data field can refer to data to be queried, for example, the data value corresponding to Event_tm in table A and table B that meets the target query condition (On_tm≤Event_tm≤Off_tm), and then Event_tm can be used as the query data field.
[0062] Optionally, in this embodiment, the reference data field can refer to reference data for auxiliary query, for example, On_tm and Off_tm in table B can be used as auxiliary and reference, so as to query the data value corresponding to Event_tm in table A that meets the target query condition according to the target query condition (On_tm≤Event_tm≤Off_tm).
[0063] In the technical solution provided in step S204, the first data table including the reference data field in the plurality of data tables is expanded into a third data table according to the reference data field and the target query condition, that is, the expansion basis can be but is not limited to being determined based on the reference data field and the target query condition. For example, when the target query condition (On_tm≤Event_tm≤Off_tm) and the reference data field (On_tm and Off_tm) are known, the 10-minute interval in which the device running time falls can be expanded, that is, the time between On_tm and Off_tm is the device running time. One day is divided into multiple intervals with 10 minutes as an interval, and the 10-minute interval information in which the device running time falls can be expanded. For example, when On_tm is 09:00:10 and Off_tm is 09:15:00, the running time between On_tm and Off_tm is 09:00:10-09:15:00, which falls into two 10-minute intervals of 09:00:00-09:10:00 and 09:10:00-09:20:00.
[0064] In an example embodiment, the first data table including the reference data field in the plurality of data tables can be expanded into a third data table according to the reference data field and the target query condition in the following manner, but is not limited thereto: a target expansion field is added in the first data table according to the reference data field and the target query condition, to obtain an expanded data table; an expansion data value of the target expansion field corresponding to a reference data value of the reference data field is determined according to a relationship between the reference data value and the target expansion field, wherein the expansion data value of the target expansion field is used to indicate the filtering condition; and the expansion data value is added to the expanded data table to obtain the third data table.
[0065] Optionally, in the embodiment, the target expansion field can be but is not limited to being determined according to the reference data field and the target query condition, for example, Figure 4 is a schematic diagram of the third data table according to an embodiment of the present application, as Figure 4As shown, based on Table B, the target extension field (on_10min_tm) is expanded to obtain a third data table (Table C), according to On_tm and Off_tm in Table B, a time interval (On~Off) is obtained, indicating the 10-minute interval in which the corresponding On_tm and Off_tm fall, a target extension field (on_10min_tm) is added, and the "left end" of the obtained time interval is taken as the extension data value. For example, On_tm (11:15:10) and Off_tm (11:20:10) fall into the time interval (11:10:00~11:20:00 and 11:20:00~11:30:00), and the "left end" of the time interval is taken as the extension data value to obtain (on_10min_tm) 11:10:00 and 11:20:00.
[0066] In an example embodiment, the target extension field can be added in the first data table to obtain an extended data table according to the reference data field and the target query condition, but is not limited to the following: the target extension field is constructed according to the reference data field and the target query condition; the data column corresponding to the target extension field is added in the first data table to obtain the extended data table.
[0067] Optionally, in this embodiment, the reference data field and the target query condition can construct the target extension field, but are not limited to the following: for example, given the reference data field (On_tm and Off_tm), the target query condition (On_tm≤Event_tm≤Off_tm), and the time difference between On_tm and Off_tm representing the device running time, the reference domain corresponding to the reference data field can be first divided into multiple data intervals, wherein the reference domain is the set of all values allowed by the reference data field, that is, the reference domain can refer to all the time allowed by the device to run. The total time is divided into multiple data intervals, and then the target data interval for dividing the total time is determined, which can be but not limited to the following: first, obtain multiple sets of data intervals between multiple sets of data included in the query data field; then determine the target data interval according to the multiple sets of data intervals, wherein the target data interval is used to represent the average value of the multiple sets of data intervals; for example, the average value of 10min is obtained by obtaining multiple sets of data values corresponding to Event_tm, and 10min is taken as the target data interval, and the target extension field (on_10min_tm) is constructed.
[0068] In the technical solution provided in step S206, the second data table and the third data table are associated according to the matching relationship between the query data field and the filtering condition, to obtain a fourth data table, wherein the second data table is a data table in the plurality of data tables that includes the query data field, that is, a matching operation can be performed before association, and the association operation is performed based on the matching relationship, wherein the matching relationship can be a comparison relationship of numerical values, for example, the numerical value of the query data field and the numerical value of the corresponding filtering condition are compared, and in the case of numerical value equality, it is determined that the matching relationship is a matching success; and in the case of numerical value inequality, it is determined that the matching relationship is a matching failure.
[0069] In an example embodiment, the second data table and the third data table can be associated according to the matching relationship between the query data field and the filtering condition to obtain a fourth data table, in which the second data table is a data table in the plurality of data tables that includes the query data field, by the following manner: each query data value of the query data field in the second data table is matched with the filtering condition in the third data table; and each query data value of the query data field in the second data table that matches the filtering condition in the third data table is associated to obtain the fourth data table.
[0070] Optionally, in this embodiment, each query data value of the query data field in the second data table is matched with the filtering condition in the third data table, which can be performed by the following manner, for example, Figure 5 is a schematic diagram of the association process of the second data table and the third data table according to an embodiment of the present application, as Figure 5 shown, Event_tm in the second data table (table A) and on_10min_tm in the third data table (table C) are matched, data values that satisfy the filtering condition are associated to obtain the fourth data table (table D), and data values that do not satisfy the filtering condition are not associated.
[0071] In an example embodiment, each query data value of the query data field in the second data table can be matched with the filtering condition in the third data table by the following manner: a first data in the each query data value is compared with a second data in each extension data value of a target extension field in the third data table, wherein the extension data value of the target extension field is used to indicate the filtering condition; and in the case that the first data and the second data are consistent, it is determined that each query data value of the query data field in the second data table matches the filtering condition in the third data table successfully.
[0072] Optionally, in the embodiment, the first data in each of the query data values is compared with the second data in each of the extended data values of the target extended field in the third data table, and the first data and the second data can be but are not limited to equal, for example, Figure 6 is a schematic diagram of the matching process of the second data table (Table A) and the third data table (Table C) according to the embodiment of the application, as shown in Figure 6 The first 4 bits of the query data value of Event_tm and the first 4 bits of the extended data value of on_10min_tm can be but are not limited to compared, and in the case that the data values are equal, it is determined that the screening condition is matched successfully.
[0073] In the technical solution provided in the step S208, the data satisfying the target query condition is queried from the fourth data table to obtain the target data table, which can be but is not limited to querying the data from the fourth data table according to the target query condition. Due to the pre-screening and the association processing, the Cartesian product contained in the fourth data table will be greatly reduced.
[0074] In an example embodiment, the data satisfying the target query condition can be but is not limited to queried from the fourth data table to obtain the target data table by the following manner: obtaining the query data value of the query data field and the reference data value of the reference data field included in the fourth data table; and deleting the data whose query data value and reference data value do not satisfy the target query condition from the fourth data table to obtain the target data table.
[0075] Optionally, in the embodiment, before the target data table is obtained, the data whose query data value and reference data value do not satisfy the target query condition can also be deleted, for example, Figure 7 is a schematic diagram of the generation of the target data table according to the embodiment of the application, as shown in Figure 7 The query data value of Event_tm and the extended data value of on_10min_tm are compared, and the data not satisfying the target query condition (On_tm≤Event_tm≤Off_tm) is deleted to obtain the target data table.
[0076] In an example embodiment, the data satisfying the target query condition can be but is not limited to deleted from the fourth data table to obtain the target data table by the following manner: deleting the data whose query data value and reference data value do not satisfy the target query condition from the fourth data table as a candidate data table; and deleting the screening condition from the candidate data table to obtain the target data table.
[0077] Optionally, in the embodiment, after the target data table is obtained, the screening condition can also be deleted, Figure 8 is a flow chart of generating a target data table according to an embodiment of the present application, as shown in Figure 8 First, data in the fourth data table that does not satisfy the target query condition is deleted as a candidate data table, and then the screening condition (on_10min_tm) in the candidate data table is deleted to obtain the target data table.
[0078] In order to better understand the process of the above data query method, the above data query method process is described in combination with optional embodiments below, but is not used to limit the technical solutions of the embodiments of the present application.
[0079] In the embodiment, a data query method is provided, Figure 9 is a schematic diagram of a data query method according to an embodiment of the present application, as shown in Figure 9 The method mainly includes the following steps:
[0080] Step S901: obtaining A table data and B table data;
[0081] Step S902: obtaining an expanded field corresponding to the B table according to a rule;
[0082] Step S903: expanding the data of the B table according to the obtained expanded field to obtain a C table;
[0083] Step S904: associating the A table and the C table;
[0084] Step S905: filtering the data set obtained by association to obtain a target data set.
[0085] Through the above embodiments, the present application proposes a calculation method for processing Cartesian product generated in the process of unequal value association of large data tables, and the association complexity is reduced by expanding a new association relationship field and a data set. In the present application, the time field is used for expansion, and the expansion can also be extended to other fields with features.
[0086] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software on a general hardware platform as necessary, and of course can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product in essence or in the form of a part of the prior art that makes a contribution. The computer software product is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk) and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device) to execute the method of each embodiment of the present application.
[0087] Figure 10 is a structural block diagram of a data query device according to an embodiment of the present application; as shown in Figure 10 , comprising:
[0088] The receiving module 1002 is configured to receive a data query request, wherein the data query request is used to request to query data of an associated data table between a plurality of data tables that meets a target query condition, and the target query condition is used to indicate an inequality relationship between a query data field and a reference data field.
[0089] The extension module 1004 is configured to, in response to the data query request, extend a first data table including the reference data field in the plurality of data tables to a third data table according to the reference data field and the target query condition, wherein the third data table carries a screening condition used for pre-screening data.
[0090] The association module 1006 is configured to associate a second data table with the third data table according to a matching relationship between the query data field and the screening condition, to obtain a fourth data table, wherein the second data table is a data table including the query data field in the plurality of data tables.
[0091] The query module 1008 is configured to query data meeting the target query condition from the fourth data table, to obtain a target data table.
[0092] According to the above embodiment, after receiving a query request for querying an associated data table between a plurality of data tables, the query is performed according to an inequality relationship between a query data field and a reference data field indicated by a target query condition. First, a first data table including the reference data field is expanded into a third data table, wherein the expansion content includes a screening condition for pre-screening data. In a subsequent association process, the query data field and the screening condition are matched first, and only the data for which the query data field and the screening condition are matched successfully is associated, and the data for which the query data field and the screening condition are not matched successfully is not associated. Through the pre-screening operation before association, the Cartesian product generated by association is greatly reduced, and the generation of a huge Cartesian product by directly associating a plurality of associated data tables is avoided. The reduction of the Cartesian product can effectively improve the efficiency of data query. Finally, data is efficiently queried in a fourth data table obtained by association according to the target query condition. By using the above technical solution, the problems such as low efficiency of data query in the related art are solved, and the technical effect of improving the efficiency of data query is achieved.
[0093] In an example embodiment, the expansion module comprises:
[0094] The first adding unit is configured to add a target expansion field in the first data table according to the reference data field and the target query condition, to obtain an expanded data table;
[0095] The determination unit is configured to determine an expansion data value of the target expansion field corresponding to a reference data value of the reference data field according to a relationship between the reference data value and the target expansion field, wherein the expansion data value of the target expansion field is used to indicate the screening condition;
[0096] The second adding unit is configured to add the expansion data value to the expanded data table to obtain the third data table.
[0097] In an example embodiment, the first adding unit is configured to:
[0098] construct the target expansion field according to the reference data field and the target query condition;
[0099] add a data column corresponding to the target expansion field in the first data table to obtain the expanded data table.
[0100] In an example embodiment, the association module comprises:
[0101] The matching unit is configured to match each query data value of the query data field in the second data table with the screening condition in the third data table;
[0102] The association unit is configured to associate each query data value of the query data field in the second data table with data in the third data table that matches the filtering condition successfully, to obtain a fourth data table.
[0103] In an example embodiment, the matching unit is configured to:
[0104] compare first data in each query data value with second data in each extension data value of a target extension field in the third data table, wherein the extension data value of the target extension field is used to indicate the filtering condition;
[0105] In a case where the first data and the second data are consistent, it is determined that each query data value of the query data field in the second data table matches the filtering condition in the third data table successfully.
[0106] In an example embodiment, the query module comprises:
[0107] The obtaining unit is configured to obtain query data values of the query data field and reference data values of the reference data field included in the fourth data table;
[0108] The deleting unit is configured to delete data in the fourth data table that does not satisfy the target query condition from the query data values and the reference data values, to obtain the target data table.
[0109] In an example embodiment, the deleting unit is configured to:
[0110] delete data in the fourth data table that does not satisfy the target query condition from the query data values and the reference data values as a candidate data table;
[0111] delete the filtering condition from the candidate data table, to obtain the target data table.
[0112] Embodiments of the present application also provide a storage medium comprising a stored program, wherein the above-mentioned program performs any of the above-mentioned methods when running.
[0113] Optionally, in the present embodiment, the above-mentioned storage medium can be configured to store program code for performing the following steps:
[0114] S1, receiving a data query request, wherein the data query request is used to request data in an associated data table between a plurality of data tables that satisfies a target query condition, and the target query condition is used to indicate an inequality relationship between a query data field and a reference data field;
[0115] S2, in response to the data query request, expanding a first data table including the reference data field in the plurality of data tables into a third data table according to the reference data field and the target query condition, wherein the third data table carries a screening condition for pre-screening data;
[0116] S3, associating a second data table with the third data table according to a matching relationship between the query data field and the screening condition, to obtain a fourth data table, wherein the second data table is a data table including the query data field in the plurality of data tables;
[0117] S4, querying data satisfying the target query condition from the fourth data table to obtain a target data table.
[0118] Embodiments of the present application also provide an electronic device including a memory and a processor, the memory storing a computer program, and the processor being configured to execute the computer program to perform the steps in any of the above method embodiments.
[0119] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected with the processor, and the input / output device is connected with the processor.
[0120] Optionally, in the embodiment, the processor can be configured to execute the following steps through the computer program:
[0121] S1, receiving a data query request, wherein the data query request is used to request to query data satisfying a target query condition in an associated data table between a plurality of data tables, and the target query condition is used to indicate an inequality relationship between a query data field and a reference data field;
[0122] S2, in response to the data query request, expanding a first data table including the reference data field in the plurality of data tables into a third data table according to the reference data field and the target query condition, wherein the third data table carries a screening condition for pre-screening data;
[0123] S3, associating a second data table with the third data table according to a matching relationship between the query data field and the screening condition, to obtain a fourth data table, wherein the second data table is a data table including the query data field in the plurality of data tables;
[0124] S4, querying data satisfying the target query condition from the fourth data table to obtain a target data table.
[0125] Optionally, in the embodiment, the storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various storage medium capable of storing program codes.
[0126] Optionally, the specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, and the embodiment will not be described here.
[0127] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be realized by a general computing device, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices, and optionally, they can be realized by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in different order, or they can be manufactured into individual integrated circuit modules, or multiple modules or steps among them can be manufactured into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
[0128] The above only describes the preferred embodiments of the present application, and it should be noted that those skilled in the art can make several improvements and refinements without departing from the principles of the present application, and these improvements and refinements should be considered as the protection scope of the present application.
Claims
1. A query method of data, characterized by, The method comprises the following steps: receiving a data query request, the data query request being used to request to query data of an associated data table between a plurality of data tables satisfying a target query condition, the target query condition being used to indicate an inequality relationship between a query data field and a reference data field; in response to the data query request, expanding a first data table including the reference data field in the plurality of data tables into a third data table according to the reference data field and the target query condition, the third data table carrying a screening condition used to pre-screen data; associating a second data table with the third data table according to a matching relationship between the query data field and the screening condition to obtain a fourth data table, the second data table being a data table including the query data field in the plurality of data tables; querying data satisfying the target query condition from the fourth data table to obtain a target data table. The step of associating the second data table with the third data table according to the matching relationship between the query data field and the screening condition to obtain the fourth data table comprises the following steps: matching each query data value of the query data field in the second data table with the screening condition in the third data table; associating data in which each query data value of the query data field in the second data table is successfully matched with the screening condition in the third data table to obtain the fourth data table.
2. The query method of data according to claim 1, characterized in that, The step of expanding the first data table including the reference data field in the plurality of data tables into the third data table comprises the following steps: adding a target expansion field in the first data table according to the reference data field and the target query condition to obtain an expansion data table; determining an expansion data value of the target expansion field corresponding to a reference data value of the reference data field according to a relationship between the reference data value and the target expansion field, wherein the expansion data value of the target expansion field is used to indicate the screening condition; adding the expansion data value to the expansion data table to obtain the third data table.
3. The method of claim 2, wherein, The step of adding the target expansion field in the first data table according to the reference data field and the target query condition to obtain the expansion data table comprises the following steps: constructing the target expansion field according to the reference data field and the target query condition; adding a data column corresponding to the target expansion field in the first data table to obtain the expansion data table.
4. The method of claim 1, wherein, The step of matching each query data value of the query data field in the second data table with the screening condition in the third data table comprises the following steps: comparing first data in each query data value with second data in each expansion data value of a target expansion field in the third data table, wherein the expansion data value of the target expansion field is used to indicate the screening condition; in a case where the first data and the second data are consistent in comparison, determining that each query data value of the query data field in the second data table is successfully matched with the screening condition in the third data table.
5. The method of claim 1, wherein, The step of querying data satisfying the target query condition from the fourth data table to obtain the target data table comprises the following steps: The fourth data table includes query data values of the query data field and reference data values of the reference data field; The query data values and the reference data values that do not satisfy the target query condition are deleted from the fourth data table to obtain the target data table.
6. The method of claim 5, wherein, The query data values and the reference data values that do not satisfy the target query condition are deleted from the fourth data table to obtain the target data table, and the method comprises: The query data values and the reference data values that do not satisfy the target query condition are deleted from the fourth data table to obtain a candidate data table; The filter condition is deleted from the candidate data table to obtain the target data table.
7. A data search device, characterized by comprising: The method comprises: The receiving module is configured to receive a data query request, the data query request being used to request data that satisfies a target query condition in an associated data table between a plurality of data tables, the target query condition being used to indicate an inequality relationship between a query data field and a reference data field; The extension module is configured to, in response to the data query request, extend a first data table that includes the reference data field in the plurality of data tables into a third data table according to the reference data field and the target query condition, the third data table carrying a filter condition used to pre-filter data; The association module is configured to associate a second data table with the third data table according to a matching relationship between the query data field and the filter condition to obtain a fourth data table, the second data table being a data table that includes the query data field in the plurality of data tables; The query module is configured to query data that satisfies the target query condition from the fourth data table to obtain a target data table; The association module is further configured to match each query data value of the query data field in the second data table with the filter condition in the third data table, and associate data for which the matching is successful to obtain the fourth data table.
8. A computer readable storage medium, characterized in that, The computer readable storage medium comprises a stored program, wherein the program performs the method of any one of claims 1 to 6 when executed. 9.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to execute the method of any one of claims 1 to 6 by using the computer program.
Citation Information
Patent Citations
Data query method, device and equipment and storage medium
CN112131253A
Data query method and device
CN114020790A