Method for setting up tree-shaped data structure applied to online education system
A technology of data structure and establishment method, applied in the field of data processing, can solve the problems of low query efficiency, difficult to support data expansion and infinite depth of sub-node cascade, etc., to achieve the effect of improving efficiency
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0032] see figure 2 , which is a simple finite-level tree data structure.
[0033] First, starting from the root node, according to the order from top to bottom, from left to right, according to the rules of increasing sequence, define a left number value Lft and a right number value Rgt for each node in sequence; when setting the root node The initial value starts from 1, and when the increment is 1, according to the query formula: ROUND((Rgt-Lft-1) / 2), get figure 2 The left and right number values of the nodes shown. Preferably, the numbering rules of the left numbered value Lft and the right numbered value Rgt are implemented by the CPU through logic operations.
[0034] According to create a tree data storage structure, establish such as image 3 The relational data table shown.
Embodiment 2
[0036] The tree data storage structure is an infinite hierarchical tree data structure.
[0037] In more application scenarios, under the new data storage structure, let's take a look at the solutions corresponding to several practical application scenarios that we usually encounter in applications. Here, we take the infinite-level tree menu data as an example to create a relational data table as follows:
[0038]
[0039] In this relational data table, we insert a small amount of sample data so that the results can be seen intuitively in subsequent query applications:
[0040]
[0041] / / Remove all leaves:
[0042] select*from menutree where rht=lft+1;
[0043] / / Get the path of a node:
[0044]
[0045] / / Get all the trees and the depth of each node:
[0046] SELECT node.name,(COUNT(parent.name)-1) AS depth
[0047] FROM menutree AS node,menutree AS parent
[0048] WHERE node.lft BETWEEN parent.lft AND parent.rgt
[0049] GROUP BY node.name
[0050] ORDER BY n...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com