Unholy Prayer Posted March 5, 2007 Share Posted March 5, 2007 I'm making my own forum for my website and I wanted to make subforums. I was wondering if I should make a whole separate database table or if I should just add an extra field in the forums table? Anyone know the best way to do this? Quote Link to comment Share on other sites More sharing options...
fert Posted March 5, 2007 Share Posted March 5, 2007 Here's how i do it TABLE forums title TEXT description TEXT rank_level INT TABLE subforums title TEXT description TEXT rank_level INT forum TEXT Quote Link to comment Share on other sites More sharing options...
Unholy Prayer Posted March 5, 2007 Author Share Posted March 5, 2007 Hmm... I'll give it a try. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted March 5, 2007 Share Posted March 5, 2007 personally i'd go with the adding of a new field - i.e, parent_id - and keep all the forums and subforums in the same table. This way, if you decided (for example) to add a 'forum description', or perform a restructure, then you're only handling a single table and not two. Also when it comes to dealing with stuff like posts/topics/forum permissions, etc, having a single, consistent table will be much easier to code for. id active (ENUM, y or n) parent_id title description ...etc... Quote Link to comment Share on other sites More sharing options...
mb81 Posted March 20, 2007 Share Posted March 20, 2007 personally i'd go with the adding of a new field - i.e, parent_id - and keep all the forums and subforums in the same table. This way, if you decided (for example) to add a 'forum description', or perform a restructure, then you're only handling a single table and not two. Also when it comes to dealing with stuff like posts/topics/forum permissions, etc, having a single, consistent table will be much easier to code for. id active (ENUM, y or n) parent_id title description ...etc... I agree with this, just assign a parent_id of 0 to all top level forums, then all others can use the unique id as their parent id. One of my big projects right now uses XMB forums and that's the way they do it. I have also used it for a simplified structure for a resource browser that uses a directory structure. The subforum table is very discouraged, because what happens if you want to create sub-sub-forums, or sub-sub-sub forums. Then you are multiplying your workload. Quote Link to comment Share on other sites More sharing options...
Liquid Fire Posted April 11, 2007 Share Posted April 11, 2007 yea, creating one table for all the forums i would think is the most efficient way of doing this. I will mostly likely be build my own forum system for my project management system and that is the way i would ever consider doing the forum table. This way you don't limit yourself on how many subforums you can have and does make coding easier besuase you will only have 1 table to deal with wether is it a top level forum and a sub forum. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.