Asp. NET infinite-level classification of beautiful fields (depth field)

Source: Internet
Author: User

The Red Arrows in the following figure are the parent class and belong to the root level.

The following fields: ID Parent ID type name Depth sort

There is nothing to explain in the first 3 fields, and it should be clear to anyone who has done an infinite class of classification design

And the 5th field sort Field Id:43 's 23 sort represents him in this table at 23 's root directory

And the 23,01 below 23 shows that he is a Class 2 category, ranked No. 01 below 23, and also supports the 99 level classification.

And I am more special is a depth field, you can look at the graph data,

The id:40 depth field is also the 40,id:43 depth field also 43.

And their subordinate subclass, followed by a "," plus their own ID.

Level 2 subclass of the depth of the field is (parent ID, their own id), and so on, and so on, 3-level classification depth is (the total parent class ID, parent class ID, own ID), not to mention later.

See here can look at the above picture, because I this website program, only 2 level classification just.

And of course, the middle one "," You can use your own favorite characters you use "|" "-" "_" all characters are OK but it is recommended that you have a character.

Because in the program is good to split, but also very intuitive, can completely modify their own data in the database classification (because the site classification generally set a little change, the first time can be completely added to the database all categories)

Speaking here, in order to say that this field has what function and benefits, I look at this field seems to be a waste of resources, the following listen to my careful way:

In the industry portal often has such a requirement, need to find out a category of all subcategories, if there is no this field,

Then find out all the following categories of words, the SQL statement should be very long, or use recursion: According to the Level 1 parent class ID found all 2 categories--according to the 2-level classification id--all 3-level classification, if there are multi-level classification, such a recursive efficiency can be imagined.

If you have this field (and the data has been added), everything will be much better, so that you can easily identify all the subclasses under a category, and look at the following figure:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.