Business query method, device and equipment and storage medium

By creating a wide table before business queries, and querying the business directly in the wide table, the problem of low efficiency in business queries in structured query language databases is solved, and efficient and accurate query results are achieved.

CN115687340BActive Publication Date: 2026-07-31DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DOUYIN VISION CO LTD
Filing Date
2021-07-28
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

In existing technologies, business query efficiency in structured query language databases is relatively low, especially when querying the main table and its associated subsidiary tables, which requires multiple join queries, resulting in low efficiency.

Method used

Before performing business queries, a wide table is created in advance based on the main table and the related subsidiary tables. During the query, the business query is performed directly in the wide table, which improves efficiency.

Benefits of technology

By creating wide tables, multiple join queries are reduced, improving the efficiency of business queries. Furthermore, data consistency is maintained through real-time and periodic updates, ensuring the accuracy of query results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115687340B_ABST
    Figure CN115687340B_ABST
Patent Text Reader

Abstract

This application provides a business query method, apparatus, device, and storage medium, comprising: obtaining a main table and at least one secondary table, wherein the main table and at least one secondary table are related to the business query; generating a wide table based on the main table and at least one secondary table; obtaining the business to be queried; querying the business to be queried in the wide table; and returning the query results. This can improve the efficiency of business queries.
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 business query method, apparatus, device, and storage medium. Background Technology

[0002] Typically, Structured Query Language (SQL) databases contain a main table and numerous subordinate tables associated with it. Currently, if a user needs to query a specific business function, they must first query the main table, and then query all the subordinate tables associated with it. Clearly, this query method is inefficient. Summary of the Invention

[0003] This application provides a business query method, apparatus, device, and storage medium, thereby improving business query efficiency.

[0004] In a first aspect, this application provides a business query method, comprising: obtaining a main table and at least one secondary table, wherein the main table and at least one secondary table are related to the business query; generating a wide table based on the main table and at least one secondary table; obtaining the business to be queried; querying the business to be queried in the wide table and returning the query results.

[0005] Secondly, this application provides a business query device, comprising: a first acquisition module, a generation module, a second acquisition module, and a query module, wherein the first acquisition module is used to acquire a main table and at least one sub-table, the main table and at least one sub-table being related to the business query; the generation module is used to generate a wide table based on the main table and at least one sub-table; the second acquisition module is used to acquire the business to be queried; and the query module is used to query the business to be queried in the wide table and return the query results.

[0006] Thirdly, an electronic device is provided, comprising: a processor and a memory for storing a computer program, the processor for calling and running the computer program stored in the memory, and performing the methods as described in the first aspect or its various implementations.

[0007] Fourthly, a computer-readable storage medium is provided for storing a computer program that causes a computer to perform the methods described in the first aspect or its various implementations.

[0008] Fifthly, a computer program product is provided, including computer program instructions that cause a computer to perform the methods as described in the first aspect or its various implementations.

[0009] Sixthly, a computer program is provided that causes a computer to perform the methods described in the first aspect or its various implementations.

[0010] In summary, through the technical solution of this application, the server can obtain a main table and at least one subordinate table, generate a wide table based on the main table and at least one subordinate table, obtain the business to be queried, query the business in the wide table, and return the query results. In other words, before performing a business query, the server pre-builds a wide table based on the main table and the subordinate tables associated with the main table; when performing a business query, it only needs to query this wide table, thereby improving the efficiency of business queries. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 A business query scenario diagram provided for this application;

[0013] Figure 2 Another business query scenario diagram provided for this application;

[0014] Figure 3 Another business query scenario diagram provided for this application;

[0015] Figure 4 A flowchart illustrating a business query method provided in this application embodiment;

[0016] Figure 5 A schematic diagram of a snowflake model provided in an embodiment of this application;

[0017] Figure 6 A flowchart illustrating a wide table data update process provided in this application embodiment;

[0018] Figure 7 A flowchart illustrating another wide table data update process provided in this application embodiment;

[0019] Figure 8 A flowchart illustrating another wide table data update process provided in this application embodiment;

[0020] Figure 9 This is a schematic block diagram of the electronic device 900 provided in an embodiment of this application. Detailed Implementation

[0021] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0022] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.

[0023] Before introducing the technical solution of this application, the relevant knowledge of the technical solution of this application will be explained below:

[0024] Primary Key: Also known as the primary key, it is a candidate key chosen to uniquely identify a row in a table. A table has only one primary key. A primary key can consist of one field or multiple fields, known as a single-field primary key or a multi-field primary key, respectively.

[0025] Foreign key: Used to associate with another table. For example, if a field in table A is the primary key in table B, then that field is a foreign key in table A.

[0026] Main table (parent table): A table created in the database, which contains a primary key used to associate with other tables and serves as a unique identifier within the main table.

[0027] Sub-table: A table whose primary key value is used as a foreign key in the parent table. It can be joined with the parent table via the foreign key.

[0028] Overview of the relationship and usage between the master table and the slave table: The data in the slave table depends on the master table. When querying data, it is necessary to perform a join query between the master table and the slave table.

[0029] Wide table: As the name suggests, a wide table is a database table with a large number of fields. It usually refers to a database table that links together metrics, dimensions, and attributes related to a business theme.

[0030] Snowflake model: When one or more slave tables are not directly connected to the master table, but are connected to the master table through other slave tables, the diagram looks like multiple snowflakes connected together, hence the name snowflake model.

[0031] It should be understood that there are currently two main methods for business queries. The first method involves querying the main table first, and then querying all related sub-tables. This is clearly inefficient. The second method arises because, with the rise of microservices, data is often scattered across various microservices. When performing a query, users need to aggregate data from these microservices. A common approach is to use one microservice as the caller, then retrieve all data meeting the specified criteria from other microservices via Remote Procedure Call (RPC). This data is then aggregated and paginated with the data from the caller. This process can be time-consuming, especially with large datasets. While pagination can be used to display large amounts of data, each query requires data aggregation and pagination, leading to low query efficiency.

[0032] To solve the above-mentioned technical problems, this application pre-creates a wide table based on the main table and the related sub-tables before performing business queries. When performing business queries, it is only necessary to query this wide table.

[0033] In some possible implementations, the technical solution of this application can be applied to the following application scenarios, but is not limited to these:

[0034] Scene 1: Figure 1 A business query scenario diagram provided for this application, such as Figure 1 As shown, server 110 locally stores a main table and at least one secondary table related to business queries. Terminal device 120 can communicate with server 110. Terminal device 120 can send a business query request to server 110. Server 110 performs a business query based on the locally stored main table and at least one secondary table, and returns the query result to terminal device 120.

[0035] Scene 2: Figure 2 Another business query scenario diagram provided for this application, such as Figure 2As shown, server 110 does not locally store the main table and at least one secondary table related to the business query. These main tables and secondary tables can be distributed on other servers 130. Terminal device 120 can communicate with server 110, and server 110 can communicate with other servers 130. Server 110 can obtain the main table and at least one secondary table from other servers 130. Terminal device 120 can send a business query request to server 110. Server 110 performs a business query based on the obtained main table and at least one secondary table, and returns the query result to terminal device 120.

[0036] Scene 3: Figure 3 Another business query scenario diagram provided for this application, such as Figure 3 As shown, server 110 locally stores a master table related to business queries, but does not store at least one slave table related to business queries. These slave tables can be distributed on other servers 130. Terminal device 120 can communicate with server 110, and server 110 can communicate with other servers 130. Server 110 can obtain at least one slave table from other servers 130. Terminal device 120 can send a business query request to server 110. Server 110 performs a business query based on the locally stored master table and the obtained at least one slave table, and returns the query result to terminal device 120.

[0037] It should be understood that in scenario three, server 110 is the server that stores the main table. In fact, server 110 that implements business queries can also be the server that stores any sub-table. In this case, server 110 can obtain the main table and other sub-tables from other servers to implement business queries. In short, this application does not limit the application scenarios of the technical solution of this application.

[0038] In some possible implementations, the terminal device may be a smartphone, tablet, laptop, desktop computer, smart speaker, wearable device, etc., but is not limited thereto, and this application does not impose any restrictions on it.

[0039] In some implementations, the server can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.

[0040] In some possible implementations, communication between the terminal device and the server, and between servers, can be conducted using cellular mobile networks or Wireless Fidelity (WiFi), etc., and this application does not impose any restrictions on this.

[0041] The technical solution of this application will be described in detail below:

[0042] Figure 4 A flowchart illustrating a business query method provided in this application embodiment, the method can be... Figure 1 , Figure 2 or Figure 3 The method, which is executed on server 110, but is not limited to this, includes the following steps:

[0043] S410: Retrieve the main table and at least one secondary table.

[0044] S420: Generate a wide table based on the main table and at least one subordinate table.

[0045] S430: Retrieve the query business.

[0046] S440: Queries the business to be queried in the wide table and returns the query results.

[0047] In some implementations, the server can obtain the master table and at least one slave table locally, as shown in Scenario 1. Alternatively, the server can obtain the master table and at least one slave table from other servers, as shown in Scenario 2. Or, the server can obtain the master table locally and at least one slave table from other servers, as shown in Scenario 3. In short, this application does not restrict how the server obtains the master table and at least one slave table.

[0048] It should be understood that both the main table and at least one subordinate table are related to the business query.

[0049] In some implementations, the server can generate a snowflake model based on a master table and at least one slave table, and then generate a wide table based on the snowflake model.

[0050] Figure 5 A schematic diagram of a snowflake model provided in an embodiment of this application, as shown below. Figure 5 As shown, the snowflake model includes a master table as its center and includes at least one first-level slave table and at least one second-level slave table. The first-level slave table is a slave table that includes data from the wide table that needs to be updated in real time, while the second-level slave table is a slave table that does not include data from the wide table that needs to be updated in real time.

[0051] It should be understood that a first-level subordinate table can be directly or indirectly related to the parent table. Similarly, a second-level subordinate table can also be directly or indirectly related to its corresponding first-level subordinate table.

[0052] It should be understood that, Figure 5 Solid lines indicate direct relationships, while dashed lines indicate indirect relationships.

[0053] It should be understood that the snowflake model represents the relationship between the main table and at least one subordinate table, based on which the wide table can be determined.

[0054] In some implementations, the server can directly generate a wide table based on the master table and at least one slave table. That is, the server does not need to build a snowflake model, but directly determines the relationship between the master table and at least one slave table, and generates the wide table based on that relationship. In summary, this application does not impose any restrictions on how a wide table is generated based on the master table and at least one slave table.

[0055] In some implementations, because the wide table contains a large number of records, the server can paginate the wide table when the pagination conditions are met.

[0056] In some implementations, the pagination condition is to paginate every N records, where N is a positive integer. However, this application does not impose any restrictions on the pagination condition. For example, if the pagination condition is to paginate every 20 records, then the server can store records 1-20 on the first page, records 21-30 on the second page, and so on.

[0057] It should be understood that a terminal device can send a query request to the server, which includes the service to be queried.

[0058] In summary, in this application, the server can obtain a main table and at least one subordinate table, generate a wide table based on the main table and at least one subordinate table, obtain the business to be queried, query the business in the wide table, and return the query results. That is, before performing a business query, the server pre-builds a wide table based on the main table and the subordinate tables associated with the main table; when performing a business query, it only needs to query this wide table, thereby improving the efficiency of business queries.

[0059] Furthermore, to ensure the accuracy of business queries, the data in the wide table must also be consistent with the main and subsidiary tables. Therefore, when the data in the main and subsidiary tables is updated, the data in the wide table also needs to be updated for consistency. The data update process will be explained below:

[0060] Figure 6 A flowchart of a wide table data update process provided for an embodiment of this application is shown below. Figure 6 As shown, this method can be derived from... Figure 1 , Figure 2 or Figure 3 The method, which is executed on server 110, but is not limited to this, includes the following steps:

[0061] S610: Get logs from the main table in real time.

[0062] S620: Determine whether there are any data updates in the main table based on the logs of the main table.

[0063] S630: If the first data in the main table is updated, then the first data in the wide table will be updated accordingly.

[0064] The first data is any data in the main table.

[0065] It should be understood that the main table includes data from the wide table that needs to be updated in real time. Therefore, the server needs to obtain the logs of the main table in real time. Once the logs of the main table indicate that the first data has been updated, such as added, deleted, or modified, the server will also update the first data in the wide table accordingly, such as added, deleted, or modified, so as to keep the data in the wide table and the main table consistent.

[0066] In this application, the server can obtain the logs of the main table in real time, determine whether there are any data updates in the main table based on the logs, and if the first data in the main table is updated, the first data in the wide table is updated accordingly to ensure that the data in the wide table is consistent with the data in the main table, thereby ensuring the accuracy of the wide table data and thus ensuring the accuracy of business queries.

[0067] Figure 7 A flowchart of another wide table data update process provided for an embodiment of this application is shown below. Figure 7 As shown, this method can be derived from... Figure 1 , Figure 2 or Figure 3 The method, which is executed on server 110, but is not limited to this, includes the following steps:

[0068] S710: Real-time acquisition of logs from first-level slave tables.

[0069] S720: Determine whether there are any data updates in the first-level slave table based on the logs of the first-level slave table.

[0070] S730: If it is determined that the second data in the first-level subordinate table has been updated, then the second data in the wide table is updated accordingly.

[0071] The second data is any data from the first-level sub-table.

[0072] It should be understood that, as mentioned above, the first-level slave table is a slave table that includes data from the wide table that needs to be updated in real time. Therefore, the server needs to obtain the logs of the first-level slave table in real time. Once the logs of the first-level slave table indicate that the second data has been updated, such as added, deleted, or modified, the server will also update the second data in the wide table accordingly, such as added, deleted, or modified, to ensure that the data in the wide table and the first-level slave table are consistent.

[0073] In this application, the server can obtain the logs of the first-level slave table in real time, and determine whether there is data update in the main table based on the logs of the first-level slave table. If the second data of the first-level slave table is updated, the second data in the wide table is updated accordingly to ensure that the data in the wide table is consistent with the data in the first-level slave table, thereby ensuring the accuracy of the wide table data and thus ensuring the accuracy of business queries.

[0074] Figure 8 A flowchart of another wide table data update process provided in the embodiments of this application is shown below. Figure 8 As shown, this method can be derived from... Figure 1 , Figure 2 or Figure 3 The method, which is executed on server 110, but is not limited to this, includes the following steps:

[0075] S810: Periodically scans all records in the main table.

[0076] S820: When scanning any record in the master table, determine whether there is any data update in at least one second-level slave table based on the association relationship between the record and at least one second-level slave table.

[0077] S830: For any second-level sub-table in at least one second-level sub-table, if the third data of the second-level sub-table is updated, then the third data in the wide table is updated accordingly.

[0078] The third data is any data from the second-level sub-table.

[0079] It should be understood that, as mentioned above, a second-level sub-table is a sub-table that does not include data in the wide table that needs to be updated in real time. Therefore, for this type of second-level sub-table, the server can update it periodically. For example, the server can update it every 20 minutes or 30 minutes. In short, this application does not impose any restrictions on the update cycle of the server for second-level sub-tables.

[0080] It should be understood that since the wide table is built around the main table, meaning it's built with the main table's entries as its dimensions, the server can periodically scan all records in the main table. Because each record in the main table is directly or indirectly related to the first-level subsidiary tables, and the first-level subsidiary tables are directly or indirectly related to the second-level subsidiary tables, when scanning each record in the main table, the server determines whether the third data in the second-level subsidiary tables has been updated based on the relationships between the main table and the first-level subsidiary tables, and between the first-level subsidiary tables and the second-level subsidiary tables. If the third data in the second-level subsidiary tables has been updated, the second data in the wide table is updated accordingly.

[0081] In this application, the server can periodically scan all records in the main table. When scanning any record in the main table, it determines whether there are any data updates in the at least one second-level subsidiary table based on the relationship between the record and at least one second-level subsidiary table. For any of the at least one second-level subsidiary table, if the third data in the second-level subsidiary table is updated, the second data in the wide table is updated accordingly, ensuring the consistency of data between the wide table and the second-level subsidiary tables, thereby guaranteeing the accuracy of the wide table data and thus ensuring the accuracy of business queries. Furthermore, since the second-level subsidiary tables do not include data from the wide table that needs to be updated in real time, the server does not need to update the second-level subsidiary tables in real time, but only periodically, thereby reducing server power consumption.

[0082] This application provides a business query device, which can be... Figure 1 , Figure 2 or Figure 3 The server 110 includes a first acquisition module, a generation module, a second acquisition module, and a query module. The first acquisition module acquires a main table and at least one secondary table, which are related to the business query. The generation module generates a wide table based on the main table and at least one secondary table. The second acquisition module acquires the business to be queried. The query module queries the wide table for the business to be queried and returns the query results.

[0083] In one possible implementation, the generation module is specifically used to: generate a snowflake model based on a master table and at least one slave table; and generate a wide table based on the snowflake model.

[0084] In one possible implementation, the business query device further includes: a third acquisition module, a first judgment module, and a first update module, wherein the third acquisition module is used to acquire the logs of the main table in real time; the first judgment module is used to determine whether there is a data update in the main table based on the logs of the main table; and the first update module is used to update the first data in the wide table accordingly if the first data in the main table is updated; wherein the first data is any data in the main table.

[0085] In one possible implementation, at least one subordinate table includes at least one first-level subordinate table and at least one second-level subordinate table; wherein, the first-level subordinate table is a subordinate table that includes data in the wide table that needs to be updated in real time, and the first-level subordinate table is directly or indirectly related to the main table, and the second-level subordinate table is a subordinate table that does not include data in the wide table that needs to be updated in real time, and the second-level subordinate table is directly or indirectly related to a first-level subordinate table.

[0086] In one possible implementation, the business query device further includes: a fourth acquisition module, a second judgment module, and a second update module, wherein the fourth acquisition module acquires the logs of the first-level sub-table in real time; the second judgment module is used to determine whether there is a data update in the first-level sub-table based on the logs of the first-level sub-table; the second update module is used to update the second data in the wide table accordingly if it is determined that the second data in the first-level sub-table has been updated; wherein the second data is any data in the first-level sub-table.

[0087] In one possible implementation, the business query device further includes: a scanning module, a third judgment module, and a third update module. The scanning module periodically scans all records in the main table. The third judgment module, when scanning any record in the main table, determines whether there is a data update in at least one second-level subsidiary table based on the relationship between the record and at least one second-level subsidiary table. The third update module, for any second-level subsidiary table, updates the third data in the wide table accordingly if the third data in that second-level subsidiary table is updated. The third data is any data item in the second-level subsidiary table.

[0088] In one possible implementation, the business query device further includes a fifth acquisition module and a pagination module, wherein the fifth acquisition module is used to acquire pagination conditions; and the pagination module is used to paginate the wide table according to the pagination conditions.

[0089] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be found in the method embodiments. To avoid repetition, further details are omitted here. Specifically, the executable... Figure 4 The corresponding method embodiments, and the foregoing and other operations and / or functions of each module in the device, are respectively for implementing Figure 4 For the sake of brevity, the corresponding processes in each method are not described in detail here.

[0090] The apparatus of this application embodiment has been described above from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that this functional module can be implemented in hardware, in software instructions, or in a combination of hardware and software modules. Specifically, the steps of the method embodiments in this application can be completed by integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in this application embodiment can be directly embodied as being executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. Optionally, the software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps in the above method embodiments.

[0091] Figure 9 This is a schematic block diagram of an electronic device 900 provided in an embodiment of this application. The electronic device may be... Figure 1 , Figure 2 or Figure 3 Server 110 is included, but not limited to this.

[0092] like Figure 9 As shown, the electronic device 900 may include:

[0093] The system includes a memory 910 and a processor 920. The memory 910 stores computer programs and transfers the program code to the processor 920. In other words, the processor 920 can retrieve and run the computer program from the memory 910 to implement the methods described in the embodiments of this application.

[0094] For example, the processor 920 can be used to execute the above-described method embodiments according to instructions in the computer program.

[0095] In some embodiments of this application, the processor 920 may include, but is not limited to:

[0096] General-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0097] In some embodiments of this application, the memory 910 includes, but is not limited to:

[0098] Volatile memory and / or non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0099] In some embodiments of this application, the computer program may be divided into one or more modules, which are stored in the memory 910 and executed by the processor 920 to perform the method provided in this application. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.

[0100] like Figure 9 As shown, the electronic device may further include:

[0101] Transceiver 930, which can be connected to processor 920 or memory 910.

[0102] The processor 920 can control the transceiver 930 to communicate with other devices; specifically, it can send information or data to other devices or receive information or data sent by other devices. The transceiver 930 may include a transmitter and a receiver. The transceiver 930 may further include antennas, and the number of antennas may be one or more.

[0103] It should be understood that the various components in the electronic device are connected through a bus system, which includes a data bus, a power bus, a control bus, and a status signal bus.

[0104] This application also provides a computer storage medium storing a computer program thereon, which, when executed by a computer, enables the computer to perform the methods of the above-described method embodiments. Alternatively, embodiments of this application also provide a computer program product containing instructions that, when executed by a computer, cause the computer to perform the methods of the above-described method embodiments.

[0105] When implemented using software, it can be implemented entirely or partially as a computer program product. This computer program product includes one or more computer instructions. When these 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 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 that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0106] According to one or more embodiments of this disclosure, a business query method is provided, comprising: obtaining a main table and at least one secondary table, wherein the main table and at least one secondary table are related to the business query; generating a wide table based on the main table and at least one secondary table; obtaining the business to be queried; querying the business to be queried in the wide table and returning the query results.

[0107] According to one or more embodiments of this disclosure, generating a wide table based on a main table and at least one secondary table includes: generating a snowflake model based on the main table and at least one secondary table; and generating a wide table based on the snowflake model.

[0108] According to one or more embodiments of this disclosure, the method further includes: acquiring the logs of the main table in real time; determining whether there is a data update in the main table based on the logs of the main table; if the first data in the main table is updated, then updating the first data in the wide table accordingly; wherein the first data is any data in the main table.

[0109] According to one or more embodiments of this disclosure, at least one sub-table includes: at least one first-level sub-table and at least one second-level sub-table; wherein, the first-level sub-table is a sub-table that includes data in the wide table that needs to be updated in real time, and the first-level sub-table is directly or indirectly associated with the main table, and the second-level sub-table is a sub-table that does not include data in the wide table that needs to be updated in real time, and the second-level sub-table is directly or indirectly associated with a first-level sub-table.

[0110] According to one or more embodiments of this disclosure, the method further includes: acquiring the logs of the first-level slave table in real time; determining whether there is a data update in the first-level slave table based on the logs; if it is determined that the second data in the first-level slave table has been updated, then updating the second data in the wide table accordingly; wherein the second data is any data in the first-level slave table.

[0111] According to one or more embodiments of this disclosure, the method further includes: periodically scanning all records of the master table; when scanning any record of the master table, determining whether there is a data update in at least one second-level sub-table based on the association relationship between the record and at least one second-level sub-table; for any second-level sub-table in the at least one second-level sub-table, if the third data of the second-level sub-table is updated, then the second data in the wide table is updated accordingly; wherein the third data is any data in the second-level sub-table.

[0112] According to one or more embodiments of this disclosure, after generating a wide table based on a main table and at least one secondary table, the method further includes: obtaining pagination conditions; and paginating the wide table according to the pagination conditions.

[0113] According to one or more embodiments of this disclosure, a business query apparatus is provided. The apparatus includes: a first acquisition module, a generation module, a second acquisition module, and a query module. The first acquisition module acquires a main table and at least one subordinate table, which are related to the business query. The generation module generates a wide table based on the main table and at least one subordinate table. The second acquisition module acquires the business to be queried. The query module queries the wide table for the business to be queried and returns the query results.

[0114] According to one or more embodiments of this disclosure, the generation module is specifically used to: generate a snowflake model based on a main table and at least one secondary table; and generate a wide table based on the snowflake model.

[0115] According to one or more embodiments of this disclosure, the business query device further includes: a third acquisition module, a first judgment module, and a first update module, wherein the third acquisition module is used to acquire the logs of the main table in real time; the first judgment module is used to determine whether there is a data update in the main table based on the logs of the main table; the first update module is used to update the first data in the wide table accordingly if the first data in the main table is updated; wherein the first data is any data in the main table.

[0116] According to one or more embodiments of this disclosure, at least one sub-table includes: at least one first-level sub-table and at least one second-level sub-table; wherein, the first-level sub-table is a sub-table that includes data in the wide table that needs to be updated in real time, and the first-level sub-table is directly or indirectly associated with the main table, and the second-level sub-table is a sub-table that does not include data in the wide table that needs to be updated in real time, and the second-level sub-table is directly or indirectly associated with a first-level sub-table.

[0117] According to one or more embodiments of this disclosure, the business query device further includes: a fourth acquisition module, a second judgment module, and a second update module, wherein the fourth acquisition module acquires the logs of the first-level sub-table in real time; the second judgment module is used to determine whether there is a data update in the first-level sub-table based on the logs of the first-level sub-table; the second update module is used to update the second data in the wide table accordingly if it is determined that the second data in the first-level sub-table has been updated; wherein the second data is any data in the first-level sub-table.

[0118] According to one or more embodiments of this disclosure, the business query device further includes: a scanning module, a third judgment module, and a third update module, wherein the scanning module is used to periodically scan all records of the main table; the third judgment module is used to determine whether there is a data update in at least one second-level subsidiary table when scanning any record of the main table, based on the association relationship between the record and at least one second-level subsidiary table; the third update module is used to update the third data in the wide table accordingly if the third data of any second-level subsidiary table is updated; wherein the third data is any data in the second-level subsidiary table.

[0119] According to one or more embodiments of this disclosure, the business query device further includes: a fifth acquisition module and a pagination module, wherein the fifth acquisition module is used to acquire pagination conditions; and the pagination module is used to paginate the wide table according to the pagination conditions.

[0120] Those skilled in the art will recognize that the modules 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.

[0121] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0122] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. For example, the functional modules in the various embodiments of this application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0123] 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 business query method, characterized in that, include: Obtain a main table and at least one subordinate table, wherein the main table and the at least one subordinate table are related to the business query; Generate a wide table based on the main table and at least one subordinate table; Retrieve the query request; The query function is retrieved from the wide table, and the query results are returned. The at least one subordinate table includes: at least one first-level subordinate table and at least one second-level subordinate table; The first-level sub-table is a sub-table that includes the data in the wide table that needs to be updated in real time, and the first-level sub-table is directly or indirectly related to the main table. The second-level sub-table is a sub-table that does not include the data in the wide table that needs to be updated in real time, and the second-level sub-table is directly or indirectly related to one of the first-level sub-tables. This also includes: periodically scanning all records in the main table; When scanning any record in the main table, determine whether there is any data update in the at least one second-level subsidiary table based on the association relationship between the record and the at least one second-level subsidiary table; For any of the at least one second-level sub-tables, if the third data of the second-level sub-table is updated, then the third data in the wide table is updated accordingly. The third data is any one of the data in the second-level sub-table.

2. The method according to claim 1, characterized in that, The step of generating a wide table based on the main table and the at least one subordinate table includes: Generate a snowflake model based on the main table and at least one of the subordinate tables; The wide table is generated based on the snowflake model.

3. The method according to claim 1 or 2, characterized in that, Also includes: Obtain the logs of the main table in real time; Determine whether the main table has been updated based on the logs of the main table; If the first data in the main table is updated, then the first data in the wide table is updated accordingly. The first data is any data in the main table.

4. The method according to claim 1, characterized in that, Also includes: Obtain the logs of the first-level slave table in real time; Determine whether there are any data updates in the first-level slave table based on the logs of the first-level slave table; If it is determined that the second data in the first-level sub-table has been updated, then the second data in the wide table is updated accordingly. The second data is any one of the data in the first-level sub-table.

5. The method according to claim 1 or 2, characterized in that, After generating the wide table based on the main table and the at least one subordinate table, the process further includes: Get pagination criteria; The wide table is paginated according to the pagination conditions.

6. A business query device, characterized in that, include: The first acquisition module is used to acquire a main table and at least one sub-table, wherein the main table and the at least one sub-table are related to the business query. A generation module is used to generate a wide table based on the main table and the at least one subordinate table; The second acquisition module is used to acquire the business to be queried; The query module is used to query the business to be queried in the wide table and return the query results; The at least one subordinate table includes: at least one first-level subordinate table and at least one second-level subordinate table; The first-level sub-table is a sub-table that includes the data in the wide table that needs to be updated in real time, and the first-level sub-table is directly or indirectly related to the main table. The second-level sub-table is a sub-table that does not include the data in the wide table that needs to be updated in real time, and the second-level sub-table is directly or indirectly related to one of the first-level sub-tables. It also includes: a scanning module, used to periodically scan all records in the main table; The third judgment module is used to determine whether there is data update in the at least one second-level subsidiary table when scanning any record in the main table, based on the association relationship between the record and the at least one second-level subsidiary table. The third update module is used to update the third data in the wide table if the third data in any of the at least one second-level sub-tables is updated; wherein the third data is any data in the second-level sub-table.

7. An electronic device, characterized in that, include: A processor and a memory, the memory being used to store a computer program, the processor being used to invoke and run the computer program stored in the memory to perform the method of any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, Used to store a computer program that causes a computer to perform the method as described in any one of claims 1 to 5.