phpnoob Posted May 6, 2010 Share Posted May 6, 2010 HiI cant choice what solution its better.I want to make a forum with sub forum. 01.I make 6 table, 1 Main forum and topic and post table and 1 sub forum and sub topic and sub post table.02. i make 3 table 1 Main forum and topic and post table and 2 more columns for every table, for to sub.What solution its better? Link to comment Share on other sites More sharing options...
Synook Posted May 6, 2010 Share Posted May 6, 2010 Uh, the best solution is to only have one table, for all forums, subsidiary or not. This is how all real bulletin board systems work.You can always have an extra field called "parent" that records what a forum is subsidiary to. Link to comment Share on other sites More sharing options...
phpnoob Posted May 6, 2010 Author Share Posted May 6, 2010 Uh, the best solution is to only have one table, for all forums, subsidiary or not. This is how all real bulletin board systems work.You can always have an extra field called "parent" that records what a forum is subsidiary to.ok i choice the 3 table with one more column Link to comment Share on other sites More sharing options...
Synook Posted May 6, 2010 Share Posted May 6, 2010 Why don't you want to use a single table? Link to comment Share on other sites More sharing options...
phpnoob Posted May 6, 2010 Author Share Posted May 6, 2010 Why don't you want to use a single table?what?Only 1 table? you must be kidding :)That isn't a good idea Link to comment Share on other sites More sharing options...
ShadowMage Posted May 6, 2010 Share Posted May 6, 2010 what?Only 1 table? you must be kidding :)That isn't a good ideaActually I think that's exactly what he said it was...the best solution:Uh, the best solution is to only have one table, for all forums, subsidiary or not. This is how all real bulletin board systems work.You can always have an extra field called "parent" that records what a forum is subsidiary to. Link to comment Share on other sites More sharing options...
phpnoob Posted May 6, 2010 Author Share Posted May 6, 2010 Actually I think that's exactly what he said it was...the best solution:if you not know, this forum have 3 tables, not one Link to comment Share on other sites More sharing options...
phpnoob Posted May 6, 2010 Author Share Posted May 6, 2010 So heres an explain why is not a good idea the 1 table.I have 20 forum place, and all forums have 200 topic and 15000 post, so i have a 15220 record one that table, i know that, the server can read 1 million records for 1sec, but if my forum is really active, the server slow down, just think,if i make your idea, than if someone fresh the main forum page or topic or post place, the process search all record on that table every time, that's why it's not a good idea+ and is not clear . Link to comment Share on other sites More sharing options...
Synook Posted May 7, 2010 Share Posted May 7, 2010 Perform benchmarks or whatever, but I do assure you that I am not joking, for the sake of organisation and speed one table is better. Properly indexed, it will be much better for the database then making it access multiple tables. This bulletin board has all its posts in a single table. The largest bulletin board in the world (I wonder what it is?) has only one table for posts.Also, in terms of database theory it is very bad to have multiple tables that are basically duplicating the same fields. Link to comment Share on other sites More sharing options...
phpnoob Posted May 7, 2010 Author Share Posted May 7, 2010 Perform benchmarks or whatever, but I do assure you that I am not joking, for the sake of organisation and speed one table is better. Properly indexed, it will be much better for the database then making it access multiple tables. This bulletin board has all its posts in a single table. The largest bulletin board in the world (I wonder what it is?) has only one table for posts.Also, in terms of database theory it is very bad to have multiple tables that are basically duplicating the same fields.What do you mean about, duplicating the same fields.Main forum: select all record on forum tableView Topic: Select all record on topic tablePosting:Select all record on post tableNo duplicated field just three tableOr you meaning the 3 more table to the sub forum? :S Link to comment Share on other sites More sharing options...
ShadowMage Posted May 7, 2010 Share Posted May 7, 2010 Ah, see now that's a different story. I think there was a bit of a misunderstanding here. I (and I think Synook did too) thought you were creating three tables in which posts were to be stored. One for each of your forums. But I see what you're saying now, and yes I think that is the way you should do it.One table for the forum list.One table for the topic list which has a forumID field to link it to a forum.One table for the posts which has a postID field to link it to a topic (and possibly a forumID field) Link to comment Share on other sites More sharing options...
phpnoob Posted May 7, 2010 Author Share Posted May 7, 2010 Ah, see now that's a different story. I think there was a bit of a misunderstanding here. I (and I think Synook did too) thought you were creating three tables in which posts were to be stored. One for each of your forums. But I see what you're saying now, and yes I think that is the way you should do it.One table for the forum list.One table for the topic list which has a forumID field to link it to a forum.One table for the posts which has a postID field to link it to a topic (and possibly a forumID field)Yessorry my english really sucks :SOk againWhat is the best choice?I make 1 more table for each table for Sub forum or i make only 1 more column to all table"The sub forum is a forum in the topic list" Link to comment Share on other sites More sharing options...
ShadowMage Posted May 7, 2010 Share Posted May 7, 2010 I would still stick with 3 tables.One for the forums:You would also include the sub forums in this table but perhaps create a field called parentForum or something so that you know that forum belongs to another forum. In the case of the main forums you would leave that field blank. When you load your list of main forums you would just create a WHERE clause on your query to check if parentForum was blank. When you enter a forum you again search the forums table for all forums with parentForum equal to the forumID of the forum you are in.One for all the topics:All of your topics will go in this table. Every topic, for every forum. You would then have a field called forumID so that you know which forum the topic belongs to.One for all the posts:All the posts will go in this table. Every post, for every topic, for every forum. You would then have a field called topicID so you know which topic the post belonged to. It might also be good to store the forumID in this table too.Does that make sense? Link to comment Share on other sites More sharing options...
phpnoob Posted May 10, 2010 Author Share Posted May 10, 2010 Thx for helping Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.