简体   繁体   中英

How would the tree hierarchy look like in this table?

表

I am new to SQL tree and hierarchies and was reading up on tree utilities in SQL server. I came across this table on codeproject and I've a hard time visualizing the tree (I tried drawing it out but I might have gotten it wrong). My question is...how does the NLEFT and NRIGHT ID look like in this instance?? For eg would Tranquilicity be the parent of Miracle and Miracle being the Parent of Emruad etc?? Just need a visualized tree to understand the concept...Thanks guys!!

This looks like Nested set model

EDIT

I think article Managing Hierarchical Data in MySQL will help you, there are described techniques to work with Nested Set Model and Adjacency List Model

This is a self-referencing table where P_ID is a foreign key referring to another row's ID and NLEVEL indicates how deep each node is in the tree. Not sure what NLEFT and NRIGHT are. They don't appear to have anything to do with the structure of the tree, but I can't be sure.

  • Tranquilicity
    • Miracle drizziacle
      • Emruad
      • Geoges
        • Chill ville
        • Carystopia
          • Icing drip drop
          • Vlairbor
          • Loneliness-Ville
          • Asira
            • Nocity
            • Aneril
            • Frozen objects
              • Lantasia
              • Boricua
              • Aribasci
              • Tylersville
          • Wird oh just weird
          • Veridian
        • Goosberry Ville

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM