Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. MySQL
  4. what kind of table structure is this

what kind of table structure is this

Scheduled Pinned Locked Moved MySQL
databasetutorialquestiondata-structures
5 Posts 2 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jayapal Chandran
    wrote on last edited by
    #1

    I have created a table in which i have categories and products all in one table. i have id and pid column. Id is the main uniq id and pid is for the parent id. so for any first category the pid is 0 which means it is the top most. consider for example the first category is id 1 and inside that i am creating another category say cat2. this would have id=2 and pid=1 and it can go like a tree structure. Now i want to manipulate data in this table. for example i might start at any mid point and i want all its children as result set. for example i have a structure like this... cat1->cat2->cat3->cat4->cat5 now i want to delete cat3 and its sub items. i have the id of cat3 and now i dont know how to form a query to list all its sub items or to fetch all its sub items ids to delete or to do other process. also what is the term to such structure in database concepts?

    Today's Beautiful Moments are Tomorrow's Beautiful Memories

    C J 2 Replies Last reply
    0
    • J Jayapal Chandran

      I have created a table in which i have categories and products all in one table. i have id and pid column. Id is the main uniq id and pid is for the parent id. so for any first category the pid is 0 which means it is the top most. consider for example the first category is id 1 and inside that i am creating another category say cat2. this would have id=2 and pid=1 and it can go like a tree structure. Now i want to manipulate data in this table. for example i might start at any mid point and i want all its children as result set. for example i have a structure like this... cat1->cat2->cat3->cat4->cat5 now i want to delete cat3 and its sub items. i have the id of cat3 and now i dont know how to form a query to list all its sub items or to fetch all its sub items ids to delete or to do other process. also what is the term to such structure in database concepts?

      Today's Beautiful Moments are Tomorrow's Beautiful Memories

      C Offline
      C Offline
      CitrusTech
      wrote on last edited by
      #2

      Well it looks like a hierachical query to me. You might want to check out http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

      Data Quality and Decision Tree tools

      J 2 Replies Last reply
      0
      • C CitrusTech

        Well it looks like a hierachical query to me. You might want to check out http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

        Data Quality and Decision Tree tools

        J Offline
        J Offline
        Jayapal Chandran
        wrote on last edited by
        #3

        Yes i was looking for this. I have used adjacent list model. But the effective one according to that article is nested model. So i need to some gimmick in my php code like looping. The hierarchy will not go too long so a looping or recursion will do to delete items from this hierarchy. Thank you.

        Today's Beautiful Moments are Tomorrow's Beautiful Memories

        1 Reply Last reply
        0
        • C CitrusTech

          Well it looks like a hierachical query to me. You might want to check out http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

          Data Quality and Decision Tree tools

          J Offline
          J Offline
          Jayapal Chandran
          wrote on last edited by
          #4

          If you have some links that would delete adjacency list model recursive deletion then please drop those here. just in case if have...

          Today's Beautiful Moments are Tomorrow's Beautiful Memories

          1 Reply Last reply
          0
          • J Jayapal Chandran

            I have created a table in which i have categories and products all in one table. i have id and pid column. Id is the main uniq id and pid is for the parent id. so for any first category the pid is 0 which means it is the top most. consider for example the first category is id 1 and inside that i am creating another category say cat2. this would have id=2 and pid=1 and it can go like a tree structure. Now i want to manipulate data in this table. for example i might start at any mid point and i want all its children as result set. for example i have a structure like this... cat1->cat2->cat3->cat4->cat5 now i want to delete cat3 and its sub items. i have the id of cat3 and now i dont know how to form a query to list all its sub items or to fetch all its sub items ids to delete or to do other process. also what is the term to such structure in database concepts?

            Today's Beautiful Moments are Tomorrow's Beautiful Memories

            J Offline
            J Offline
            Jayapal Chandran
            wrote on last edited by
            #5

            This is working for me to delete a table like this. http://www.dynamicdrive.com/forums/showthread.php?t=55892[^]

            Today's Beautiful Moments are Tomorrow's Beautiful Memories

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups