Application of XML in unlimited Classification

Source: Internet
Author: User

Always consider an efficient way to achieve unlimited classification in relational databases
I tried the encoding method but found that many restrictions finally gave up.
I have also tried the classification method used in general forums, but I always feel that maintenance is not very convenient.
For more advanced classificationAlgorithmLimited to your own mathematical level, you will not consider it.

Think of using XML to store structured databases to record data and results
The tree structure of XML storage has the advantages of the device and is easy to maintain. Do not use recursion.

After the XML storage structure is formatted with XSL, the parallel classification data suitable for the database is obtained directly.
Then you can directly import the data to the database.
However, a small problem is that there are more entries with multiple categories updated.
However, you can control the update under one to two categories.
In this way, the number of updated entries is relatively small.

The following is a simple example.

XML classification structure file

<? XML version = "1.0" encoding = "UTF-8" ?>
< Categorys >
< Category ID = "1" Rootid = "1" >
< Category ID = "3" Rootid = "1" >
< Category ID = "4" Rootid = "1" >
< Category ID = "7" Rootid = "1"   />
</ Category >
</ Category >
< Category ID = "5" Rootid = "1" >
< Category ID = "6" Rootid = "1" >
< Category ID = "8" Rootid = "1"   />
</ Category >
</ Category >
</ Category >
< Category ID = "2" Rootid = "2"   />
</ Categorys >

XML classification calculation result File < Categorys >
< Category ID = "1" Rootid = "1" Parentid = "0" Depth = "0" Childcount = "6" Parentlist = "" Childlist = "3, 5" Sort = "1" />
< Category ID = "3" Rootid = "1" Parentid = "1" Depth = "1" Childcount = "2" Parentlist = "1" Childlist = "4" Sort = "2" />
< Category ID = "4" Rootid = "1" Parentid = "3" Depth = "2" Childcount = "1" Parentlist = "1, 3" Childlist = "7" Sort = "3" />
< Category ID = "7" Rootid = "1" Parentid = "4" Depth = "3" Childcount = "0" Parentlist = "1, 3, 4" Childlist = "" Sort = "4" />
< Category ID = "5" Rootid = "1" Parentid = "1" Depth = "1" Childcount = "2" Parentlist = "1" Childlist = "6" Sort = "5" />
< Category ID = "6" Rootid = "1" Parentid = "5" Depth = "2" Childcount = "1" Parentlist = "1, 5" Childlist = "8" Sort = "6" />
< Category ID = "8" Rootid = "1" Parentid = "6" Depth = "3" Childcount = "0" Parentlist = "1, 5, 6" Childlist = "" Sort = "7" />
< Category ID = "2" Rootid = "2" Parentid = "0" Depth = "0" Childcount = "0" Parentlist = "" Childlist = "" Sort = "8" />
</ Categorys >

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.