what kind of table structure is this
-
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
-
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
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
-
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
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
-
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
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
-
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
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