CN114840557A - Data query method and device, storage medium and electronic device - Google Patents

Data query method and device, storage medium and electronic device Download PDF

Info

Publication number
CN114840557A
CN114840557A CN202210297160.1A CN202210297160A CN114840557A CN 114840557 A CN114840557 A CN 114840557A CN 202210297160 A CN202210297160 A CN 202210297160A CN 114840557 A CN114840557 A CN 114840557A
Authority
CN
China
Prior art keywords
data
query
data table
target
field
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210297160.1A
Other languages
Chinese (zh)
Inventor
刘马龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202210297160.1A priority Critical patent/CN114840557A/en
Publication of CN114840557A publication Critical patent/CN114840557A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24564Applying rules; Deductive queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a data query method and device, a storage medium and an electronic device, and relates to the technical field of smart families, wherein the data query method comprises the following steps: receiving a data query request; responding to the data query request, and expanding a first data table including the reference data fields in the multiple data tables into a third data table according to the reference data fields and the target query condition; associating the second data table with the third data table according to the matching relation between the query data fields and the screening conditions to obtain a fourth data table, wherein the second data table is a data table comprising the query data fields in the plurality of data tables; and querying data meeting the target query condition from the fourth data table to obtain a target data table.

Description

Data query method and device, storage medium and electronic device
Technical Field
The 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
With the development of science and technology, big data is distributed in every corner of social life, and in many application scenarios, SQL (Structured Query Language) is required to perform unequal association on data in a plurality of data tables to Query required data, but in the prior art, the data amount of cartesian products generated by performing unequal association on data tables using SQL is extremely large, and as data of data tables increases, the problem of too large cartesian products becomes more prominent, too many system resources are occupied, which causes a great burden on system processing for processing data, and the too large cartesian products reduce the Query efficiency for data.
Aiming at the problems of low efficiency of data query and the like in the related technology, no effective solution is provided.
Disclosure of Invention
The embodiment of the application provides a data query method and device, a storage medium and an electronic device, and aims to at least solve the problems of low data query efficiency and the like in the related art.
According to an embodiment of the present application, there is provided a method for querying data, including: receiving a data query request, wherein the data query request is used for requesting to query data of an associated data table among a plurality of data tables, and the associated data table meets a target query condition, and the target query condition is used for indicating an inequality relation between a query data field and a reference data field;
responding to the data query request, and expanding a first data table comprising the reference data fields in the multiple data tables into a third data table according to the reference data fields and the target query conditions, wherein the third data table carries screening conditions for pre-screening data;
associating a second data table with the third data table according to the matching relation between the query data fields and the screening conditions to obtain a fourth data table, wherein the second data table is a data table comprising the query data fields in the plurality of data tables;
and querying the data meeting the target query condition from the fourth data table to obtain a target data table.
Optionally, the expanding, according to the reference data field and the target query condition, the first data table including the reference data field in the multiple data tables into a third data table includes:
adding a target extension field in the first data table according to the reference data field and the target query condition to obtain an extension data table;
determining an extended data value of the target extended field corresponding to the reference data value according to a relation between the reference data value of the reference data field and the target extended field, wherein the extended data value of the target extended field is used for indicating the screening condition;
and adding the extended data value into the extended data table to obtain the third data table.
Optionally, the adding a target extension field in the first data table according to the reference data field and the target query condition to obtain an extended data table includes:
constructing the target extension field according to the reference data field and the target query condition;
and adding a data column corresponding to the target extension field in the first data table to obtain the extension data table.
Optionally, the associating, according to a matching relationship between the query data field and the screening condition, a second data table with the third data table to obtain a fourth data table, where the second data table is a data table including the query data field in the multiple data tables, and includes:
matching each query data value of the query data field in the second data table with the screening condition in the third data table;
and associating each query data value of the query data field in the second data table with the data successfully matched with the screening conditions in the third data table to obtain a fourth data table.
Optionally, the matching each query data value of the query data field in the second data table with the screening condition in the third data table includes:
comparing the first data in each query data value with the second data in each extended data value of a target extended field in the third data table, wherein the extended data value of the target extended field is used for indicating the screening condition;
and under the condition that the first data is consistent with the second data 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.
Optionally, the querying, from the fourth data table, data meeting the target query condition to obtain a target data table, includes:
acquiring a query data value of the query data field and a reference data value of the reference data field which are included in the fourth data table;
and deleting the data of which the query data value and the reference data value do not meet the target query condition from the fourth data table to obtain the target data table.
Optionally, the deleting the data of which the query data value and the reference data value do not satisfy the target query condition from the fourth data table to obtain the target data table includes:
deleting data of which the query data value and the reference data value do not meet 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.
According to another embodiment of the present application, there is also provided a data query apparatus, including:
the data query module is used for requesting to query data, of which associated data tables among a plurality of data tables meet target query conditions, and the target query conditions are used for indicating an inequality relation between a query data field and a reference data field;
an expansion module, configured to respond to the data query request, expand a first data table including the reference data field in the multiple data tables into a third data table according to the reference data field and the target query condition, where the third data table carries a screening condition for performing pre-screening on data;
the association module is used for associating a second data table with the third data table according to the matching relation between the query data fields and the screening conditions to obtain a fourth data table, wherein the second data table is a data table comprising the query data fields in the plurality of data tables;
and the query module is used for querying the data meeting the target query condition from the fourth data table to obtain a target data table.
According to another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the above data query method when running.
According to another aspect of the embodiments of the present application, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for querying data through the computer program.
In the embodiment of the application, a data query request is received, wherein the data query request is used for requesting to query data of an associated data table among a plurality of data tables, wherein the associated data table meets a target query condition, and the target query condition is used for indicating an inequality relation between a query data field and a reference data field; responding to the data query request, and expanding a first data table comprising the reference data fields in the multiple data tables into a third data table according to the reference data fields and the target query conditions, wherein the third data table carries screening conditions for pre-screening the data; associating the second data table with the third data table according to the matching relation between the query data fields and the screening conditions to obtain a fourth data table, wherein the second data table is a data table comprising the query data fields in the plurality of data tables; inquiring data meeting target inquiry conditions from a fourth data table to obtain a target data table, namely after receiving an inquiry request for inquiring an associated data table among a plurality of data tables, inquiring according to an unequal relation between an inquiry data field and a reference data field indicated by the target inquiry conditions, firstly expanding a first data table comprising the reference data field into a third data table, wherein the expanded content comprises screening conditions for pre-screening the data, matching the inquiry data field and the screening conditions in the subsequent association process, associating only the data of which the inquiry data field is successfully matched with the screening conditions, not associating the data of which the inquiry data field is not successfully matched with the screening conditions, and greatly reducing Cartesian products generated by association through the pre-screening operation before associating, the method avoids directly carrying out unequal association on a plurality of associated data tables to generate huge Cartesian products, wherein the reduction of the Cartesian products can effectively improve the efficiency of data query, and finally, data is efficiently queried in a fourth data table obtained by association according to target query conditions. By adopting the technical scheme, the problems of low data query efficiency and the like in the related technology are solved, and the technical effect of improving the data query efficiency is realized.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
FIG. 1 is a diagram illustrating a hardware environment of a method for querying data according to an embodiment of the present disclosure;
FIG. 2 is a flow chart of a method for querying data according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an association data table according to an embodiment of the application;
FIG. 4 is a schematic diagram of a third data table according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a process of associating a second data table with the third data table according to an embodiment of the present application;
FIG. 6 is 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;
FIG. 7 is a schematic diagram of generation of a target data table according to an embodiment of the present application;
FIG. 8 is a flow chart of generation of a target data table according to an embodiment of the present application;
FIG. 9 is a diagram illustrating a method for querying data according to an embodiment of the present application;
fig. 10 is a block diagram of a data query device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to one aspect of the embodiment of the application, a method for querying data is provided. The data query method is widely applied to full-House intelligent digital control application scenes such as intelligent homes (Smart Home), intelligent homes, intelligent Home equipment ecology, intelligent House (Intelligent House) ecology and the like. Alternatively, in this embodiment, the above data query method may be applied to a hardware environment formed by the terminal device 102 and the server 104 as shown in fig. 1. As shown in fig. 1, the server 104 is connected to the terminal device 102 through a network, and may be configured to provide a service (e.g., an application service) for the terminal or a client installed on the terminal, set a database on the server or independent of the server, and provide a data storage service for the server 104, and configure a cloud computing and/or edge computing service on the server or independent of the server, and provide a data operation service for the server 104.
The network may include, but is not limited to, at least one of: wired networks, wireless networks. The wired network may include, but is not limited to, at least one of: wide area networks, metropolitan area networks, local area networks, which may include, but are not limited to, at least one of the following: WIFI (Wireless Fidelity), bluetooth. Terminal equipment 102 can be but not limited to be PC, the cell-phone, the panel computer, intelligent air conditioner, intelligent cigarette machine, intelligent refrigerator, intelligent oven, intelligent kitchen range, intelligent washing machine, intelligent water heater, intelligent washing equipment, intelligent dish washer, intelligent projection equipment, intelligent TV, intelligent clothes hanger, intelligent (window) curtain, intelligence audio-visual, smart jack, intelligent stereo set, intelligent audio amplifier, intelligent new trend equipment, intelligent kitchen guarding equipment, intelligent bathroom equipment, intelligence robot of sweeping the floor, intelligence robot of wiping the window, intelligence robot of mopping the ground, intelligent air purification equipment, intelligent steam ager, intelligent microwave oven, intelligent kitchen is precious, intelligent clarifier, intelligent water dispenser, intelligent lock etc..
In this embodiment, a data query method is provided, which is applied to the computer terminal, and fig. 2 is a flowchart of a data query method according to an embodiment of the present application, where the flowchart includes the following steps:
step S202, receiving a data query request, wherein the data query request is used for requesting to query data, of which associated data tables among a plurality of data tables meet target query conditions, and the target query conditions are used for indicating an inequality relation between a query data field and a reference data field;
step S204, responding to the data query request, and expanding a first data table including the reference data fields in the multiple data tables into a third data table according to the reference data fields and the target query conditions, wherein the third data table carries screening conditions for pre-screening data;
step S206, according to the matching relation between the query data field and the screening condition, associating a second data table with the third data table to obtain a fourth data table, wherein the second data table is a data table comprising the query data field in the plurality of data tables;
step S208, querying data meeting the target query condition from the fourth data table to obtain a target data table.
Through the steps, after receiving a query request for querying associated data tables among a plurality of data tables, querying according to an unequal relation between a query data field and a reference data field indicated by a target query condition, firstly, expanding a first data table including the reference data field into a third data table, wherein the expanded content comprises a screening condition for pre-screening data, matching the query data field with the screening condition in the subsequent association process, only associating the data of which the query data field is successfully matched with the screening condition, not associating the data of which the query data field is not successfully matched with the screening condition, and greatly reducing the Cartesian product generated by association through the pre-screening operation before association, avoiding directly associating the associated data tables with unequal values to generate a huge Cartesian product, the reduction of the Cartesian product can effectively improve the efficiency of data query, and finally, data can be efficiently queried in the fourth data table obtained through association according to the target query condition. By adopting the technical scheme, the problems of low data query efficiency and the like in the related technology are solved, and the technical effect of improving the data query efficiency is realized.
In the technical solution provided in step S202 above, the data query request may be, but is not limited to, data for requesting to query an associated data table among multiple data tables to satisfy the target query condition, that is, multiple data tables may exist in the big data server, for example: table a, table B, table C, table D, etc., and the data query request may be used to query the data of the associated one of tables a, B, C, D (tables a and B).
Optionally, in this embodiment, an associated data table in associated data tables between multiple data tables may refer to multiple data tables having a data association relationship, for example, fig. 3 is a schematic diagram of an associated data table according to an embodiment of the present application, as shown in fig. 3, table a and table B are two data tables having a data association relationship, where a first column (device ID) of table a and table B is both AAAA, and the remaining columns are data information describing a device AAAA, for example, Event _ tm in table a represents an Event reporting time corresponding to the device AAAA, Power in table a represents an operating Power of the device AAAA at the corresponding Event reporting time, On _ tm in table B represents a Power-On time of the device AAAA, and Off _ tm in table B represents a Power-Off time of the device AAAA, and similar to this way that related data to the same associated subject is commonly carried by multiple data tables, then such multiple data tables describing related data of the same associated subject are mutually associated data tables.
Alternatively, in this embodiment, the target query condition is used to indicate an inequality relationship between the query data field and the reference data field, for example, the target query condition may be On _ tm ≦ Event _ tm ≦ Off _ tm, the inequality relationship being used to indicate that the query data field (Event _ tm) is larger than the reference data field (On _ tm) and the query data field (Event _ tm) is smaller than the reference data field (Off _ tm).
Optionally, in this embodiment, the query data field may refer to data to be queried, for example, if a data value corresponding to Event _ tm in the above-mentioned query tables a and B satisfies a target query condition (On _ tm ≦ Event _ tm ≦ Off _ tm), Event _ tm may be used as the query data field.
Alternatively, in this embodiment, the reference data field may refer to reference data of auxiliary query, for example, On _ tm and Off _ tm in the above table B, which may be used as auxiliary and reference, so as to query the data value corresponding to Event _ tm satisfying the target query condition in table a according to the target query condition (On _ tm ≦ Event _ tm ≦ Off _ tm).
In the technical solution provided in step S204 above, the first data table including the reference data field in the multiple data tables is extended into the third data table according to the reference data field and the target query condition, that is, the extension may be based On, but not limited to, the reference data field and the target query condition, for example, the target query condition (On _ tm ≦ Event _ tm ≦ Off _ tm) is known and the reference data fields (On _ tm and Off _ tm) may be extended, a 10-minute interval in which the device runtime falls may be extended, that is, the time between On _ tm and Off _ tm is the device runtime, the day is divided into multiple intervals at intervals of 10 minutes, 10-minute interval information in which the device runtime falls may be extended, 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, which are 10-minute intervals.
In an exemplary embodiment, a first data table of the plurality of data tables including the reference data field may be extended to a third data table according to the reference data field and the target query condition by, but not limited to: adding a target extension field in the first data table according to the reference data field and the target query condition to obtain an extension data table; determining an extended data value of the target extended field corresponding to the reference data value according to a relation between the reference data value of the reference data field and the target extended field, wherein the extended data value of the target extended field is used for indicating the screening condition; and adding the extended data value into the extended data table to obtain the third data table.
Alternatively, in this embodiment, the target extension field may be determined according to the reference data field and the target query condition, for example, fig. 4 is a schematic diagram of a third data table according to an embodiment of the present application, and as shown in fig. 4, On the basis of table B, the target extension field (On _10min _ tm) is extended to obtain a third data table (table C), a time interval (On to Off) is obtained according to On _ tm and Off _ tm in table B, a 10-minute interval in which the corresponding On _ tm and Off _ tm fall is indicated, the target extension field (On _10min _ tm) is added, and a "left end" of the obtained time interval is used as an extension data value. For example, On _ tm (11:15:10) and Off _ tm (11:20:10) fall into time intervals (11:10: 00-11: 20:00 and 11:20: 00-11: 30:00), and the "left end" of the time interval is obtained as an extended data value (On _10min _ tm) as 11:10:00 and 11:20: 00.
In an exemplary embodiment, an extended data table may be obtained by, but is not limited to, adding a target extension field in the first data table according to the reference data field and the target query condition in the following manner: constructing the target extension field according to the reference data field and the target query condition; and adding a data column corresponding to the target extension field in the first data table to obtain the extension data table.
Optionally, in this embodiment, the target extension field may be configured by referring to a data field and the target query condition, but not limited to, by knowing that a time difference between a reference data field (On _ tm and Off _ tm), a target query condition (On _ tm ≦ Event _ tm ≦ Off _ tm), and an On _ tm and Off _ tm represents a device runtime, first, a reference definition field corresponding to the reference data field may be equally divided into a plurality of data intervals, where the reference definition field is a set of all values allowed by the reference data field, that is, the reference definition field may refer to all times allowed by the device to run, and the total time is equally divided into a plurality of data intervals, so that it is necessary to determine a target data interval of equally divided total time, and the interval may be determined by, but not limited to, by: firstly, acquiring a plurality of groups of data intervals among a plurality of groups of data included in the query data field; then determining a target data interval according to the plurality of groups of data intervals, wherein the target data interval is used for representing an average value of the plurality of groups of data intervals; for example, data values corresponding to a plurality of sets of events _ tm are acquired, an average value is obtained for 10min, 10min is taken as a target data interval, and a target extension field is constructed: on _10min _ tm.
In the technical solution provided in step S206, according to a matching relationship between a query data field and the screening condition, a second data table and the third data table are associated to obtain a fourth data table, where the second data table is a data table including the query data field in the plurality of data tables, that is, before the association, a one-step matching operation may be performed, where the association operation is performed based on the matching relationship, where the matching relationship may be a comparison relationship of numerical values, for example, the numerical value of the query data field is compared with the numerical value of the corresponding screening condition, and when the numerical values are equal, the matching relationship is determined to be a successful matching; the matching relationship may be determined to be a matching failure, but is not limited to, in the case where the values are not equal.
In an exemplary embodiment, a fourth data table may be obtained by, but not limited to, associating a second data table with the third data table according to a matching relationship between a query data field and the filtering condition, where the second data table is a data table including the query data field in the plurality of data tables: matching each query data value of the query data field in the second data table with the screening condition in the third data table; and associating each query data value of the query data field in the second data table with the data successfully matched with the screening conditions in the third data table to obtain a fourth data table.
Optionally, in this embodiment, 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, but the method may be, but is not limited to, matching Event _ tm in the second data table (table a) with on _10min _ tm in the third data table (table C) by using a schematic diagram of a process of associating the second data table with the third data table according to an embodiment of the present application as shown in fig. 5, and associating data values that satisfy the screening condition to obtain a fourth data table (table D), where data values that do not satisfy the screening condition are not associated.
In an exemplary embodiment, each query data value of the query data field in the second data table may be matched with the screening condition in the third data table by, but is not limited to: comparing the first data in each query data value with the second data in each extended data value of a target extended field in the third data table, wherein the extended data value of the target extended field is used for indicating the screening condition; and under the condition that the first data is consistent with the second data 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.
Optionally, in this embodiment, the first data in each query data value is compared with the second data in each extended data value of the target extended field in the third data table, where the first data and the second data may be, but are not limited to be, equal, for example, fig. 6 is a schematic diagram of a matching process between the second data table (table a) and the third data table (table C) according to an embodiment of the present application, as shown in fig. 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 may be, but are not limited to be, compared, and in a case that the data values are equal, it is determined that the screening condition matches successfully.
In the technical solution provided in step S208, the data satisfying the target query condition is queried from the fourth data table to obtain the target data table, but not limited to, data query is performed on the data of the fourth data table according to the target query condition, and due to the pre-screening and association processing, a cartesian product included in the fourth data table is greatly reduced.
In an exemplary embodiment, the data satisfying the target query condition may be queried from the fourth data table, but is not limited to, obtaining the target data table by: acquiring a query data value of the query data field and a reference data value of the reference data field which are included in the fourth data table; and deleting the data of which the query data value and the reference data value do not meet the target query condition from the fourth data table to obtain the target data table.
Optionally, in this embodiment, before obtaining the target data table, data that the query data value and the reference data value do not satisfy the target query condition may also be deleted, for example, fig. 7 is a schematic diagram of generating the target data table according to an embodiment of the present application, and as shown in fig. 7, data that does not satisfy the target query condition (On _ tm ≦ Event _ tm ≦ Off _ tm) is deleted by comparing the query data value of Event _ tm with the extended data value of On _10min _ tm, so as to obtain the target data table.
In an exemplary embodiment, the target data table may be obtained by, but is not limited to, deleting the data of which the query data value and the reference data value do not satisfy the target query condition from the fourth data table by: deleting data of which the query data value and the reference data value do not meet 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.
Optionally, in this embodiment, the filtering condition may also be deleted after obtaining the target data table, fig. 8 is a flow chart of generating the target data table according to the embodiment of the present application, and as shown in fig. 8, first delete data whose query data value and reference data value do not satisfy the target query condition in the fourth data table as a candidate data table, and then delete the filtering condition (on _10min _ tm) in the candidate data table to obtain the target data table.
In order to better understand the process of the data query method, the following describes the data query method flow with reference to an optional embodiment, but the present invention is not limited to the technical solution of the embodiment of the present application.
In this embodiment, a data query method is provided, and fig. 9 is a schematic diagram of a data query method according to an embodiment of the present application, as shown in fig. 9, the method mainly includes the following steps:
step S901: acquiring data of an A table and data of a B table;
step S902: expanding according to the rule to obtain an expanded field corresponding to the B table;
step S903: expanding the data of the B table according to the obtained expansion field to obtain a C table;
step S904: associating the A table with the C table;
step S905: and filtering the data set obtained by association to obtain a target data set.
Through the implementation mode, the calculation method for generating the Cartesian product in the process of processing the inequality association of the large data table is provided, and the association complexity is reduced by expanding new association relation fields and data sets. The time field characteristic is used for expanding, and further the time field characteristic can be popularized to other fields with characteristics.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method of the embodiments of the present application.
Fig. 10 is a block diagram of a data query device according to an embodiment of the present application; as shown in fig. 10, includes:
a receiving module 1002, configured to receive a data query request, where the data query request is used to request to query data in which an associated data table among a plurality of data tables 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;
an expanding module 1004, configured to respond to the data query request, and expand a first data table including the reference data field in the multiple data tables into a third data table according to the reference data field and the target query condition, where the third data table carries a screening condition for performing pre-screening on data;
an associating module 1006, configured to associate a second data table with the third data table according to a matching relationship between a query data field and the screening condition, so as to obtain a fourth data table, where the second data table is a data table including the query data field in the multiple data tables;
a query module 1008, configured to query the fourth data table for data meeting the target query condition to obtain a target data table.
Through the embodiment, after receiving a query request for querying associated data tables among a plurality of data tables, querying according to an unequal relation between a query data field and a reference data field indicated by a target query condition, first expanding a first data table including the reference data field into a third data table, wherein the expanded content includes a screening condition for pre-screening data, in a subsequent association process, the query data field is matched with the screening condition, only data successfully matched with the query data field and the screening condition is associated, data unsuccessfully matched with the screening condition is not associated, and before association, through the pre-screening operation, Cartesian products generated by association are greatly reduced, and huge Cartesian products generated by directly performing unequal association on a plurality of associated data tables are avoided, the reduction of the Cartesian product can effectively improve the efficiency of data query, and finally, data can be efficiently queried in the fourth data table obtained through association according to the target query condition. By adopting the technical scheme, the problems of low data query efficiency and the like in the related technology are solved, and the technical effect of improving the data query efficiency is realized.
In an exemplary embodiment, the expansion module includes:
a first adding unit, configured to add a target extension field in the first data table according to the reference data field and the target query condition, so as to obtain an extension data table;
a determining unit, configured to determine, according to a relationship between a reference data value of the reference data field and the target extension field, an extension data value of the target extension field corresponding to the reference data value, where the extension data value of the target extension field is used to indicate the screening condition;
and the second adding unit is used for adding the extended data value into the extended data table to obtain the third data table.
In an exemplary embodiment, the first adding unit is configured to:
constructing the target extension field according to the reference data field and the target query condition;
and adding a data column corresponding to the target extension field in the first data table to obtain the extension data table.
In an exemplary embodiment, the association module includes:
a matching unit, 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;
and the association unit is used for associating each query data value of the query data field in the second data table with the data successfully matched with the screening conditions in the third data table to obtain a fourth data table.
In an exemplary embodiment, the matching unit is configured to:
comparing the first data in each query data value with the second data in each extended data value of a target extended field in the third data table, wherein the extended data value of the target extended field is used for indicating the screening condition;
and under the condition that the first data is consistent with the second data 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.
In an exemplary embodiment, the query module includes:
an obtaining unit, configured to obtain a query data value of the query data field and a reference data value of the reference data field included in the fourth data table;
and the deleting unit is used for deleting the data of which the query data value and the reference data value do not meet the target query condition from the fourth data table to obtain the target data table.
In an exemplary embodiment, the deleting unit is configured to:
deleting data of which the query data value and the reference data value do not meet 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.
Embodiments of the present application also provide a storage medium including a stored program, where the program performs any one of the methods described above when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store program codes for performing the following steps:
s1, receiving a data query request, wherein the data query request is used for requesting to query data of an associated data table among a plurality of data tables, which meet a target query condition, and the target query condition is used for indicating an inequality relation between a query data field and a reference data field;
s2, responding to the data query request, and expanding a first data table including the reference data fields in the multiple data tables into a third data table according to the reference data fields and the target query conditions, wherein the third data table carries screening conditions for pre-screening data;
s3, associating a second data table with the third data table according to the matching relation between the query data field and the screening condition to obtain a fourth data table, wherein the second data table is a data table comprising the query data field in the plurality of data tables;
and S4, querying the data meeting the target query condition from the fourth data table to obtain a target data table.
Embodiments of the present application further provide an electronic device comprising a memory having a computer program stored therein and a processor configured to execute the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, receiving a data query request, wherein the data query request is used for requesting to query data of which associated data tables among a plurality of data tables meet target query conditions, and the target query conditions are used for indicating inequality relations between query data fields and reference data fields;
s2, responding to the data query request, and expanding a first data table including the reference data fields in the multiple data tables into a third data table according to the reference data fields and the target query conditions, wherein the third data table carries screening conditions for pre-screening data;
s3, associating a second data table with the third data table according to the matching relation between the query data field and the screening condition to obtain a fourth data table, wherein the second data table is a data table comprising the query data field in the plurality of data tables;
and S4, querying the data meeting the target query condition from the fourth data table to obtain a target data table.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing program codes, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present application described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (10)

1. A method for querying data, comprising:
receiving a data query request, wherein the data query request is used for requesting to query data of an associated data table among a plurality of data tables, and the associated data table meets a target query condition, and the target query condition is used for indicating an inequality relation between a query data field and a reference data field;
responding to the data query request, and expanding a first data table comprising the reference data fields in the multiple data tables into a third data table according to the reference data fields and the target query conditions, wherein the third data table carries screening conditions for pre-screening data;
associating a second data table with the third data table according to the matching relation between the query data fields and the screening conditions to obtain a fourth data table, wherein the second data table is a data table comprising the query data fields in the plurality of data tables;
and querying the data meeting the target query condition from the fourth data table to obtain a target data table.
2. The method according to claim 1, wherein the expanding the first data table including the reference data field in the plurality of data tables into a third data table comprises:
adding a target extension field in the first data table according to the reference data field and the target query condition to obtain an extension data table;
determining an extended data value of the target extended field corresponding to the reference data value according to a relation between the reference data value of the reference data field and the target extended field, wherein the extended data value of the target extended field is used for indicating the screening condition;
and adding the extended data value into the extended data table to obtain the third data table.
3. The method according to claim 2, wherein the adding a target extension field to the first data table according to the reference data field and the target query condition to obtain an extended data table comprises:
constructing the target extension field according to the reference data field and the target query condition;
and adding a data column corresponding to the target extension field in the first data table to obtain the extension data table.
4. The method according to claim 1, wherein the 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 a fourth data table comprises:
matching each query data value of the query data field in the second data table with the screening condition in the third data table;
and associating each query data value of the query data field in the second data table with the data successfully matched with the screening conditions in the third data table to obtain a fourth data table.
5. The method according to claim 4, wherein the matching each query data value of the query data field in the second data table with the filtering condition in the third data table comprises:
comparing the first data in each query data value with the second data in each extended data value of a target extended field in the third data table, wherein the extended data value of the target extended field is used for indicating the screening condition;
and under the condition that the first data is consistent with the second data 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.
6. The method according to claim 1, wherein the querying the data satisfying the target query condition from the fourth data table to obtain a target data table includes:
acquiring a query data value of the query data field and a reference data value of the reference data field which are included in the fourth data table;
and deleting the data of which the query data value and the reference data value do not meet the target query condition from the fourth data table to obtain the target data table.
7. The method according to claim 6, wherein the deleting the data of which the query data value and the reference data value do not satisfy the target query condition from the fourth data table to obtain the target data table comprises:
deleting data of which the query data value and the reference data value do not meet 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.
8. An apparatus for querying data, comprising:
the data query module is used for requesting to query data, of which associated data tables among a plurality of data tables meet target query conditions, and the target query conditions are used for indicating an inequality relation between a query data field and a reference data field;
an expansion module, configured to respond to the data query request, expand a first data table including the reference data field in the multiple data tables into a third data table according to the reference data field and the target query condition, where the third data table carries a screening condition for performing pre-screening on data;
the association module is used for associating a second data table with the third data table according to the matching relation between the query data fields and the screening conditions to obtain a fourth data table, wherein the second data table is a data table comprising the query data fields in the plurality of data tables;
and the query module is used for querying the data meeting the target query condition from the fourth data table to obtain a target data table.
9. A computer-readable storage medium, comprising a stored program, wherein the program when executed performs the method of any of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 7 by means of the computer program.
CN202210297160.1A 2022-03-24 2022-03-24 Data query method and device, storage medium and electronic device Pending CN114840557A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210297160.1A CN114840557A (en) 2022-03-24 2022-03-24 Data query method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210297160.1A CN114840557A (en) 2022-03-24 2022-03-24 Data query method and device, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN114840557A true CN114840557A (en) 2022-08-02

Family

ID=82562418

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210297160.1A Pending CN114840557A (en) 2022-03-24 2022-03-24 Data query method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN114840557A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024046352A3 (en) * 2022-09-02 2024-04-18 顺丰科技有限公司 Data query method and apparatus, and computer device and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024046352A3 (en) * 2022-09-02 2024-04-18 顺丰科技有限公司 Data query method and apparatus, and computer device and storage medium

Similar Documents

Publication Publication Date Title
CN112311612B (en) Information construction method and device and storage medium
WO2023168856A1 (en) Associated scene recommendation method and device, storage medium, and electronic device
CN114840557A (en) Data query method and device, storage medium and electronic device
CN114697150B (en) Command issuing method and device, storage medium and electronic device
CN111046081A (en) Access method and system for industrial time sequence data
CN116107975A (en) Control method and device of equipment, storage medium and electronic device
CN115291793A (en) Attribute data conversion method and device, storage medium and electronic device
CN116027937A (en) Rendering method and device of component to be edited, storage medium and electronic device
CN114924908A (en) Data backup method and device, storage medium and electronic device
CN115345225A (en) Method and device for determining recommended scene, storage medium and electronic device
CN115048392A (en) Data deletion method and device, storage medium and electronic device
CN115221336A (en) Method and device for determining food storage information, storage medium and electronic device
CN111143311B (en) Inter-application association determination and log association search methods, devices, media and equipment
CN114915514A (en) Intention processing method and device, storage medium and electronic device
CN108763498B (en) User identity identification method and device, electronic equipment and readable storage medium
CN108733668B (en) Method and device for querying data
CN111488490A (en) Video clustering method, device, server and storage medium
CN117743461A (en) Data synchronization method and device, storage medium and electronic device
CN111125223B (en) Database connection pool updating method and device
CN110781370B (en) Mobile terminal information query method and computer equipment
CN115480809A (en) Method and device for determining code submission amount, storage medium and electronic device
CN116756480A (en) Data statistics method and device, storage medium and electronic device
CN116521767A (en) Data information determining method and device, storage medium and electronic device
CN118132179A (en) Display method and device of sorting result, storage medium and electronic device
CN115269926A (en) Family map determination method and device, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination