If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Model for unlimited categories/sub-categories

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-17-03, 12:13
Oddish Oddish is offline
Registered User
 
Join Date: Mar 2003
Posts: 43
Model for unlimited categories/sub-categories

I'm going to start work on a new version of a news script I'm using when making websites for my clients, and I'd like to remedy its biggest flaw: there's only one level of news categories.

What I want is a dynamic category system where I'll be able to create an unlimited ammount of sub categories, but I don't know where to start looking to learn how to design the database for this.

I did some searching on these forums but the posts about "nested" and "adjacency" models whent right over my head. Maybe someone could provide a link to an article which explains this in a more concrete way.

Thanks in advance for any and all information you can give me!
Reply With Quote
  #2 (permalink)  
Old 12-17-03, 18:46
certus certus is offline
Registered User
 
Join Date: Dec 2003
Location: Canada
Posts: 710
__________________
visit: relationary
Reply With Quote
  #3 (permalink)  
Old 12-17-03, 19:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
hey certus, thanks for mentioning one of my articles

here's another that shows some of the queries that you might use against the category hierarchy -- Top N subcategories

be sure to go to Part 2 of the article to see my "order by coalesce(parentid,id)" trick


rudy
Reply With Quote
  #4 (permalink)  
Old 12-17-03, 19:51
certus certus is offline
Registered User
 
Join Date: Dec 2003
Location: Canada
Posts: 710
Anytime, rudy.
__________________
visit: relationary
Reply With Quote
  #5 (permalink)  
Old 12-18-03, 03:50
Oddish Oddish is offline
Registered User
 
Join Date: Mar 2003
Posts: 43
Great! Thanks for the links, I'll see if I can get my head around them.
Reply With Quote
  #6 (permalink)  
Old 01-05-04, 04:29
Oddish Oddish is offline
Registered User
 
Join Date: Mar 2003
Posts: 43
I really like the method described by Rudy in this article (the COALESCE trick). But this method seems so much simpler than doing the whole "modified preorder tree traversal" thing so I'm thinking there must be some negative sides to using it. Am I paranoid?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On