List:General Discussion« Previous MessageNext Message »
From:Peter Lovatt Date:July 29 2003 8:43am
Subject:RE: Category System schema
View as plain text  
you need at least 3 fields


CategoryID is the key, and identifies the category
ParentID is the CategoryID of the parent category
Name is the category name

When you add a sub category you set its ParentID to the CategoryID 

To show all sub categories of CategoryID 99

SELECT * FROM table WHERE ParentID = "99"



-----Original Message-----
From: Alex Pilson [mailto:alex@stripped]
Sent: 29 July 2003 06:06
To: mysql@stripped
Subject: Category System schema

Does anyone know the best schema to achieve a multi-level category system?

I need a person to be able to add categories on the fly, but then 
also specify sub categories and even possibly sub-categories of 
sub-cats. I have found two possible ways inside one table with using 
parentID, groupID, etc. But the issue I am now running into is that I 
have to sort on groupID to get the items to "group" correctly when 
showing in a HTML drop down list. Which means I can't sort 
alphabetically. If I do the order is not right...using Lasso 6 with 
some looping code to indent the subs in the list. On top of that I 
would also like the ability to assign a priority field for listing in 
that order as well. There has to be some kind of solution to this 
that I don't see.

Any ideas? Thanks!
     Alex Pilson
     FlagShip Interactive, Inc.

MySQL General Mailing List
For list archives:
To unsubscribe:

How to know the maxmimum length of data in a perticular column?Karam Chand28 Jul
  • Re: How to know the maxmimum length of data in a perticular column?Dan Nelson28 Jul
    • fulltext indexing and query speeds?Niels Larsen28 Jul
      • Re: fulltext indexing and query speeds?Sergei Golubchik28 Jul
    • Re: How to know the maxmimum length of data in a perticular column?Karam Chand29 Jul
      • Category System schemaAlex Pilson29 Jul
        • RE: Category System schemaPeter Lovatt29 Jul
Re: fulltext indexing and query speeds?Sergei Golubchik29 Jul
  • Re: fulltext indexing and query speeds?Niels Larsen29 Jul
    • Re: fulltext indexing and query speeds?Sergei Golubchik30 Jul