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 > category tree for recipe wiki

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-06, 10:23
rehack rehack is offline
Registered User
 
Join Date: Jan 2006
Posts: 18
category tree for recipe wiki

one other thing that's been sticking me is categories. i'd like my category system to work the same as ebay's - items can have many categories, and when displaying an item the category tree (or several trees) leading to it is displayed in a clickable manner. does this mean a recursive query for every page hit? should i worry about the performance of that?

requisite category table desc:
- category_id (0 denotes root category)
- parent_id
- name

also, is there any merit in forcing all recipes to live in a leaf node of the category tree? such that you'd have recipes -> desserts -> cakes -> sponge cakes, and then "other cakes" in the cakes category to shove everything else into. for some reason i just dislike the idea of having a category contain both sub-categories and actual items, but i can't articulate the reason for wanting to avoid it so much.

one problem i just thought of - what if i want people to be able to search for a random dessert or all desserts in a list. that would require building a list of every category that's a child, grandchild etc. of the desserts category_id, then finding recipe relationships for those categories.

first off, how would i build that list of categories? perform a select to find children of the category i want, then spawn selects for every child to find its children? then more selects? the categories can be arbitrarily deep, but now i'm having trouble visualizing how to terminate the select statement to parse the tree. i guess each category could contain an is_leaf_node value, and some hackery could terminate the query if the average of all the returned category's is_leaf_node values equals 1, but i'm just not liking this category tree the more i think about it.
Reply With Quote
  #2 (permalink)  
Old 01-14-06, 22:06
certus certus is offline
Registered User
 
Join Date: Dec 2003
Location: Canada
Posts: 710
Google around using the SQL TREES & HIERARCHIES
__________________
visit: relationary
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