A data query method and device, a server, and a storage medium

By obtaining the target query information from the terminal, the server directly determines the target data from the database, solving the inefficiency problem caused by users having to write query statements for each piece of data, and achieving efficient and accurate data querying.

CN116628018BActive Publication Date: 2026-08-04CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA UNITED NETWORK COMM GRP CO LTD
Filing Date
2023-06-13
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

When users need to query multiple data points, existing technologies require writing database query statements for each data point, resulting in low data query efficiency.

Method used

A data query method is provided that, by obtaining the target query information sent by the terminal, including the target field, the identifier of the target data table, the target filter conditions, the target time interval, and the target row number, the server directly determines the target data from the target database without requiring the user to write database query statements.

Benefits of technology

It improves data query efficiency, reduces the difficulty of user operation, and ensures the accuracy and efficiency of queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116628018B_ABST
    Figure CN116628018B_ABST
Patent Text Reader

Abstract

The application provides a data query method and device, a server and a storage medium, relates to the technical field of computers, and solves the technical problem of low data query efficiency when a user needs to query a large amount of data, the user needs to write a database query statement for each data to be queried, and then the server can query the data based on the database query statement. The method comprises the following steps: obtaining a data query request sent by a terminal, wherein the data query request comprises target query information, the target query information comprises one or more of a target field, an identifier of a target data table, a target filtering condition, a target time interval and a target row number; determining target data from a target database based on the target query information, wherein the target data is data corresponding to the target query information, and the target database comprises data of each data table in a plurality of data tables; and sending a data query response to the terminal, wherein the data query response comprises the target data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data query method, apparatus, server and storage medium. Background Technology

[0002] Currently, the server can retrieve specific data from the database using user-written database query statements.

[0003] However, in the above method, when the user needs to query a large amount of data, the user needs to write a database query statement for each piece of data to be queried, and then the server can query the data based on the database query statement, which reduces the efficiency of data query. Summary of the Invention

[0004] This application provides a data query method, apparatus, server, and storage medium, which solves the technical problem that when a user needs to query a large amount of data, the user needs to write a database query statement for each piece of data to be queried, and then the server can query the data based on the database query statement, which reduces the efficiency of data query.

[0005] In a first aspect, this application provides a data query method, comprising: obtaining a data query request sent by a terminal, the data query request including target query information, the target query information including one or more of the following: target field, identifier of target data table, target filtering conditions, target time interval, and target row number; determining target data from a target database based on the target query information, the target data being the data corresponding to the target query information, the target database including data from each of multiple data tables; and sending a data query response to the terminal, the data query response including the target data.

[0006] Optionally, the data query request includes a target field and an identifier of a target data table. The target database also includes a preset correspondence, which includes identifiers of multiple data tables and configuration information corresponding to the identifier of each data table. The configuration information corresponding to the identifier of a data table includes at least one field. Determining the target data from the target database based on the target query information specifically includes: determining target configuration information based on the identifier of the target data table and the preset correspondence, where the target configuration information is the configuration information corresponding to the identifier of the target data table; and determining the data corresponding to the first field as the target data if the first field is the same as the target field, where the first field is a field included in the target configuration information.

[0007] Optionally, the configuration information corresponding to the identifier of the data table also includes at least one associated field for each field in the field. The above-mentioned determination of target data from the target database based on the target query information specifically includes: if the associated field of the first field is the same as the target field, determining the data corresponding to the first field and the data corresponding to the associated field of the first field as the target data.

[0008] Optionally, the target query information also includes a target time interval. The above-mentioned determination of target data from the target database based on the target query information further includes: determining the storage time of each data in the data corresponding to the target field; and if the target time interval includes a first time, determining the first data as the target data, where the first time is the storage time corresponding to the first data and the first data is the data included in the data corresponding to the target field.

[0009] Optionally, the target query information also includes a target row number. The above-mentioned determination of target data from the target database based on the target query information specifically includes: determining the row number corresponding to each data in the data corresponding to the target field; if the first row number is the same as the target row number, determining the second data as the target data, wherein the first row number is the row number corresponding to the second data, and the second data is the data included in the data corresponding to the target field.

[0010] Secondly, this application provides a data query device, comprising: an acquisition module, a determination module, and a sending module; the acquisition module is used to acquire a data query request sent by a terminal, the data query request including target query information, the target query information including one or more of target fields, identifiers of target data tables, target filtering conditions, target time intervals, and target row numbers; the determination module is used to determine target data from a target database based on the target query information, the target data being the data corresponding to the target query information, the target database including data from each of multiple data tables; the sending module is used to send a data query response to the terminal, the data query response including the target data.

[0011] Optionally, the aforementioned data query request includes a target field and an identifier of a target data table. The target database also includes a preset correspondence, which includes identifiers of multiple data tables and configuration information corresponding to the identifier of each of the multiple data tables. The configuration information corresponding to the identifier of a data table includes at least one field. The determining module is specifically used to determine target configuration information based on the identifier of the target data table and the preset correspondence. The target configuration information is the configuration information corresponding to the identifier of the target data table. The determining module is also specifically used to determine the data corresponding to the first field as target data if the first field is the same as the target field. The first field is a field included in the target configuration information.

[0012] Optionally, the configuration information corresponding to the identifier of the aforementioned data table also includes at least one associated field for each field in the field. The determining module is further specifically used to determine the data corresponding to the first field and the data corresponding to the associated field of the first field as the target data when the associated field of the first field is the same as the target field.

[0013] Optionally, the target query information also includes a target time interval. The determining module is further specifically used to determine the storage time of each data in the data corresponding to the target field. The determining module is further specifically used to determine the first data as the target data when the target time interval includes a first moment, where the first moment is the storage time corresponding to the first data and the first data is the data included in the data corresponding to the target field.

[0014] Optionally, the target query information mentioned above also includes a target row number. The determining module is further specifically used to determine the row number corresponding to each piece of data in the data corresponding to the target field. The determining module is further specifically used to determine the second data as the target data when the first row number is the same as the target row number. The first row number is the row number corresponding to the second data, and the second data is the data included in the data corresponding to the target field.

[0015] Thirdly, this application provides a server, including: a processor and a memory configured to store processor-executable instructions; wherein the processor is configured to execute the instructions to implement any of the optional data query methods described in the first aspect above.

[0016] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed by a server, enable the server to perform any of the optional data query methods described in the first aspect above.

[0017] The data query method, apparatus, server, and storage medium provided in this application allow the server to receive data query requests sent by a terminal. These requests include target query parameters. Since these parameters include one or more of the following: target field, target table identifier, target filter conditions, target time interval, and target row number, the server can determine the corresponding data from the target database based on these parameters and send a data query response to the terminal. In this application, the user only needs to input key query information (i.e., target query information), and the server can directly determine the target data corresponding to that query information from the target database based on the target query parameters, eliminating the need for the user to write database query statements and improving data query efficiency. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.

[0019] Figure 1 This is a schematic diagram of the network architecture of the data query system provided in the embodiments of this application;

[0020] Figure 2 A flowchart illustrating a data query method provided in an embodiment of this application;

[0021] Figure 3 A flowchart illustrating another data query method provided in an embodiment of this application;

[0022] Figure 4 A flowchart illustrating another data query method provided in an embodiment of this application;

[0023] Figure 5 A flowchart illustrating another data query method provided in an embodiment of this application;

[0024] Figure 6 A flowchart illustrating another data query method provided in an embodiment of this application;

[0025] Figure 7 A flowchart illustrating another data query method provided in an embodiment of this application;

[0026] Figure 8 A flowchart illustrating another data query method provided in an embodiment of this application;

[0027] Figure 9 This is a schematic diagram of the structure of a data query device provided in an embodiment of this application;

[0028] Figure 10 This is a schematic diagram of another data query device provided in an embodiment of this application. Detailed Implementation

[0029] The data query method, apparatus, server, and storage medium provided in the embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0030] The terms "first" and "second," etc., in the specification and drawings of this application are used to distinguish different objects, rather than to describe a specific order of objects. For example, "first data" and "second data," etc., are used to distinguish different data, rather than to describe a specific order of data.

[0031] Furthermore, the terms “comprising” and “having”, and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or apparatus.

[0032] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0033] The term "and / or" as used in this application includes using either one of two methods or using both methods simultaneously.

[0034] In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0035] The following explains some concepts involved in the data query method, apparatus, server, and storage medium provided in the embodiments of this application.

[0036] For most business system databases, the most frequently used operations are writing and reading data, with reading operations being related to data presentation and data analysis functions. In popular relational database management systems (RDMS), Structured Query Language (SQL) is an important standard tool for data interaction.

[0037] SQL encompasses all database operations and is mainly composed of five parts.

[0038] 1. Data Definition: Also known as "Database Schema Definition Language (DDL)," it defines the logical structure of a database, including four parts: database, base tables, views, and indexes.

[0039] 2. Data manipulation: also known as "data manipulation language (DML)," which includes three operations: insert, delete, and update.

[0040] 3. Data Query: Also known as "Data Query Language (DQL)," it includes data query operations.

[0041] 4. Data Control: Also known as "Data Controller Language (DCL)," it controls user access to data by granting and revoking permissions for basic tables and views.

[0042] 5. Transaction control: also known as "transaction control language (TCL)," which includes transaction commit and rollback.

[0043] DQL is a powerful query language that provides query capabilities such as aggregation, projection, filtering, and grouping. It can retrieve any data that exists in the database using appropriate methods. SQL uses a single SELECT statement, which can be combined with other statements to complete all query functions. The complete syntax of the SELECT statement can have six clauses. The complete syntax is as follows:

[0044] SELECT: A set of column names or column expressions for the target table;

[0045] FROM: a collection of base tables or (and) views;

[0046] [WHERE conditional expression];

[0047] [GROUP BY column name set;]

[0048] [HAVING group conditional expression];

[0049] [ORDER BY column_name[collection]...].

[0050] The semantics of the entire statement are as follows: From the tables listed in the FROM clause, select tuples that satisfy the conditional expression given in the WHERE clause, then group them according to the values ​​of the columns specified in the GROUP BY clause, then extract those groups that satisfy the group conditional expression in the HAVING clause, and evaluate and output them according to the column names or column expressions given in the SELECT clause; the ORDER BY clause reorders the target table of the output, and can be supplemented with ASC (ascending) or DESC (descending) sorting.

[0051] While SQL offers powerful query capabilities, it is primarily a tool for database developers or administrators. For developers of business systems, mastering SQL requires a significant learning curve, and directly using SQL in business system development also has some drawbacks:

[0052] 1. Query statements need to be written separately for each data table. As the scale of the business system continues to expand and the number of data tables increases, the number of query statements that need to be written also increases.

[0053] 2. Data table definitions in the same type of business system are highly similar, so query statements for different tables will also be highly similar, causing redundancy and making maintenance difficult.

[0054] 3. SQL query statements themselves do not perform query performance checks. Inexperienced or unfamiliar users may write query statements with low execution efficiency, which may even cause the database to crash.

[0055] 4. There are recommended writing standards for SQL statements, which help improve readability, but no mandatory validation is performed. Users may write statements with messy formatting and poor readability.

[0056] 5. When developing business systems, SQL query statements are scattered across various source code files, which is not an ideal code structure. Even with the introduction of object-relational mapping (ORM) frameworks such as MyBatis and Hibernate, which achieves some separation between code and scripts, a large number of program files are still generated.

[0057] As described in the background art, in related technologies, when a user needs to query a large amount of data, the user needs to write a database query statement for each piece of data to be queried, and then the server can query the data based on the database query statement, which reduces the efficiency of data query. Therefore, embodiments of this application provide a data query method, apparatus, server, and storage medium. The user only needs to input key query information (i.e., target query information), and the server can directly determine the target data corresponding to the target query information from the target database based on the target query parameters, without requiring the user to write a database query statement, thus improving data query efficiency.

[0058] The data query method, apparatus, server, and storage medium provided in this application embodiment can be applied to a data query system, such as... Figure 1 As shown, the data query system includes a terminal 101 and a server 102. Typically, in practical applications, the connection between these devices can be wireless. To conveniently and intuitively illustrate the connection relationships between the devices, Figure 1 Solid lines are used to represent the meaning.

[0059] The terminal 101 can be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, cellular phone, personal digital assistant (PDA), augmented reality (AR) / virtual reality (VR) device, etc. This disclosure does not impose any special restrictions on the specific form of the terminal. It can interact with the user through one or more methods such as a keyboard, touchpad, touchscreen, remote control, voice interaction, or handwriting device. In this embodiment, the terminal 101 can send a data query request to the server 102. The data query request includes target query information, which includes one or more of the following: target field, identifier of target data table, target filtering conditions, target time interval, and target row number.

[0060] Server 102 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN) services, and big data and artificial intelligence platforms. In this embodiment, server 102 can determine target data from the target database based on the target query information and send a data query response to terminal 101, which includes the target data.

[0061] The data query method, apparatus, server, and storage medium provided in this application are applied in data query scenarios. When the server receives a data query request sent by the terminal, it can determine the target data from the target database based on the target query information included in the data query request, and then send a data query response to the terminal.

[0062] like Figure 2 As shown, the data query method provided in this application embodiment may include S101-S103.

[0063] S101, The server receives the data query request sent by the terminal.

[0064] The data query request includes target query information, which includes one or more of the following: target field, target data table identifier, target filter conditions, target time interval, and target row number.

[0065] It should be understood that this data query request is used to request data corresponding to the target query information.

[0066] It is understandable that a data table contains multiple columns, and the target field can be the name of one of the columns in the target data table.

[0067] In this embodiment of the application, the target filtering condition is used to filter the data to obtain data that meets the filtering condition.

[0068] Optionally, the target filtering condition can be a data type or a data value.

[0069] For example, assuming the target field is age, the target filter condition could be "under 22 years old".

[0070] Optionally, the identifier of the target data table can be the name of the target data table.

[0071] In one implementation, the terminal can obtain the target query information entered by the user account and then send the data query request to the server.

[0072] S102, The server determines the target data from the target database based on the target query information.

[0073] The target data refers to the data corresponding to the target query information, and the target database includes data from each of multiple data tables.

[0074] Specifically, the server can determine the target data from the target database based on one or more of the following: target field, target data table identifier, target filter conditions, target time interval, and target row number.

[0075] It should be understood that the target data is the data contained in one of the multiple data tables.

[0076] In one alternative implementation, the server can use the target query information as an input parameter to input into the data query model to obtain the target data.

[0077] In another alternative implementation, the server can also construct a Structured Query Language (SQL) query statement based on the target query information, and then determine the target data based on the SQL query statement.

[0078] S103, The server sends a data query response to the terminal.

[0079] The data query response includes the target data.

[0080] In one alternative implementation, the server may construct an SQL statement based on the target data to return data to the terminal, and then send the data query response to the terminal by executing the SQL statement.

[0081] Optionally, the data query response may also include the quantity of the target data.

[0082] For example, when the target data is a data table, the number of the target data can be the number of rows in the data table.

[0083] Optionally, the terminal may receive the data query response and then display or save the target data.

[0084] The technical solution provided by the above embodiments can bring at least the following beneficial effects: As shown in S101-S103, the server can obtain the data query request sent by the terminal. The data query request includes target query parameters. Since the target query parameters include one or more of the following: target field, target data table identifier, target filtering conditions, target time interval, and target row number, the server can determine the data corresponding to one or more of the target field, target data table identifier, target filtering conditions, target time interval, and target row number from the target database based on the data query parameters, and send a data query response to the terminal. In this embodiment, the user only needs to input the key information of the query (i.e., the target query information), and the server can directly determine the target data corresponding to the target query information from the target database based on the target query parameters, without the user having to write a database query statement, thus improving the data query efficiency.

[0085] In one implementation of this application, the data query request includes a target field and an identifier of a target data table. The target database also includes a preset correspondence, which includes identifiers of multiple data tables and configuration information corresponding to the identifier of each data table. The configuration information corresponding to the identifier of a data table includes at least one field. Figure 2 ,like Figure 3 As shown, the server determines the target data from the target database based on the target query information, which may specifically include S1021-S1022.

[0086] S1021. The server determines the target configuration information based on the identifier of the target data table and the preset correspondence.

[0087] The target configuration information is the configuration information corresponding to the identifier of the target data table.

[0088] It should be understood that the configuration information corresponding to the identifier of a data table is used to characterize the configuration items of each field in at least one of the fields included in the data table.

[0089] Optionally, the configuration information corresponding to the identifier of a data table may also include the presentation order of at least one field.

[0090] Optionally, a field's configuration options may include the field name, Chinese comments for the field, data type for the field, conversion expression for the field, storage unit for the field, and rendering unit for the field.

[0091] Wherein, the field name is the name of the field in the data table; the Chinese comment of the field is the content displayed when the field is displayed on the terminal; the data type of the field is the data type of the corresponding data in the data table, such as number; the storage unit of the field is the unit in which the corresponding data is stored in the database, such as seconds; the presentation unit of the field is the unit in which the corresponding data is displayed on the terminal, such as milliseconds; and the conversion expression of the field is the expression that converts the data stored in the database to the unit displayed on the terminal.

[0092] For example, assuming the storage unit of this field is milliseconds and the presentation unit of this field is seconds, then the conversion expression for this field is an expression that converts milliseconds to seconds.

[0093] In one optional implementation, the target database can store the preset correspondence in the form of a data table. Specifically, each row of data in the data table can store a configuration item for a field and the identifier of the data table corresponding to that field. The server can determine the target configuration information (i.e., multiple rows of data) corresponding to the identifier of the target data table based on the identifier of the data table corresponding to each row of data.

[0094] For example, Table 1 below is an example of a preset correspondence stored in the target database.

[0095] Table 1

[0096] Data table identifier Configuration information Data Table 1 Configuration Information 1 Data Table 2 Configuration Information 2 Data Table 3 Configuration Information 3

[0097] As shown in Table 1, this preset correspondence includes identifiers for three data tables. Data table 1 corresponds to configuration information one, data table 2 corresponds to configuration information two, and data table 3 corresponds to configuration information three. Assuming the identifier for the target data table is data table 1, the server can determine that the target configuration information is configuration information three.

[0098] S1022. If the first field is the same as the target field, the server will determine the data corresponding to the first field as the target data.

[0099] The first field is a field included in the target configuration information.

[0100] It should be understood that the target field is the field to be queried. If the first field is the same as the target field, it means that the first field is the field to be queried. At this time, the server can query the data corresponding to the first field and then determine the data corresponding to the first field as the target data.

[0101] In one implementation, the server can use a cursor to traverse the target configuration information and then determine whether the fields included in the target configuration information are the same as the target field.

[0102] In one alternative implementation, the server may create a temporary data table (e.g., a first data table), and if the first field is the same as the target field, determine the first field as a field of the temporary data table, and then insert the data corresponding to the first field into the first data table.

[0103] Optionally, the server may construct an SQL query statement for inserting data based on the first field and the identifier of the target data table, and then insert the data corresponding to the first field into the first data table based on the SQL query statement.

[0104] Optionally, the server may also use the first data table as the target data and then send the first data table to the terminal.

[0105] Optionally, the server may also construct an SQL query statement to return data based on the target data (e.g., the first data table), and then send the first data table to the terminal based on the SQL query statement for inserting data.

[0106] The technical solution provided by the above embodiments can bring at least the following beneficial effects: As shown in S1021-S1022, when the target query information includes the identifier of the target field and the target data table, the server can determine the target configuration information based on the identifier of the target data table and the preset correspondence. Since the target configuration information is used to characterize the configuration item of each field in at least one field included in the target data table, the server determines the data corresponding to the first field as the target data when the first field is the same as the target field, which can accurately determine the data to be queried and improve the accuracy of data query. In this embodiment, the server defines configuration information for each data table, and then can query relevant data based on the configuration information and the target query information, reducing the difficulty of data query for users and accurately retrieving the data to be queried from the database.

[0107] In one implementation of this application, the configuration information corresponding to the identifier of a data table further includes at least one associated field for each field, combined with... Figure 3 ,like Figure 4 As shown, the server determines the target data from the target database based on the target query information, and also includes S1023.

[0108] S1023. If the associated field of the first field is the same as the target field, the server determines the data corresponding to the first field and the data corresponding to the associated field of the first field as the target data.

[0109] It should be understood that there may be relationships between fields in different data tables. When there is a relationship between a field in one data table (e.g., the second field table) and a field in another data table (e.g., the third field), it means that there is a relationship between the data corresponding to the first field and the data corresponding to the second field. The server needs to obtain the data that corresponds to both the third field and the second field.

[0110] In this embodiment of the application, the server can determine whether at least one field included in the target configuration information and the associated field of each of the at least one field are the same as the target field. If the associated field of the first field is the same as the target field, it indicates that the associated field of the first field is the field to be queried. At this time, the server needs to determine the data corresponding to the first field and the data corresponding to the associated field of the first field as the target data.

[0111] For example, suppose the target data table is a student table, the target field is "teacher name", the configuration information of the target data table includes the fields "student name" and "teacher ID", the associated field of the "teacher ID" is "teacher name", and the "teacher name" field is included in the second data table. In this case, the server can determine the data corresponding to the "teacher ID" in the student table and the data corresponding to the "teacher name" in the second data table as the target data.

[0112] Specifically, the target data consists of the ID of each teacher in the student table, and the name of the teacher corresponding to each teacher ID.

[0113] Optionally, the server can determine both the "Teacher Name" field and the "Teacher ID" field as fields in the first data table mentioned above, and then insert the data corresponding to the "Teacher Name" field and the data corresponding to the "Teacher ID" field.

[0114] In an alternative implementation, the server can store the associated fields of each field in the target database as an index, thereby improving the association performance.

[0115] Optionally, the server can set different identifiers for the fields included in the current data table and the related fields of the fields included in the current data table, and then determine whether the field needs to be associated with other fields based on the identifier.

[0116] Optionally, the server can use the number "1" to identify that the field is included in the current data table, and use the number "0" to indicate that the field needs to be associated with other fields.

[0117] For example, assuming the identifier of the "Teacher ID" field in the student table is the number "0", the server can determine that the data corresponding to the "Teacher ID" field and the data corresponding to the associated fields of the "Teacher ID" field are the target data; assuming the identifier of the "Teacher Name" field in the student table is the number "1", the server can determine that the data corresponding to the "Teacher ID" field are the target data.

[0118] In this embodiment, the target database can store the associated fields of each field in the configuration information corresponding to the identifier of each data table. Data from another data table can be queried through the association between fields of different data tables. When the associated field of the first field is the same as the target field, the server determines the data corresponding to the first field and the data corresponding to the associated field of the first field as the target data, thereby improving the efficiency and accuracy of data query.

[0119] In one implementation of this application, the target query information further includes a target time interval, combined with... Figure 3 ,like Figure 5 As shown, the server determines the target data from the target database based on the target query information, and also includes S1024-S1025.

[0120] S1024. The server determines the storage time of each piece of data in the data corresponding to the target field.

[0121] Based on the description of the above embodiments, it should be understood that the target field is the column name of a certain column in the target data table, the data corresponding to the target field is the data of that certain column, and the storage time is the time when the data is stored in the data table.

[0122] In one alternative implementation, the target field may correspond to multiple data points, and the server can determine the storage time of each of these multiple data points.

[0123] Alternatively, the server can determine the storage time of each piece of data from the target data table.

[0124] Optionally, the configuration information corresponding to the identifier of the target data table may also include the storage time of each time point, and the server may also determine the storage time of each data point from the configuration information corresponding to the identifier of the target data table.

[0125] S1025. If the target time interval includes the first moment, the server will determine the first data as the target data.

[0126] Wherein, the first moment is the storage moment corresponding to the first data, and the first data is the data included in the data corresponding to the target field.

[0127] It should be understood that if the target time interval is included in the target query information, it means that the data query request is used to request data within the target time interval.

[0128] Optionally, the target query information may also include a start time and an end time, and the target time interval is the time interval between the start time and the end time.

[0129] It is understandable that if the target time interval includes the first moment, it means that the first data is the data stored within the target time interval. In this case, the server can identify the first data as the target data.

[0130] It should be noted that if the target time interval includes the storage times of multiple data points, the server can identify all of these multiple data points as the target data.

[0131] In an alternative implementation, the target query information may further include target filtering conditions, and the server may determine the data that meets the preset filtering conditions from the data that corresponds to both the identifier and the target field of the target data table as target data.

[0132] Optionally, the server can construct an SQL statement for inserting data based on the identifier of the target data table, the target field, the target time interval (and / or the target filter conditions), and then determine the target data based on the SQL statement for inserting data.

[0133] In this embodiment of the application, when the target query information also includes a target time interval, and the target time interval includes a first moment, the server determines the first data as the target data, which can improve the accuracy of data query.

[0134] In one implementation of this application, the target query information further includes the target row number, combined with... Figure 3 ,like Figure 6 As shown, the server determines the target data from the target database based on the target query information, and also includes S1026-S1027.

[0135] S1026. The server determines the row number corresponding to each piece of data in the target field.

[0136] It should be understood that if the target row number is included in the target query information, it means that the data query request is used to request the data corresponding to the target row number among the data corresponding to other information included in the target query information.

[0137] In this embodiment of the application, when the server creates the first data table, it can identify the row number of each row in the first data table. After the server inserts the data corresponding to the target field into the first data table, it can obtain the row number corresponding to each data in the data corresponding to the target field.

[0138] S1027. If the first row number is the same as the target row number, the server will determine the second data as the target data.

[0139] Wherein, the first row number is the row number corresponding to the second data, and the second data is the data included in the data corresponding to the target field.

[0140] It is understandable that if the first row number is the same as the target row number, it means that the data corresponding to the first row number is the data requested by the data query request. In this case, the server can determine the data corresponding to the first row number as the target data.

[0141] It should be noted that there can be multiple target row numbers and multiple target data.

[0142] In one alternative implementation, the server may also create a second data table, which includes the same target fields as the first data table. After determining the data corresponding to the target row number, the server can insert the data corresponding to the target row number into the second data table and then send the second data table to the terminal.

[0143] Optionally, the server may send the total row number included in the first data table to the terminal.

[0144] In this embodiment of the application, when the target query information also includes a target row number, the server can determine the row number corresponding to each data in the data corresponding to the target field, and if the first row number is the same as the target row number, the second data is determined as the target data, so as to accurately determine the data corresponding to the target query information.

[0145] The following example illustrates the data query method provided in the embodiments of this application.

[0146] like Figure 7 As shown, the data query method includes S201-S207.

[0147] S201. Obtain input parameters.

[0148] The input parameters include the target field, the name of the target data table, the target row number, the query start date, the query end date, and the target filter conditions.

[0149] S202. Load the configuration information of the target data table.

[0150] Specifically, the server determines the configuration information corresponding to the name of the target data table based on the name of the target data table and the preset correspondence.

[0151] S203. Define temporary table a.

[0152] The temporary table 'a' is used to store all data that meets the filtering conditions.

[0153] Specifically, the steps for the server to construct the temporary table creation statement are as follows:

[0154] 1. Use a cursor to traverse all configuration information corresponding to the name of the target data table, determine whether the fields included in the configuration information are taken from the main table, and whether they exist in the "target fields". If so, add the field to the fields of the temporary table.

[0155] 2. Based on the input parameter "target field", check one by one whether the target field is a field that needs to be joined with other tables to obtain. If it exists, the joined field is also used as a field of the temporary table.

[0156] 3. Add an auto-incrementing field to the temporary table to identify the row number, which will be used to implement the pagination function.

[0157] 4. Define indexes on related fields to improve join performance.

[0158] It should be noted that the server may have created the temporary table a during a historical period, and the server may store the temporary table a. If the server stores the temporary table a, it can first delete the stored temporary table a, and then recreate the temporary table a.

[0159] S204. Insert data into temporary table a.

[0160] Specifically, the key steps in constructing the SQL statement for inserting data are as follows:

[0161] 1. The fields are consistent with the fields of temporary table a in S203.

[0162] 2. The name of the data table is the same as the name of the target data table for the input parameters.

[0163] 3. Combine the target filtering conditions passed in, as well as the query start time and query end time.

[0164] 4. Get the total number of data in temporary table a and store the number in a variable.

[0165] S205. Define temporary table b.

[0166] It should be understood that the structure of temporary table b is exactly the same as that of temporary table a, and temporary table b is used to store the data after pagination.

[0167] S206. Insert data into temporary table b.

[0168] Specifically, the pagination information of the input parameter is used as a filtering condition to filter the row numbers of temporary table a, and the data of temporary table a is inserted into temporary table b. Thus, the paginated data is stored in temporary table b.

[0169] It should be noted that the server may have created the temporary table b during a historical period, and the server may store the temporary table b. If the server stores the temporary table b, it can first delete the stored temporary table b, and then recreate the temporary table b.

[0170] S207. Construct and execute the SQL statement that returns data from the temporary table b.

[0171] First, construct a "set of column names or column expressions of the target table". The set contains two parts: one part is the set of all columns in the temporary table b, and the other part parses whether the field of the associated table exists in the input parameter "target field". If it exists, add the corresponding field name of the associated table.

[0172] 2) Construct a "base table or (and) view collection", where the main table is the temporary table b. Then, parse whether the field of the associated table exists in the input parameter "target field". If it does, associate the associated table.

[0173] 3) Construct the "WHERE condition expression". Since the temporary table b stores all data that meets the condition and has been paginated, no processing is required here.

[0174] Understandably, the server can also return the total number of rows in temporary table a to the terminal (for the front end to calculate the total number of pages).

[0175] The following example illustrates the data query method provided in this application embodiment.

[0176] like Figure 8As shown, the client initiates a stored procedure call to the data query model, passing in parameters (specifically, the target field, the name of the target data table, the target row number, the query start date, the query end date, and the target filter conditions). The stored procedure reads the configuration of the target data table and uses the key technology of dynamic statement execution to process the data sequentially (see S203-S207 above for details). Finally, the query results are returned to the client.

[0177] This application embodiment can divide the server and other components into functional modules according to the above method examples. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.

[0178] When dividing each function into modules according to its corresponding function. Figure 9 A possible structural diagram of the data query device involved in the above embodiments is shown, such as... Figure 9 As shown, the data query device 20 may include: an acquisition module 201, a determination module 202, and a sending module 203.

[0179] The acquisition module 201 is used to acquire a data query request sent by the terminal. The data query request includes target query information, which includes one or more of the following: target field, identifier of target data table, target filter conditions, target time interval, and target row number.

[0180] The determination module 202 is used to determine the target data from the target database based on the target query information. The target data is the data corresponding to the target query information. The target database includes data from each of multiple data tables.

[0181] The sending module 203 is used to send a data query response to the terminal, the data query response including the target data.

[0182] Optionally, the above data query request includes the identifier of the target field and the identifier of the target data table. The target database also includes a preset correspondence, which includes the identifiers of multiple data tables and the configuration information corresponding to the identifier of each data table. The configuration information corresponding to the identifier of a data table includes at least one field.

[0183] The determination module 202 is specifically used to determine the target configuration information based on the identifier of the target data table and the preset correspondence. The target configuration information is the configuration information corresponding to the identifier of the target data table.

[0184] The determination module 202 is also specifically used to determine the data corresponding to the first field as the target data when the first field is the same as the target field, wherein the first field is a field included in the target configuration information.

[0185] Optionally, the configuration information corresponding to the identifier of the aforementioned data table may also include at least one associated field for each field in the data table.

[0186] The determining module 202 is further specifically used to determine the data corresponding to the first field and the data corresponding to the associated field of the first field as the target data when the associated field of the first field is the same as the target field.

[0187] Optionally, the target query information may also include the target time interval.

[0188] The determination module 202 is also specifically used to determine the storage time of each piece of data in the data corresponding to the target field.

[0189] The determining module 202 is further specifically used to determine the first data as target data when the target time interval includes a first moment, wherein the first moment is the storage moment corresponding to the first data, and the first data is the data included in the data corresponding to the target field.

[0190] Optionally, the target query information may also include the target row number.

[0191] The determination module 202 is also specifically used to determine the row number corresponding to each data in the data corresponding to the target field.

[0192] The determination module 202 is also specifically used to determine the second data as the target data when the first row number is the same as the target row number, wherein the first row number is the row number corresponding to the second data, and the second data is the data included in the data corresponding to the target field.

[0193] When using integrated units, Figure 10 A schematic diagram of another possible structure of the data query device involved in the above embodiments is shown. For example... Figure 10 As shown, the data query device 30 may include a processing module 301 and a communication module 302. The processing module 301 can be used to control and manage the operation of the data query device 30. The communication module 302 can be used to support communication between the data query device 30 and other entities. Optionally, as... Figure 10As shown, the data query device 30 may also include a storage module 303 for storing the program code and data of the data query device 30.

[0194] The processing module 301 can be a processor or a controller. The communication module 302 can be a transceiver, transceiver circuit, or communication interface, etc. The storage module 303 can be a memory.

[0195] In this configuration, when the processing module 301 is a processor, the communication module 302 is a transceiver, and the storage module 303 is a memory, the processor, transceiver, and memory can be connected via a bus. The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc.

[0196] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0197] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0198] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0199] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0200] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software programs, implementation can be, in whole or in part, in the form of a computer program product. This computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device containing one or more servers, data centers, etc., that can be integrated with the medium. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

[0201] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data query method, characterized by, include: Obtain a data query request sent by the terminal. The data query request includes target query information, which includes a target field, an identifier of the target data table, and at least one of the following: target filter conditions, target time interval, and target row number. The target database also includes a preset correspondence, which includes the identifiers of multiple data tables and the configuration information corresponding to the identifier of each data table. The configuration information corresponding to the identifier of a data table includes at least one field and the associated field of each of the at least one field. Target configuration information is determined based on the identifier of the target data table and the preset correspondence, wherein the target configuration information is the configuration information corresponding to the identifier of the target data table; If the first field is the same as the target field, the data corresponding to the first field is determined as the target data, and the first field is the field included in the target configuration information; If the associated field of the first field is the same as the target field, the data corresponding to the first field and the data corresponding to the associated field of the first field are determined as the target data. A data query response is sent to the terminal, and the data query response includes the target data.

2. The data query method of claim 1, wherein, The target query information also includes a target time interval, and the step of determining the target data from the target database based on the target query information further includes: Determine the storage time of each piece of data in the data corresponding to the target field; If the target time interval includes a first moment, the first data is determined as the target data, the first moment is the storage moment corresponding to the first data, and the first data is the data included in the data corresponding to the target field.

3. The data query method of claim 1, wherein, The target query information also includes the target row number, and the step of determining the target data from the target database based on the target query information further includes: Determine the row number corresponding to each piece of data in the data corresponding to the target field; If the first row number is the same as the target row number, the second data is determined as the target data, where the first row number is the row number corresponding to the second data, and the second data is the data included in the data corresponding to the target field.

4. A data query apparatus, characterized by comprising: include: The module includes an acquisition module, a determination module, and a sending module. The acquisition module is used to acquire a data query request sent by the terminal. The data query request includes target query information, which includes a target field, an identifier of a target data table, and at least one of the following: target filter conditions, target time interval, and target row number. The target database also includes a preset correspondence, which includes the identifiers of multiple data tables and the configuration information corresponding to the identifier of each data table. The configuration information corresponding to the identifier of a data table includes at least one field and the associated field of each of the at least one field. The determining module is used to determine target configuration information based on the identifier of the target data table and the preset correspondence, wherein the target configuration information is the configuration information corresponding to the identifier of the target data table; if the first field is the same as the target field, the data corresponding to the first field is determined as the target data, wherein the first field is the field included in the target configuration information; if the associated field of the first field is the same as the target field, the data corresponding to the first field and the data corresponding to the associated field of the first field are determined as the target data. The sending module is used to send a data query response to the terminal, the data query response including the target data.

5. A server, characterized by The server includes: processor; A memory configured to store processor-executable instructions; The processor is configured to execute the instructions to implement the data query method as described in any one of claims 1-3.

6. A computer-readable storage medium storing instructions thereon, characterized in that, When the instructions in the computer-readable storage medium are executed by the server, the server is able to perform the data query method as described in any one of claims 1-3.