Query method of database, readable storage medium, electronic equipment and program product

By generating target query statements in the database for recursive query, the collection of associated nodes in the tree structure data is directly obtained, which solves the problems of large memory usage and low query efficiency in the existing technology, and realizes a more efficient query process.

CN119293062APending Publication Date: 2025-01-10RENLIJIA NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411267192.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

When existing databases query tree structure data, the memory usage is large and the recursive assembly process is complicated, resulting in low query efficiency.

Method used

By generating target query statements to recursively query the associated nodes within the database, avoiding the additional recursive assembly process and directly obtaining the associated node collection.

Benefits of technology

Reduces memory usage and code complexity and improves query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293062A_ABST
    Figure CN119293062A_ABST
Patent Text Reader

Abstract

The invention provides a database query method, a readable storage medium, electronic equipment and a program product, a tree structure data set is maintained in a database, and at least two nodes are correspondingly arranged in the tree structure data set; the method comprises the following steps: acquiring a node set query request initiated for a target node in the tree structure data, wherein the node set query request comprises node information of the target node; generating a target query statement corresponding to the target node according to the node information, wherein the target query statement is used for recursively querying an association node having an association relationship with the target node in the tree structure data set based on the target node; and executing the target query statement to obtain a target node set formed by the associated nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present specification relates to the field of database technology, and in particular to a database query method, a readable storage medium, an electronic device, and a program product. Background Art

[0002] When storing data in a database, especially data with hierarchical relationships such as file systems, organizational structures, and comment reply chains, it can be stored based on a tree structure. The tree structure can not only effectively represent the complex hierarchical relationships between data, but also achieve flexible processing of each data through corresponding node operations. For the data tables in the above databases that store actual tree-structured data, how to obtain the associated nodes that have an associated relationship with the specified node has become a difficult problem in the industry.

[0003] In the related art, all the related data in the above data table are usually queried into the memory at one time, and then a chain structure corresponding to the above tree structure is recursively assembled according to the parent node of each node, and finally the above associated nodes are determined by the chain structure. However, this method occupies a large amount of memory, and the code complexity corresponding to the recursive assembly process is high, and the overall query efficiency is low. Summary of the invention

[0004] In view of this, the present specification provides a database query method, a readable storage medium, an electronic device and a program product to solve the deficiencies in the related art.

[0005] Specifically, this specification is implemented through the following technical solutions:

[0006] According to a first aspect of an embodiment of this specification, a method for querying a database is provided, wherein a tree structure data set is maintained in the database, and the tree structure data set corresponds to at least two nodes; the method comprises:

[0007] Obtaining a node set query request initiated for a target node in the tree structure data, wherein the node set query request includes node information of the target node;

[0008] Generate a target query statement corresponding to the target node according to the node information, wherein the target query statement is used to recursively query associated nodes that have an associated relationship with the target node in the tree structure data set based on the target node;

[0009] The target query statement is executed to obtain a target node set consisting of the associated nodes.

[0010] According to a second aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in the first aspect are implemented.

[0011] According to a third aspect of the embodiments of this specification, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method described in the first aspect are implemented.

[0012] According to a fourth aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the method described in the first aspect when executed by a processor.

[0013] In the technical solution provided in the present specification, a node set query request initiated for a target node in tree structure data is obtained, and a target query statement corresponding to the above target node is generated according to the node information in the request, so that the database executes the above target query statement to obtain a set of associated nodes composed of the above associated nodes, wherein the generated target query statement can instruct the database to recursively query the associated nodes that have an associated relationship with the above target node based on the target node. Since the recursive query process occurs inside the database, the above associated node set does not need to undergo an additional recursive assembly process, thereby reducing local memory usage and code complexity and improving overall query efficiency.

[0014] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification, and for ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0016] Figure 1 It is a schematic diagram of the architecture of a database query system shown in an exemplary embodiment of this specification;

[0017] Figure 2 It is a flowchart of a database query method shown in an exemplary embodiment of this specification;

[0018] Figure 3 is a schematic diagram of a tree structure data set shown in an exemplary embodiment of this specification;

[0019] Figure 4 It is a flowchart of another database query method shown in an exemplary embodiment of this specification;

[0020] Figure 5 is a schematic structural diagram of an electronic device shown in an exemplary embodiment of this specification;

[0021] Figure 6 It is a structural diagram of a database query device shown in an exemplary embodiment of this specification. DETAILED DESCRIPTION

[0022] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification.

[0023] It should be noted that in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, the single step described in this specification may be decomposed into multiple steps for description in other embodiments; and the multiple steps described in this specification may also be combined into a single step for description in other embodiments. It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determination".

[0024] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0025] An embodiment of a database query method of the present specification is described in detail below with reference to the accompanying drawings.

[0026] Figure 1is a schematic diagram of the architecture of a database detection system shown in an exemplary embodiment of this specification, such as Figure 1 As shown, the above system may include the following components: a client 10 and a database 12. Among them:

[0027] The client 10, as an application program interacting with the database 12, is responsible for obtaining data operation requests initiated by the user through the corresponding graphical interface or command line interface for the database 12, such as requests for querying, inserting, updating, deleting data, etc., and can send, for example, target query statements to the database 12 according to the above data operation requests, and then display or process the results returned from the database 12. In addition, the client 10 can be deployed and run on any device that can be connected to the database server, such as personal computers (PCs), mobile devices, servers, laptops, PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), and other electronic devices, and one or more embodiments of this specification are not limited to this.

[0028] The database 12 can be used to store a tree-structured data set, wherein each data in the tree-structured data set can be respectively regarded as a different node in the same tree structure, and all nodes except the root node correspond to a unique parent node. The corresponding storage form for the node content of each node and the relationship between each node in the tree structure can be adjusted according to the different database types. After receiving the target query statement from the client 10, the associated nodes that have an associated relationship with the target node can be queried in the tree-structured data set according to the target query statement, and then the associated node set composed of the above-mentioned associated nodes is returned to the client. In addition, the database 12 can be deployed in a physical server including an independent host, or a virtual server hosted by a host cluster, and one or more embodiments of the present specification are not limited to this.

[0029] In addition, the above-mentioned tree-structured data set can vary based on the specific type of the database 12. For example, when the above-mentioned database is a document-based database such as MongoDB, the above-mentioned tree-structured data set can be regarded as a collection containing a set of documents, wherein each document corresponds to a node; for another example, when the above-mentioned database is a relational database such as MySQL, the above-mentioned tree-structured data set can be regarded as a data table containing a set of records, wherein each record corresponds to a node.

[0030] Figure 2The present invention is a flowchart of a method for querying a database shown in an exemplary embodiment of the present specification. The database may maintain a tree structure data set, and the tree structure data set may correspond to at least two nodes. The method includes:

[0031] Step S202: obtaining a node set query request initiated for a target node in the tree structure data, wherein the node set query request includes node information of the target node.

[0032] When a user needs to obtain the associated node set of associated nodes related to a target node in a tree structure data set, the user can first initiate a node set query request for the target node through the client, and the client triggers the database to perform a corresponding query operation after obtaining the node set query request. The node set query request may include node information of the target node, and the node information may be a node identifier or other information used to uniquely identify the target node among all nodes corresponding to the tree structure data set.

[0033] The above-mentioned node set query request may also include the set type information of the node set to be queried (i.e. the above-mentioned associated node set), and the set type information may define the relationship between the above-mentioned target node and the above-mentioned associated node to control the content finally displayed by the above-mentioned associated node set. The specific corresponding relationship will be introduced in detail below, so this manual will not elaborate on it here.

[0034] Step S204: generating a target query statement corresponding to the target node according to the node information, wherein the target query statement is used to recursively query associated nodes that have an associated relationship with the target node in the tree structure data set based on the target node.

[0035] After the client obtains the above-mentioned node set query request, it can generate a target query statement for the above-mentioned target node based on the node information in the request, wherein the purpose of the target query statement is to query the associated nodes in the tree structure data set that have an associated relationship with the above-mentioned target node in a recursive query manner, rather than querying the target node itself.

[0036] The above-mentioned association relationship can be an ancestor and descendant relationship. In this case, the target node can be regarded as the ancestor node or descendant node of different associated nodes. At the same time, the client can preset the unique association relationship between the target node and the associated node, so that the associated nodes obtained by the query are only the ancestor nodes or descendant nodes of the target node; or, the user can add the above-mentioned collection type information in the above-mentioned node set query request to control and adjust the association relationship in each node set query request, that is, when the collection type information is represented as the ancestor node set of the target node, the above-mentioned target node can be the ancestor of the above-mentioned associated node; when the above-mentioned collection type information is represented as the descendant node set of the above-mentioned target node, the above-mentioned associated node can be the ancestor of the above-mentioned target node.

[0037] Below Figure 3 Take the target node and associated node as an example. Figure 3 As shown, the tree-structured data set of the database corresponds to 10 nodes, and each node corresponds to a node identifier "1" to "10" from left to right according to the hierarchical order of the tree structure, wherein, assuming that node 2 is the target node, the set type information of the node set to be queried is represented as the descendant node set of the target node, then the child nodes 4 and 5 of node 2, and the child nodes 9 and 10 of node 5 will all be used as the associated nodes of node 2; or, assuming that node 6 is the target node, the set type information of the node set to be queried is represented as the ancestor node set of the target node, then the parent node 3 of node 6, and the parent node 1 of node 3 will all be used as the associated nodes of node 6.

[0038] In this specification, the target query statement can be divided into two parts to respectively implement the recursive query capability.

[0039] In one embodiment, the target query statement may include a first clause for representing the query start node and a second clause for representing the query logic. First, the client may construct the initial first clause and the second clause based on the recursive query grammar of the database, then update the parameters in the first clause according to the node information, and update the parameters of the second clause according to the set type information, and finally concatenate the updated first clause and the second clause to generate the target query statement.

[0040] The above recursive query syntax may vary depending on the type of database. Taking MongoDB in a document-based database as an example, the above recursive query syntax can be implemented in an aggregation pipeline. As a pipeline for processing data records, each stage in the aggregation pipeline performs some operations on the data and then passes the results to the next stage. The "$match" stage can be used as the first clause to pass documents (i.e., nodes) that meet specific conditions to the second clause to perform a recursive query, and the specific conditions can be used as parameters of the first clause. The "$graphLookup" stage can be used as the second clause to find documents that match the current document, and then recursively find all children / parents, and the definition conditions of the children can be used as parameters of the second clause, such as the connection source field (connectFromField) and the connection output field (connectToField) defined by $graphLookup. Taking "WITH RECURSIVE" in a relational database as an example, the above recursive query syntax can be implemented using the "WITH RECURSIVE" syntax, wherein the WITH RECURSIVE syntax can include a basic query and a recursive query, which can be connected through, for example, UNION ALL. The above basic query can be used as the first clause to select records that meet the corresponding parameters as the above target node, and the above recursive query can be used as the second clause to recursively query all children / parents of the target node according to the corresponding parameters. In addition, the above recursive query syntax can also be configured with a maximum search depth to explicitly specify the maximum depth of the recursion to avoid the special case of infinite recursion.

[0041] It should be noted that the parameters of the initial first clause and the second clause can be a blank value or a default value, so the update operation on the above parameters can be regarded as a process of filling in blank values ​​or replacing default values, which is not limited in this specification.

[0042] Step S206: execute the target query statement to obtain a set of associated nodes consisting of the associated nodes.

[0043] After generating the target query statement, the client can send it to the database and trigger it to execute the statement, thereby obtaining a set of associated nodes in the database composed of the above-mentioned associated nodes. The above-mentioned associated node set can be applied to the abnormal self-detection process for the tree-structured data set, or other functional processing processes.

[0044] In one embodiment, the client can match the above-mentioned target node in the acquired associated node set according to the above-mentioned node information; if the match is successful, it is determined that the target node has a loop anomaly in the tree structure data set. In this embodiment, a successful match means that there are two target nodes in the tree structure data set and they are associated with each other. For example, node 1 is both the parent node and the child node of another node 2. This situation can be called a "ring" or "loop", which is an abnormal situation that does not conform to the basic definition and properties of the tree structure. Therefore, the user can be notified in time through the client to perform abnormal repair processing. In this embodiment, the client can carry out targeted detection operations on the loop situation of the target node, which effectively simplifies the detection process and improves the detection efficiency.

[0045] Of course, a failed match does not mean that there must be no loop anomalies in the tree-structured data set. The reason is that a single match is applicable to determining whether a single target node forms a loop with the nodes in its ancestor node set or descendant node set, and does not cover the loop situations of all nodes with the ancestor node set and the nodes in the descendant node set. In other words, the client can complete the loop anomaly detection for the entire tree-structured data set by executing corresponding target query statements on different target nodes in turn.

[0046] In another embodiment, the node set query request may also include filtering node information different from the node information. The client may match the corresponding associated nodes in the associated node set according to the filtering node information; if the match is successful, the associated node set may be deleted for the matched associated nodes, and the processed associated node set may be returned. In this embodiment, the associated node set often contains invalid nodes that the user does not care about. When generating a node set query request, the client may also add filtering node information to it to represent the nodes that the user does not expect to appear in the associated node set, thereby improving the readability of the associated node set.

[0047] In some recursive query syntaxes, the associated node set formed by executing the target query statement will use at least one layer of nested structure to maintain the associated nodes obtained by the recursive query, but the corresponding number of nested levels does not match the number of levels of the corresponding tree structure in the associated node set, resulting in misjudgment when the client directly judges the association relationship between the target node and the associated node based on the number of nested levels. To avoid the above situation and improve the usage scenarios of the extended associated node set, the client can perform flattening processing on the associated nodes of each nested level in the obtained associated node set to obtain an associated node set without a nested structure, such as an array structure in JSON (JavaScript Object Notation) format.

[0048] Combine the following Figure 4 Explain the query method of another database, such as Figure 4 As shown in FIG. 1 , the method comprises the following steps:

[0049] Step S402: obtaining a node set query request initiated for a node corresponding to a target organization in the company's internal organizational structure information.

[0050] In one embodiment, assume that there is a collection named "organizations" in the MongoDB database, which stores the organizational structure information within the company. Each document represents an organizational unit and has the following structure:

[0051]

[0052] Each organizational unit has an orgId to uniquely identify itself and a parentOrgId to identify its parent organizational unit. If parentOrgId is null, it means that the organizational unit is the top-level organization.

[0053] Assume that the user needs to query all sub-organizations under the "head office", including sub-organizations at all levels. Then a node set query request for the target node with orgId 1 can be initiated to the client, and in addition to orgId, the request can also include non-essential data such as "parentOrgId" and "name" for information verification of the target node.

[0054] Step S404: Generate a corresponding database query statement according to the node set query request.

[0055] In one embodiment, after obtaining the above node set query request, the client may construct the following initial database query statement based on the aggregation pipeline:

[0056]

[0057]

[0058] Among them, the $match code block is used as the first clause of the target query statement to locate the above target node, and the values ​​of the orgId and parentOrgId fields can be further determined based on the node information of the above node collection query request. The $graphLookup code block is used as the second clause of the target query statement to recursively query all sub-organizations of the target node, and the field values ​​of connectFromField and connectToField can be predetermined, so that the node collection query request can query the sub-organization by default even if the collection type information is not included. Of course, if you need to query all parent organizations of the target node, you can actively set the value of connectFromField to "parentOrgId" and the value of connectToField to "orgId" through the collection type information.

[0059] Step S406: trigger the database to execute the database query statement and obtain the associated node set through the MongoDB client.

[0060] In one embodiment, the MongoDB client may send the above database query statement to the database, and the database may execute the above database query statement after receiving it and return the following result to the above client.

[0061]

[0062]

[0063] Step S408: Flatten the associated node set

[0064] In one embodiment, considering that the associated node set has a multi-layer nested structure, the client may flatten it so that nodes of all levels are displayed flatly at the same level as described below.

[0065]

[0066]

[0067] Among them, data originally belonging to different nested levels are converted into a single-layer, non-nested structure to facilitate the implementation of subsequent functional operations, such as verifying whether the above-mentioned target node forms a loop in the organizational structure information within the company, or detecting the departmental authority of the target node (assuming that the superior organization has the authority of the subordinate organization associated with it).

[0068] Figure 5 is a schematic structural diagram of an electronic device provided by an exemplary embodiment. Figure 5, at the hardware level, the device includes a processor 502, an internal bus 504, a network interface 506, a memory 508 and a non-volatile memory 510, and of course may also include hardware required for other functions. One or more embodiments of this specification can be implemented based on software, such as the processor 502 reading the corresponding computer program from the non-volatile memory 510 into the memory 508 and then running it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logical devices or a combination of hardware and software, etc., that is, the execution subject of the following processing flow is not limited to each logical unit, but can also be hardware or logical devices. Corresponding to the embodiment of the aforementioned database query method, this specification also provides an embodiment of a database query device.

[0069] Figure 6 A block diagram of a database query device shown in an embodiment of the present invention. Figure 6 , wherein the database maintains a tree structure data set, and the tree structure data set corresponds to at least two nodes; the device may include:

[0070] The node set query request acquisition unit 602 is used to acquire a node set query request initiated for a target node in the tree structure data, wherein the node set query request includes node information of the target node.

[0071] The target query statement generating unit 604 is used to generate a target query statement corresponding to the target node according to the node information, and the target query statement is used to recursively query the associated nodes that have an associated relationship with the target node in the tree structure data set based on the target node.

[0072] The associated node set acquisition unit 606 is configured to execute the target query statement to acquire an associated node set consisting of the associated nodes.

[0073] Optionally, the association relationship is an ancestor-descendant relationship; the node set query request further includes set type information of the node set to be queried;

[0074] In the case where the set type information is characterized as a set of ancestor nodes of the target node, the target node is an ancestor of the associated node;

[0075] In the case where the set type information represents a set of descendant nodes of the target node, the associated node is an ancestor of the target node.

[0076] Optionally, the target query statement includes a first clause for representing a query start node and a second clause for representing a query logic; the target query statement generating unit 604 is specifically used to:

[0077] Constructing the first clause and the second clause based on the recursive query grammar of the database;

[0078] updating the parameters of the first clause according to the node information, and updating the parameters of the second clause according to the set type information;

[0079] The updated first clause is concatenated with the second clause to generate the target query statement.

[0080] Optionally, the database is a document database or a relational database.

[0081] Optionally, the associated node set uses at least one layer of nested structure to maintain the associated nodes; the device further includes:

[0082] The flattening processing unit is used to perform flattening processing on the associated nodes of each nested level in the associated node set to obtain an associated node set without a nested structure.

[0083] Optionally, the device further comprises:

[0084] a loop anomaly detection unit, configured to match the target node in the associated node set according to the node information;

[0085] In the case of successful matching, it is determined that the target node has a loop anomaly in the tree structure data set.

[0086] Optionally, the node set query request further includes filtering node information different from the node information; and the device further includes:

[0087] Matching corresponding associated nodes in the associated node set according to the filtering node information;

[0088] In the case of successful matching, a deletion process is performed on the associated node set for the matched associated nodes, and the processed associated node set is returned.

[0089] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0090] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. Ordinary technicians in this field can understand and implement it without paying creative work.

[0091] Based on the same concept as the above method, this specification also provides an electronic device, including: a processor; a memory for storing processor executable instructions; wherein the processor implements the steps of the method described in any of the above embodiments by running the executable instructions.

[0092] Based on the same concept as the above method, this specification also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in any of the above embodiments are implemented.

[0093] Based on the same concept as the above method, this specification also provides a computer program product, including a computer program / instruction, which implements the steps of the method described in any of the above embodiments when executed by a processor.

[0094] Although the present invention includes many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of the specific embodiments of specific inventions. Certain features described in multiple embodiments of the present invention may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although features may work in certain combinations as described above and even initially claimed as such, one or more features from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of a sub-combination.

[0095] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that these operations be performed in the particular order shown or performed sequentially, or requiring that all illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product, or packaged into multiple software products.

[0096] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.

[0097] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for querying a database, characterized in that: The database maintains a tree structure data set, and the tree structure data set corresponds to at least two nodes; the method includes: Obtaining a node set query request initiated for a target node in the tree structure data, wherein the node set query request includes node information of the target node; Generate a target query statement corresponding to the target node according to the node information, wherein the target query statement is used to recursively query associated nodes that have an associated relationship with the target node in the tree structure data set based on the target node; The target query statement is executed to obtain an associated node set consisting of the associated nodes.

2. The method according to claim 1, characterized in that: The association relationship is an ancestor-descendant relationship; the node set query request also includes set type information of the node set to be queried; In the case where the set type information is characterized as a set of ancestor nodes of the target node, the target node is an ancestor of the associated node; In the case where the set type information represents a set of descendant nodes of the target node, the associated node is an ancestor of the target node.

3. The method according to claim 2, characterized in that The target query statement includes a first clause for representing a query start node and a second clause for representing a query logic; and generating a target query statement corresponding to the target node according to the node information includes: Constructing the first clause and the second clause based on the recursive query grammar of the database; updating the parameters of the first clause according to the node information, and updating the parameters of the second clause according to the set type information; The updated first clause is concatenated with the second clause to generate the target query statement.

4. The method according to claim 1, characterized in that The database is a document database or a relational database.

5. The method according to claim 1, characterized in that: The associated node set uses at least one nested structure to maintain the associated nodes; the method further includes: Flattening is performed on the associated nodes of each nested level in the associated node set to obtain an associated node set without a nested structure.

6. The method according to claim 1, characterized in that The method further comprises: Matching the target node in the associated node set according to the node information; In the case of successful matching, it is determined that the target node has a loop anomaly in the tree structure data set.

7. The method according to claim 1, characterized in that The node set query request further includes filtering node information different from the node information, and the method further includes: Matching corresponding associated nodes in the associated node set according to the filtering node information; In the case of successful matching, a deletion process is performed on the associated node set for the matched associated nodes, and the processed associated node set is returned.

8. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the program / instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.