Data query method and device, equipment and storage medium
Through the data table structure of the mixed ranks and queues, the linkage query between the first layer of data and non-first layer of data is realized, and the poor performance and data update complexity caused by infinite dolls and full-scale query are solved, which improves user experience and query efficiency.
Patent Information
- Application Number
- CN202410131289.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-30
- Publication Date
- 2025-08-01
AI Technical Summary
The prior art is under great pressure when querying data from unlimited multi-layer and two-layer tree structures, resulting in stuttering in query and poor user experience. The update is complicated and error-prone when the first layer brings out the second layer of data.
The preset data table adopts a mixed row and column mode, and the paging query conditions and the linked paging query conditions are obtained through the first layer of data query request, so as to realize the linkage query between the first layer of data and non-first layer data, and use row data to represent the first layer of data, column data to represent the non-first layer of data, and are associated with the service primary key.
While querying the first layer of data, the first page of non-first layer data is brought out, which reduces the performance problems of unlimited nesting doll query and full query, ensures query performance, and avoids the complexity and consistency of data updates.
Smart Images

Figure CN120407855A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of information query, and in particular, to a data query method, device, equipment and storage medium. Background Art
[0002] There are two cases for the paging technology of existing tree-structured data: infinitely many layers and two layers.
[0003] Case 1 of infinitely many layers: Paging query is performed according to the horizontal layers of the tree, and the sub-layers are queried in an infinite nesting manner. The effect diagram of the traditional mode of infinitely many layers is as Figure 1a shown, or only the parent layer is displayed. The user clicks on the parent layer node, and then queries the sub-layer data, which requires the user to click repeatedly to drill down and view. Case 2 of two layers: The first layer of the tree is the first layer, and all other sub-layers are displayed on the second layer. The effect diagram of the two-layer mode is as Figure 1b shown, and the second layer needs to be popped up and displayed after clicking the reply. Since the data on the second layer cannot be directly seen, it cannot play the role of attracting content, and few users will click in to view. Currently, when the first layer and the second layer need to be displayed simultaneously, the data on the second layer can be queried in full at one time; or the first data of the second layer can be brought out and displayed on the first layer. That is, the first data of the second layer is written to an extended field of the first layer, and when querying the data of the first layer, it can be directly brought out.
[0004] However, in the process of implementing the present invention, it is found that there are at least the following problems in the prior art:
[0005] In the infinite nesting query database of the infinitely many layers mode, or in the two-layer mode of displaying the first layer and the second layer data simultaneously through full query, when the data volume is large, the pressure on the database increases sharply, which will cause query lag and poor user experience; when the first layer brings out the first data of the second layer for display, if the data of the second layer being displayed is updated, both the sub-node itself and this data saved in the extended field of the parent node need to be modified, increasing the complexity and easily forming the problem of data inconsistency. Summary of the Invention
[0006] The embodiments of the present invention provide a data query method, device, equipment and storage medium to bring out the first page data of non-first layer data while querying the first layer data, and ensure the query performance when the data volume increases.
[0007] In a first aspect, the embodiments of the present invention provide a data query method, and the method includes:
[0008] In response to a first-layer data query request, obtain a first-layer paging query condition and a non-first-layer associated paging query condition associated with the first-layer paging query condition from the first-layer data query request; the first-layer data query request is a query request for root node data in a preset tree structure; the first-layer paging query condition represents paging query of the root node data, and each page includes a first specified number of root node data; the non-first-layer associated paging query condition represents a second specified number of non-root node data associated with each root node data when querying each root node data from the preset tree structure.
[0009] According to the first-layer paging query condition and the non-first-layer associated paging query condition, query each target first-layer data and each target non-first-layer data associated with each target first-layer data respectively from a preset data table in a database, so as to implement first-layer data query and non-first-layer data associated query.
[0010] The preset data table is in a row-column mixed mode, each row data represents first-layer data, and each column data corresponding to each row data represents non-first-layer data; the column data uses the row data as the business primary key.
[0011] In a second aspect, an embodiment of the present invention further provides a data query device, and the device includes:
[0012] A query condition acquisition module, configured to obtain a first-layer paging query condition and a non-first-layer associated paging query condition associated with the first-layer paging query condition from the first-layer data query request in response to the first-layer data query request; wherein, the first-layer data query request is a query request for root node data in a preset tree structure; the first-layer paging query condition represents paging query of the root node data, and each page includes a first specified number of root node data; the non-first-layer associated paging query condition represents a second specified number of non-root node data associated with each root node data when querying each root node data from the preset tree structure.
[0013] A first-layer data query module, configured to query each target first-layer data and each target non-first-layer data associated with each target first-layer data respectively from a preset data table in a database according to the first-layer paging query condition and the non-first-layer associated paging query condition, so as to implement first-layer data query and non-first-layer data associated query.
[0014] Wherein, the preset data table is in a row-column mixed mode, each row data represents first-layer data, and each column data corresponding to each row data represents non-first-layer data; the column data uses the row data as the business primary key.
[0015] [[ID=2I]]In a third aspect, an embodiment of the present invention provides an electronic device, and the electronic device includes:
[0016] one or more processors;
[0017] a memory for storing one or more programs;
[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the data query method provided by any embodiment of the present invention.
[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data query method provided by any embodiment of the present invention.
[0020] The embodiments of the above invention have the following advantages or beneficial effects:
[0021] The technical solution of the present invention obtains the first-level paging query condition and the non-first-level associated paging query condition linked to the first-level paging query condition from the first-level data query request in response to the first-level data query request; the first-level data query request is a query request for the root node data in the preset tree structure; the first-level paging query condition represents the paging query of the root node data, and each page includes a first specified number of root node data; the non-first-level associated paging query condition represents the second specified number of non-root node data linked to the query from the preset tree structure when querying each root node data; according to the first-level paging query condition and the non-first-level associated paging query condition, each target first-level data and each target non-first-level data linked to each target first-level data are queried from the preset data table of the database to realize the first-level data query and non-first-level data linked query; the preset data table is a row-column mixed mode, each row data represents the first-level data, and each column data corresponding to each row data represents the non-first-level data; the column data uses the row data as the business primary key. Because the technical means of paging query of the first-layer data and jointly querying the first page of non-first-layer data are adopted, the technical problems of the existing technology of infinite nesting doll query or full query of the second-layer data when the data volume is large are overcome, and the technical problems of complex and error-prone updating of the first data of the second layer when the first layer is brought out for display. In addition, the first page of non-first-layer data is brought out at the same time as the first-layer data, and the query performance is guaranteed as the data volume grows. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1a An infinitely multi-layered traditional pattern rendering provided by existing technology;
[0023] Figure 1b A two-layer model effect diagram provided by the existing technology;
[0024] Figure 1cFlowchart of a data query method provided by an embodiment of the present invention;
[0025] Figure 1d Schematic diagram of data display of a document directory tree provided by this embodiment;
[0026] Figure 1e Query data time sequence diagram provided by this embodiment;
[0027] Figure 2a Flowchart of a preset data table construction method provided by an embodiment of the present invention;
[0028] Figure 2b Time sequence diagram of creating data in a preset data table provided by this embodiment;
[0029] Figure 2c Overall schematic diagram of data creation and data query provided by this embodiment;
[0030] Figure 3 Schematic diagram of the structure of a data query device provided by an embodiment of the present invention;
[0031] Figure 4 Schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Detailed implementation manners
[0032] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. In addition, it should be noted that for the sake of description, only parts related to the present invention are shown in the drawings, rather than all the structures.
[0033] Figure 1c Flowchart of a data query method provided by an embodiment of the present invention. This embodiment is applicable to the case of paging query of data in a tree structure. This method can be executed by a data query device integrated in a server, and this device can be implemented in a software and / or hardware manner. As Figure 1c shown, this method specifically includes the following steps:
[0034] S110. In response to a first-layer data query request, obtain a first-layer paging query condition and a non-first-layer associated paging query condition associated with the first-layer paging query condition from the first-layer data query request.
[0035] Among them, the first-level data query request can be a query request for the root node data in the preset tree structure; for data in the form of a tree structure, the first-level data is equivalent to the root node data of the tree structure, and the non-first-level data under the first-level data is equivalent to the non-root node data of the tree structure. The first-level data query request is initiated by the target user through the front-end interface. The first-level paging query condition can refer to the query condition for the first-level data, which can be specifically characterized as each page including a first specified number of root node data when querying the root node data in a paging manner; the non-first-level joint paging query condition can refer to the joint query condition for the non-first-level data while querying the first-level data, which can be specifically characterized as the second specified number of non-root node data that are linked to the query from the preset tree structure when querying each root node data.
[0036] To address the existing issue of non-first-tier data not being able to be displayed simultaneously when querying first-tier data, or of only being able to display one piece of non-first-tier data when querying first-tier data, this embodiment simultaneously queries the first page of subordinate non-first-tier data while querying first-tier data. For example, if a target user queries first-tier comment data for a comment scenario through a front-end interface, the front-end interface sends a first-tier comment data query request to a back-end server. Based on the first-tier comment data query request, the server obtains first-tier paging query conditions and non-first-tier paging query conditions bound to the first-tier paging query conditions.
[0037] Optionally, before responding to the first-layer data query request and obtaining the first-layer paging query conditions and the non-first-layer associated paging query conditions corresponding to the first-layer paging query conditions from the first-layer data query request, it may also include: obtaining the identity identification information of the target user from the first-layer data query request; and verifying that the identity of the target user is legal and has data reading permission based on the identity identification information.
[0038] The data query method of this embodiment is applicable to comment scenarios including meetings or schedules, collaborative documents, projects or tasks, forums or blogs, etc. It can also be applied to collaborative document directory trees and tree-like list scenarios such as parent-child relationship trees. For example, for scenarios such as meetings and schedules that require certain viewing permissions, it is necessary to verify the identity and permissions of the target user in advance.
[0039] S120. According to the first-layer paging query conditions and the non-first-layer linked paging query conditions, query each target first-layer data and each target non-first-layer data corresponding to each target first-layer data from the preset data table of the database to realize the first-layer data query and the non-first-layer data linked query.
[0040] Among them, the preset data table can be a data table constructed through data in a preset tree structure. The preset data table can be in a row-column mixed mode. Each row of data can represent the first-level data, and each column of data corresponding to each row of data can represent non-first-level data; the column data uses the row data as the business primary key.
[0041] In this embodiment, after obtaining the first-level paging query condition and the non-first-level associated paging query condition from the first-level data query request, the row data (i.e., each target first-level data) can be queried from the preset data table according to the first-level paging query condition to implement the query of the first-level data, and while querying each row of data, the column data (i.e., each target non-first-level data) corresponding to the non-first-level associated paging query condition can be queried simultaneously to implement the associated query of the non-first-level data. It can be understood that the first-level data and some non-first-level data are in a bound state.
[0042] In an alternative embodiment, to implement the query of the first-level data, specifically, the respective target row data corresponding to the first-level paging query condition can be queried from the preset data table; according to the non-first-level associated paging query condition, the column data range corresponding to each target row data can be determined; according to the column data range corresponding to the currently processed target row data, the respective target column data matching the currently processed target row data can be queried from the preset data table; the respective target row data and the respective target column data are assembled in terms of the user dimension, and the assembly result is fed back to the target user through the front-end interface.
[0043] Exemplarily, if it is specified in the first-level paging query condition that each page of the first-level data contains 30 pieces of data, then 30 rows of data can be sequentially selected from the beginning in the preset data table to determine the row data range, and each row of data within the row data range is used as the respective target row data; at the same time, for each target row data, a certain number of corresponding column data need to be queried in an associated manner. According to the non-first-level associated paging query condition, each column of data within the column data range corresponding to the currently processed target row data is used as the respective target column data for the current associated query. In the comment scenario, further, the identification information (such as user ID) of each comment user can be extracted from the respective target row data and the respective target column data corresponding to each target row data, the user information interface is queried by the user ID, and a user information list is returned, that is, the respective target row data and the respective target column data corresponding to each target row data are assembled in terms of the user ID, and the assembly result is fed back to the target user through the front-end interface.
[0044] After the target user queries the first page of the first-level data and the associated non-first-level data based on the first-level data query request, if the target user wants to continue to query more non-first-level data under a certain piece of first-level data, a non-first-level data query request can be further sent through the front-end interface for the current first-level data.
[0045] Specifically, in response to a non-first-layer data query request, obtain the business primary key field value and the non-first-layer paging query condition from the non-first-layer data query request; locate the target row data from the preset data table according to the business primary key field value; determine each target column data from the column data corresponding to the target row data according to the non-first-layer paging query condition; assemble each target column data in terms of the user dimension, and feedback the assembly result to the target user through the front-end interface to implement non-first-layer data query.
[0046] Among them, in the preset data table, the column data corresponding to each row data uses the row data as the business primary key, and the business primary key field value is used to represent the identity of the row data. The target non-first-layer data query request may refer to a query request for more non-first-layer data subordinate to the target first-layer data. The non-first-layer paging query condition characterizes paging query of non-root node data, and each page includes a third specified number of non-root node data. The non-first-layer paging query condition may include: the specified page and the page size; or the specified last business primary key field value of the previous page and the page size.
[0047] Exemplarily, if the business primary key field value in the target non-first-layer data query request is "100", and the non-first-layer paging query condition specifies to query the second page of non-first-layer data with a size of 20 items. Then, the row data with the business primary key of "100" can be queried from the preset data table according to "100" as the target row data; further, start from the second page in the corresponding column data of the target row data to find 20 column data as each target column data corresponding to the target row data. Further, the identification information (such as user ID) of each comment user can be extracted from each target column data, query the user information interface by the user ID, and return the user information list, that is, assemble each target column data in terms of the user ID, and feedback the assembly result to the target user through the front-end interface.
[0048] The technical solution of the present invention is as follows: in response to a first-layer data query request, obtain a first-layer paging query condition and a non-first-layer associated paging query condition associated with the first-layer paging query condition from the first-layer data query request; the first-layer data query request is a query request for the root node data in a preset tree structure; the first-layer paging query condition represents paging query of the root node data, and each page includes a first specified number of root node data; the non-first-layer associated paging query condition represents a second specified number of non-root node data associated with each root node data queried from the preset tree structure when querying each root node data; according to the first-layer paging query condition and the non-first-layer associated paging query condition, query each target first-layer data and each target non-first-layer data associated with each target first-layer data respectively from a preset data table in the database, so as to implement first-layer data query and non-first-layer data associated query; the preset data table is in a row-column mixed mode, each row data represents first-layer data, and each column data corresponding to each row data represents non-first-layer data; the column data uses the row data as the business primary key. Because the technical means of first-layer data paging query and associated query of the first page of non-first-layer data is adopted, the technical problems in the prior art that the infinite nested query or full-volume query of the second-layer data has poor query performance when the data volume is large, and the update of the first data brought out by the first layer to the second layer is complex and error-prone are overcome. Furthermore, when querying the first-layer data, the first page of non-first-layer data is brought out, and the query performance is guaranteed when the data volume increases.
[0049] Taking the comment scenario of a blog as an example, the comment data in this scenario is a two-layer data structure. User 1 directly posts comment data 1 under a post, User 2 directly posts comment data 2 under this post, and User 3 directly posts comment data 3 under this post; User 4 posts reply data 1 under comment data 1, and User 5 posts reply data 2 under comment data 1; User 6 replies to reply data 1 under comment data 1 and posts reply data 3; User 7 posts reply data 4 under comment data 2. The above data can be stored in the form of Table 1 in a preset data table. Among them, comment data 1, comment data 2, and comment data 3 are equivalent to first-layer data, and reply data 1, reply data 2, reply data 3, and reply data 4 are equivalent to non-first-layer data.
[0050] Table 1
[0051] Column 1 Column 2 Column 3 … Row 1 (Comment Data 1) Reply Data 1 Reply Data 2 Reply Data 3 Row 2 (Comment Data 2) Reply Data 4 …… …… Row 3 (Comment Data 3) …… …… …… ……
[0052] If the current request queries the first-level data, the first-level paging query condition in this request is to query the first page of the first-level data, and the page size is 10 rows. The non-first-level associated paging query condition linked to the first-level paging query condition is to query the first page of the non-first-level data, and the page size is 5 columns. Then, the row data corresponding to rows 1 - 10 can be found from Table 1, and the column data of columns 1 - 5 corresponding to each of rows 1 - 10 can be queried. If the current request queries more reply data subordinate to comment data 2, the row 2 can be located in Table 1 according to the value of the business primary key field in this request. The non-first-level paging query condition in this request is the 2nd page, and the page size is 5 columns. Then, the column data of columns 6 - 10 can be queried from the column data corresponding to row 2.
[0053] Taking IM (Instant Messenger) chat records as an example, the chat records are a two-level data structure queried by time dimension. The time dimension can include days, weeks, months, quarters, and years. The storage of chat records can be the same as that of Table 1. The user information is saved in the rows, the parent node is the time dimension field, and the columns in the rows are the specific chat data:
[0054] 1) Personal chat records: The first-level data can refer to the other user identification data that has chatted with the current individual. The second-level data (equivalent to the non-first-level data here) can be the specific chat data of each other user. When querying chat records by time dimension, two-level paged data is returned each time (the first-level data is returned according to the first-level paging query condition, and the associated second-level data is returned according to the non-first-level associated paging query condition). Without clicking on each specific user and expanding the chat information again, just by sliding the chat page, the second-level chat data of each user can be seen.
[0055] 2) Group message records: The first-level data can be the identification data of all users who have chatted in the group. The second-level data can be the specific chat data of each user. When querying chat records by time dimension, two-level paged data is returned each time (the first-level data is returned according to the first-level paging query condition, and the associated second-level data is returned according to the non-first-level associated paging query condition). Without clicking on each specific user and expanding the chat information again, just by sliding the chat page, the second-level chat data of each user can be seen.
[0056] Such a setting can greatly save the operation of the user manually clicking on users to expand chat information, and the user experience is greatly improved. The interaction between the client and the server is greatly reduced, saving network IO (input / output), and thus saving server resources.
[0057] Taking the document directory tree as an example, the directory tree is multi-level data. The data storage method of the document directory tree can be as follows: The first-level nodes are saved in a row, and their parent nodes are empty. When a node A (i.e., the second-level node) in a column of a row has child nodes (i.e., the third-level nodes), the first layer of the child nodes of node A needs to be saved separately in the row, and its parent node ID is A. The list of nodes included in this column is the grandchild nodes (the fourth-level nodes) of A. The same principle applies to the other fifth and sixth levels. Formula: For the Nth layer and the N + 1th layer, where N is odd, the odd layers will appear in the row data (the row data is queried through the parent node ID), and the even layers will appear in the column data table. That is, the nodes of the 1st, 3rd, 5th, …, Nth layers are in the row data, and the nodes of the 2nd, 4th, 6th, …, N + 1th layers are in the column data. It can be understood that for multi-level data with more than two levels, the data of the odd levels in the preset data table can be equivalent to the first-level data and stored in the row data, and the data of the even levels in the preset data table can be equivalent to the non-first-level data and stored in the column data corresponding to the corresponding row data.
[0058] Further, when the user first queries data, the document directory will be expanded in two-level paging. The first-level data is the first-level document directory corresponding to each first-level node (such as Figure 1d the first-level directory A, the first-level directory B, and the first-level directory C shown in the left figure), and at the same time, the first-page data of the subdirectories of each first-level node directory is brought out (such as Figure 1d the first-level directory A shown in the left figure brings out the second-level A-1, the second-level A-2, and the second-level A-3 - Document 1; the first-level directory B brings out the second-level B-1; the first-level directory C brings out the second-level C-1 document), so that the user does not need to manually click on the first-level node to expand its subdirectory. The user can quickly view the document directory information by sliding the page. When finding a certain subdirectory that the user wants to view (such as Figure 1d the second-level A-1 shown in the right figure), the two-level subdirectory of this subdirectory (the second-level A-1) can be queried again (such as Figure 1d the third-level A-1-1 and the third-level A-1-2 shown in the right figure, and the third-level A-1-1 brings out the fourth-level A-1-1-2 Document X1). In this way, the expanded directory is a four-level directory structure.
[0059] To enable those skilled in the art to better understand the data query method of this embodiment, Figure 1e a query data timing diagram is provided for this embodiment.
[0060] The user queries the first-layer data through the front end. The front end calls the first-layer query interface. After receiving the first-layer data query request, the server verifies the user's legitimacy and the read-only permission for the data. Query the row data according to the paging conditions (the first-layer paging query conditions), and jointly query the first page of the column data corresponding to the row data (query according to the non-first-layer associated paging query conditions). It is completed by executing a single SQL statement. For the query result, the server needs to extract the user IDs in the list, form the user ID list A, batch query the user information interface according to the user ID list A, return the user information list, assemble the user information in the return result, and return the query result to the front end.
[0061] If the user needs to continue to view the non-first-layer data, they can call the non-first-layer data query interface. After receiving the non-first-layer data query request, the server verifies the user's legitimacy and the permission to create data. The interface input parameters need to include the rootId (the value of the business primary key field) and the column paging conditions (the non-first-layer paging query conditions). The column paging conditions support two types: 1) which page and the page size; 2) the last business primary key of the previous page and the page size. Locate and query the row in Table X according to the rootId, and query the specified page data for the columns in the row according to the paging conditions. It is completed by executing a single SQL statement. For the query result, the server needs to extract the user IDs in the list, form the user ID list A, batch query the user information interface according to the user ID list A, return the user information list, assemble the user information in the return result, and return the query result to the front end.
[0062] The tree-shaped data paging query mode of this embodiment adopts the same-screen two-layer paging mechanism for display, which can avoid infinite-layer expansion and the display of non-first-layer data covering the first-layer data.
[0063] Figure 2a It is a flowchart of a method for constructing a preset data table provided by an embodiment of the present invention. On the basis of the above embodiment, this embodiment is applicable to the situation of creating data in a tree structure. This method can be executed by a data creation device integrated in the server, and this device can be implemented in software and / or hardware. As Figure 2a shown, the method specifically includes the following steps:
[0064] S210. In response to the data creation request, obtain the data description information of the data to be created from the data creation request.
[0065] Among them, the data description information may include a business primary key field, a core information field, a parent node field, a sub - list field, a valid status field, a creator field, a modifier field, a creation time field, and a modification time field; the business primary key field can be used to represent the identity identifier of the first - layer data; the core information field can be used to represent the comment content of the data to be created currently; the parent node field can be used to represent the reply object of the data to be created currently; the sub - list field is used to represent the data description information of non - first - layer data; the first data to be created is obtained by extracting the values of the core information field, the valid status field, the creator field, and the creation time field from the data description information; the second data to be created is obtained by extracting the value of the sub - list field from the data description information.
[0066] In this embodiment, if the target user creates data through the front - end interface, the front - end sends a data creation request to the server, and the server obtains the data description information of the data to be created according to this data query request.
[0067] Optionally, before obtaining the data description information of the data to be created from the data creation request in response to the data creation request, the identity identifier information of the target user can also be obtained from the data creation request; and the identity of the target user is verified to be legal and have the data creation permission according to the identity identifier information.
[0068] S220. Determine the data type of the data to be created according to the value of the business primary key field in the data description information.
[0069] Optionally, determining the data type of the data to be created according to the value of the business primary key field in the data description information may include: when the value of the business primary key field is empty, determining that the data to be created is first - layer data; when the value of the business primary key field is non - empty, determining that the data to be created is non - first - layer data.
[0070] In this embodiment, it is possible to judge whether the data to be created is root - node data (first - layer data) according to the business primary key field in the description field of the data description information of the data to be created. If the value of the business primary key field is empty, it is determined that the data to be created is root - node data (first - layer data); if the value of the business primary key field is not empty, it is determined that the data to be created is non - root - node data (non - first - layer data).
[0071] S230. In the case where the data type is first - layer data, extract the first data to be created from the data description information, and add the content of the first data to be created as new row data to the preset data table.
[0072] In this embodiment, if the data to be created is the first-layer data, the core information field value, the creator, the creation time, etc. can be extracted from the corresponding data description information to obtain the first data to be created, and a row data entity can be constructed according to the content of the first data to be created, and then this row data entity can be directly added to the preset data table.
[0073] S240. In the case where the data type is non-first-layer data, locate the target row data from the preset data table according to the business primary key field value, and extract the second data to be created from the data description information, and add the content of the second data to be created as new column data to the column position corresponding to the target row data in the preset data table.
[0074] In this embodiment, if the data to be created is non-first-layer data, the business primary key field value can be read, and the target row data can be located from the row data already constructed in the preset data table according to this field value. Further, the parent node field value, the sub-list field, the creator, the creation time, etc. are extracted from the data description information of the data to be created to obtain the second data to be created, and a column data entity is constructed according to the content of the second data to be created, and then this column data entity is directly added under the target row data in the preset data table.
[0075] The technical solution of the present invention is as follows: in response to a data creation request, obtain the data description information of the data to be created from the data creation request; determine the data type of the data to be created according to the business primary key field value of the data description information; in the case where the data type is the first-layer data, extract the first data to be created from the data description information, and add the content of the first data to be created as new row data to the preset data table; in the case where the data type is non-first-layer data, locate the target row data from the preset data table according to the business primary key field value, and extract the second data to be created from the data description information, and add the content of the second data to be created as new column data to the column position corresponding to the target row data in the preset data table. Because the technical means of storing the first-layer data and the non-first-layer data in a row-column hybrid mode is adopted, the technical problem that the total number of rows or the total number of columns is large when querying data based on a single-row mode or a single-column mode data table in the prior art leads to poor subsequent query performance is overcome, and thus the total number of rows is effectively reduced, providing a certain prerequisite for ensuring query performance when the data volume increases.
[0076] In order to enable those skilled in the art to better understand the method for constructing the preset data table in this embodiment, Figure 2b A sequence diagram for creating data in a preset data table is provided for this embodiment.
[0077] The user creates data through the front end. The front end calls the data creation interface. After the server receives the data creation request, it verifies the user's legitimacy and the permission to create data, and then determines whether it is a root node. If the rootId is empty, it is a root node, and a row data entity is constructed. If the root is not empty, it is a non-root node, and the Id of the nearest parent node needs to be provided to construct a column data entity. In the case of row data, a row of data is directly appended to Table X and saved in the data table X. In the case of column data, it is necessary to locate the row according to the rootId and then write the column entity into the column in the row of Table X.
[0078] Figure 2c This embodiment provides an overall schematic diagram of data creation and data query.
[0079] Data creation starts. First, the data of the root nodes in the first layer is created. This layer of data will be written into the rows in the data table. If non-root node data is continuously created based on a certain root node, it will be written into the columns of the row data of that root node.
[0080] The selected database needs to support JSON queries for table fields. Currently, the open-source databases supported include Mysql8.x, Mongodb, and Hbase, etc. Data query starts with paging query in the first layer. In the paging query of the first layer, first perform row paging query according to the row paging condition (i.e., the paging query condition of the first layer), and at the same time perform paging query for the columns in the row (only take the first page). The paging size of the column query needs to be passed in by the front end. If the user wants to view more data in the second layer, only need to query the data in the second layer. The front end needs to pass the rootId (the business primary key Id of the data of the node in the first layer to which the second layer belongs) and the paging condition for the second layer query, and call the second layer data paging query interface to implement. The implementation method is to first locate the row according to the root node, and then query the columns in the row according to the paging condition.
[0081] The following is an embodiment of the data query device provided by the embodiment of the present invention. This device and the data query method in the above-mentioned Embodiment 1 belong to the same inventive concept. For the details not described in detail in the embodiment of the data query device, reference can be made to the content of the above-mentioned embodiments.
[0082] Figure 3 This is a schematic structural diagram of the data query device provided by the embodiment of the present invention. As Figure 3 shown, the device includes: a query condition acquisition module 310 and a first layer data query module 320. Among them:
[0083] The query condition acquisition module 310 is configured to, in response to a first-layer data query request, acquire a first-layer paging query condition and a non-first-layer associated paging query condition corresponding to the first-layer paging query condition from the first-layer data query request; wherein the first-layer data query request is a query request for root node data in a preset tree structure; the first-layer paging query condition represents a paging query for the root node data, with each page including a first specified number of root node data; and the non-first-layer associated paging query condition represents a second specified number of non-root node data to be linked and queried from the preset tree structure when querying each root node data.
[0084] The first-layer data query module 320 is configured to query each target first-layer data and each target non-first-layer data corresponding to each target first-layer data from a preset data table in the database according to the first-layer paging query condition and the non-first-layer joint paging query condition, so as to realize the linkage query of the first-layer data and the non-first-layer data;
[0085] The preset data table is a mixed row and column mode, each row data represents first-layer data, and each column data corresponding to each row data represents non-first-layer data; the column data uses the row data as the business primary key.
[0086] The technical solution of the present invention obtains the first-level paging query condition and the non-first-level associated paging query condition corresponding to the first-level paging query condition from the first-level data query request in response to the first-level data query request; the first-level data query request is a query request for the root node data in the preset tree structure; the first-level paging query condition represents the paging query of the root node data, and each page includes a first specified number of root node data; the non-first-level associated paging query condition represents the second specified number of non-root node data that are linked to the query from the preset tree structure when querying each root node data; according to the first-level paging query condition and the non-first-level associated paging query condition, each target first-level data and each target non-first-level data corresponding to each target first-level data are queried from the preset data table of the database to realize the first-level data query and non-first-level data linkage query; the preset data table is a row-column mixed mode, each row data represents the first-level data, and each column data corresponding to each row data represents the non-first-level data; the column data uses the row data as the business primary key. Because the technical means of paging query of the first-layer data and jointly querying the first page of non-first-layer data are adopted, the technical problems of the existing technology of infinite nesting doll query or full query of the second-layer data when the data volume is large are overcome, and the technical problems of complex and error-prone updating of the first data of the second layer when the first layer is brought out for display. In addition, the first page of non-first-layer data is brought out at the same time as the first-layer data, and the query performance is guaranteed as the data volume grows.
[0087] In the above device, optionally, the first-layer data query request is initiated by the target user through the front-end interface;
[0088] Correspondingly, it further includes a verification module, which is used before obtaining the first-layer paging query condition and the non-first-layer associated paging query condition corresponding to the first-layer paging query condition from the first-layer data query request in response to the first-layer data query request:
[0089] Obtain the identity identification information of the target user from the first-layer data query request;
[0090] Verify that the identity of the target user is legal and has the data reading permission according to the identity identification information.
[0091] In the above device, optionally, the first-layer data query module 320 can specifically be used for:
[0092] Query each target row data corresponding to the first-layer paging query condition from the preset data table;
[0093] Determine the column data range corresponding to each target row data according to the non-first-layer associated paging query condition;
[0094] Query each target column data matching the current processed target row data from the preset data table according to the column data range corresponding to the current processed target row data;
[0095] Assemble the respective target row data and the respective target column data in terms of the user dimension, and feed back the assembly result to the target user through the front-end interface.
[0096] In the above device, optionally, it further includes a non-first-layer data query module, which is used for:
[0097] In response to the target non-first-layer data query request, obtain the business primary key field value and the non-first-layer paging query condition from the target non-first-layer data query request;
[0098] Locate the target row data from the preset data table according to the business primary key field value;
[0099] Determine each target column data from the column data corresponding to the target row data according to the non-first-layer paging query condition;
[0100] Assemble the respective target column data in terms of the user dimension, and feed back the assembly result to the target user through the front-end interface to implement non-first-layer data query.
[0101] In the above device, optionally, the non-first-layer paging query condition represents paging query of non-root node data, and each page includes a third specified number of non-root node data;
[0102] The non-first-layer paging query conditions include:
[0103] Specified page and page size; or
[0104] Specified value of the last business primary key field of the previous page and page size.
[0105] In the above device, optionally, it further includes a preset data table construction module, specifically including:
[0106] A data description information acquisition unit, configured to obtain data description information of data to be created from the data creation request in response to the data creation request;
[0107] A data type determination unit, configured to determine the data type of the data to be created according to the value of the business primary key field of the data description information;
[0108] A first data addition unit, configured to extract first data to be created from the data description information and add the content of the first data to be created as new row data to the preset data table when the data type is first-layer data;
[0109] A second data addition unit, configured to locate target row data from the preset data table according to the value of the business primary key field and extract second data to be created from the data description information, and add the content of the second data to be created as new column data to the column position corresponding to the target row data of the preset data table when the data type is non-first-layer data.
[0110] In the above device, optionally, the data type determination unit is specifically configured to:
[0111] Determine that the data to be created is first-layer data when the value of the business primary key field is empty;
[0112] Determine that the data to be created is non-first-layer data when the value of the business primary key field is non-empty.
[0113] In the above device, optionally, the data description information includes a business primary key field, a core information field, a parent node field, a sub-list field, a valid status field, a creator field, a modifier field, a creation time field, and a modification time field;
[0114] The business primary key field is used to represent the identity identifier of the first-layer data;
[0115] The core information field is used to represent the comment content of the currently created data;
[0116] The parent node field is used to represent the reply object of the data to be created currently;
[0117] The sub - list field is used to represent the data description information of non - first - layer data;
[0118] The first data to be created is obtained by extracting the core information field value, valid status field value, creator field value, and creation time field value from the data description information; the second data to be created is obtained by extracting the sub - list field value from the data description information.
[0119] The data query device provided by the embodiments of the present invention can execute the data query method provided by the first embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the data query method.
[0120] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Figure 4 It shows a block diagram of an exemplary server 12 suitable for implementing the embodiments of the present invention. Figure 4 The shown server 12 is only an example, and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.
[0121] As Figure 4 shown, the server 12 is presented in the form of a general - purpose computing device. The components of the server 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).
[0122] The bus 18 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the multiple bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0123] The server 12 typically includes a variety of computer - system - readable media. These media can be any available media accessible by the server 12, including volatile and non - volatile media, removable and non - removable media.
[0124] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Server 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 can be used for reading and writing on non-removable, non-volatile magnetic media ( Figure 4 not shown, commonly referred to as a "hard disk drive"). Although Figure 4 not shown in the figure, a disk drive for reading and writing on a removable non-volatile disk (such as a "floppy disk") and an optical disk drive for reading and writing on a removable non-volatile optical disk (such as a CD-ROM, DVD-ROM or other optical media) can be provided. In these cases, each drive can be connected to bus 18 through one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.
[0125] A program / utility 40 having a set (at least one) of program modules 42 can be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods in the embodiments described in the present invention.
[0126] Server 12 can also communicate with one or more external devices 14 (such as a keyboard, a pointing device, a display 24, etc.), and can also communicate with one or more devices that enable a user to interact with the server 12, and / or communicate with any device that enables the server 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through an input / output (I / O) interface 22. In addition, server 12 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through a network adapter 20. As shown in the figure, network adapter 20 communicates with other modules of server 12 through bus 18. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in combination with server 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0127] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the steps of a data query method provided in the first embodiment of the present invention. The method includes:
[0128] In response to a first-layer data query request, obtain a first-layer paging query condition and a non-first-layer associated paging query condition associated with the first-layer paging query condition from the first-layer data query request; the first-layer data query request is a query request for root node data in a preset tree structure; the first-layer paging query condition represents paging query of the root node data, and each page includes a first specified number of root node data; the non-first-layer associated paging query condition represents a second specified number of non-root node data linked and queried from the preset tree structure when querying each root node data.
[0129] According to the first-layer paging query condition and the non-first-layer associated paging query condition, query each target first-layer data and each target non-first-layer data respectively linked to each target first-layer data from a preset data table in a database, so as to implement first-layer data query and non-first-layer data linked query.
[0130] The preset data table is in a row-column mixed mode, each row data represents first-layer data, and each column data corresponding to each row data represents non-first-layer data; the column data uses the row data as a business primary key.
[0131] Of course, those skilled in the art can understand that the processor can also implement the technical solutions of the data query method provided in any embodiment of the present invention.
[0132] This embodiment provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the steps of a data query method provided in the foregoing embodiments of the present invention. The method includes:
[0133] In response to a first-layer data query request, obtain a first-layer paging query condition and a non-first-layer associated paging query condition associated with the first-layer paging query condition from the first-layer data query request; the first-layer data query request is a query request for root node data in a preset tree structure; the first-layer paging query condition represents paging query of the root node data, and each page includes a first specified number of root node data; the non-first-layer associated paging query condition represents a second specified number of non-root node data linked and queried from the preset tree structure when querying each root node data.
[0134] According to the first-layer paging query condition and the non-first-layer associated paging query condition, query each target first-layer data and each target non-first-layer data respectively linked to each target first-layer data from a preset data table in a database, so as to implement first-layer data query and non-first-layer data linked query.
[0135] The preset data table is in a row-column mixed mode. Each row of data represents the first-layer data, and each column of data corresponding to each row of data represents non-first-layer data. The column data uses the row data as the business primary key.
[0136] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or combined with an instruction execution system, apparatus, or device.
[0137] The computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device.
[0138] The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0139] Computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0140] Those of ordinary skill in the art should understand that the above-mentioned modules or steps of the present invention can be implemented with a general-purpose computing device. They can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Optionally, they can be implemented with program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module to be implemented. Thus, the present invention is not limited to any specific combination of hardware and software.
[0141] Note that the above is only the preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein. Various obvious changes, re-adjustments, and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments may be included, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A data query method, applied to a server, characterized in that The method comprises: In response to a first-layer data query request, a first-layer paging query condition and a non-first-layer associated paging query condition linked to the first-layer paging query condition are obtained from the first-layer data query request; the first-layer data query request is a query request for root node data in a preset tree structure; the first-layer paging query condition represents a paging query for the root node data, each page including a first specified number of root node data; the non-first-layer associated paging query condition represents a second specified number of non-root node data linked to the query from the preset tree structure when querying each root node data; According to the first-layer paging query condition and the non-first-layer joint paging query condition, query each target first-layer data and each target non-first-layer data respectively linked with each target first-layer data from the preset data table of the database, so as to realize first-layer data query and non-first-layer data linkage query; The preset data table is a mixed row and column mode, each row data represents first-layer data, and each column data corresponding to each row data represents non-first-layer data; the column data uses the row data as the business primary key.
2. The method according to claim 1, characterized in that, The first-tier data query request is initiated by the target user through the front-end interface; Before obtaining, in response to the first-layer data query request, the first-layer paging query condition and the non-first-layer associated paging query condition linked to the first-layer paging query condition from the first-layer data query request, the method further includes: Obtaining the identity information of the target user from the first layer data query request; Verify that the target user's identity is legitimate and has data reading authority based on the identity identification information.
3. The method according to claim 1, characterized in that According to the first-layer paging query condition and the non-first-layer joint paging query condition, each target first-layer data and each target non-first-layer data respectively linked with each target first-layer comment data are queried from the preset data table of the database to realize first-layer data query and non-first-layer data linkage query, including: Query each target row of data corresponding to the first-level paging query condition from the preset data table; Determine the column data range corresponding to each target row data according to the non-first-level joint paging query condition; According to the column data range corresponding to the currently processed target row data, query each target column data matching the currently processed target row data from the preset data table; The target row data and the target column data are assembled based on the user as the dimension, and the assembly result is fed back to the target user through the front-end interface.
4. The method according to claim 1, characterized in that, Also includes: In response to a non-first-layer data query request, obtaining a business primary key field value and a non-first-layer paging query condition from the non-first-layer data query request; Locating target row data from the preset data table according to the business primary key field value; Determine each target column data from the column data corresponding to the target row data according to the non-first-layer paging query condition; The target column data are assembled based on the user as the dimension, and the assembly result is fed back to the target user through the front-end interface to realize non-first-layer data query.
5. The method according to claim 4, wherein The non-first-layer paging query condition represents paging query of non-root node data, and each page includes a third specified number of non-root node data; The non-first-layer paging query condition includes: a specified page and page size; or a specified value of the last business primary key field of the previous page and page size.
6. The method according to claim 1, wherein the method for constructing the preset data table is applied to the server, and the method for constructing the preset data table includes: responding to a data creation request, and obtaining data description information of the data to be created from the data creation request; determining the data type of the data to be created according to the value of the business primary key field in the data description information; in the case where the data type is first-layer data, extracting first data to be created from the data description information, and adding the content of the first data to be created as new row data to the preset data table; in the case where the data type is non-first-layer data, locating target row data from the preset data table according to the value of the business primary key field, and extracting second data to be created from the data description information, and adding the content of the second data to be created as new column data to the column position corresponding to the target row data in the preset data table.
7. The method according to claim 6, wherein Determining the data type of the data to be created according to the value of the business primary key field in the data description information includes: in the case where the value of the business primary key field is empty, determining that the data to be created is first-layer data; in the case where the value of the business primary key field is non-empty, determining that the data to be created is non-first-layer data.
8. The method according to claim 6, wherein The data description information includes a business primary key field, a core information field, a parent node field, a sub-list field, a valid status field, a creator field, a modifier field, a creation time field, and a modification time field; The business primary key field is used to represent the identity identifier of the first-layer data; The core information field is used to represent the comment content of the currently to-be-created data; The parent node field is used to represent the reply object of the currently to-be-created data; The sub-list field is used to represent the data description information of non-first-layer data; The first data to be created is obtained by extracting the values of the core information field, the valid status field, the creator field, and the creation time field in the data description information; the second data to be created is obtained by extracting the value of the sub-list field in the data description information.
9. A data query device, characterized in that, including: a query condition acquisition module, configured to respond to a first-layer data query request, and obtain a first-layer paging query condition and a non-first-layer associated paging query condition associated with the first-layer paging query condition from the first-layer data query request; wherein, the first-layer data query request is a query request for root node data in a preset tree structure; the first-layer paging query condition represents paging query of the root node data, and each page includes a first specified number of root node data; the non-first-layer associated paging query condition represents a second specified number of non-root node data associated with querying each root node data from the preset tree structure; The first-layer data query module is used to query each target first-layer data and each target non-first-layer data associated with each target first-layer data respectively from a preset data table in the database according to the first-layer paging query condition and the non-first-layer associated paging query condition, so as to implement first-layer data query and non-first-layer data associated query; Among them, the preset data table is in a row-column mixed mode, each row data represents first-layer data, and each column data corresponding to each row data represents non-first-layer data; the column data uses the row data as the business primary key.
10. An electronic device, characterized in that, The electronic device includes: One or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data query method as described in any one of claims 1-8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the data query method as described in any one of claims 1-8.
Citation Information
Patent Citations
Column type memory storage and query device and column type memory storage and query method
CN104750727A
Comment display method and data acquisition method
CN110188298A
Query method and system for paging to obtain cloud platform terminal data
CN110928902A
Hierarchical relationship query response time reducing method, server and user front end
CN111026962A
Data query method and device based on online analytical processing and electronic equipment
CN117349288A