keldorn Posted November 8, 2009 Share Posted November 8, 2009 I'm able to easily create categories, but I run into problems trying to think of ways to create sub-categories of a category in a sql database, how can this be done in the most efficient way? This is how I would do with no sub categories. Say you an article table, that holds say articles. Okay you have: id+cat_id+content++++++++++++title 1+1------This is your first post+ Hello world Then you have another table called categories, where you have this, id+name 1+foo bar Doing this you can easily after a mysql query take the cat_id, then say, SELECT name FROM category_table WHERE id=1) You will get Foo bar. I belive this is called recurvsive naming, where the article table only holds the ID number of the category, which translates to name in category_table. But things to me, get more confusing when designing sub-categories. So what is the best way to design the tables using sub categories? Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.