| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Creating a Hierarchical Structure
How would you, or what is the commonly accepted way, of creating a database which represents a hierarchical category structure ala Yahoo!?
What I have done until now is to create a table called categories. Each field has a categoryID, a parentID and the category's name. The parentID is "0" for all top level categories, and all sub-categories inherit a parentID containing the categoryID of the category above it. So for instance:
CategoryID ParentID Name
1 0 Shopping
2 1 Retail
3 1 Business to Business
4 2 Clothing
I was talking to some guy yesterday who said the standard what of creating such a system in a directory was to have a table which contains your root categories and then a new table for every level of sub-category. So if your directory goes 10 levels deep you have 10 category tables each containing the categories of a level.
What's better and why? What do you guys do?
Gabe
-- Ender Technology Web Applications, Design, Hosting http://www.endertechnology.com 310-516-7411Received on Wed Aug 08 2001 - 11:49:25 CDT
![]() |
![]() |