From: "Gabriel Richards" <grichards@endertechnology.com>
Newsgroups: comp.databases.theory
Subject: Creating a Hierarchical Structure
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Message-ID: <p4ec7.21643$Ug.5815984@typhoon.we.rr.com>
Date: Wed, 08 Aug 2001 16:49:25 GMT
NNTP-Posting-Host: 66.27.200.200
X-Complaints-To: abuse@rr.com
X-Trace: typhoon.we.rr.com 997289365 66.27.200.200 (Wed, 08 Aug 2001 09:49:25 PDT)
NNTP-Posting-Date: Wed, 08 Aug 2001 09:49:25 PDT
Organization: Road Runner


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-7411





