views:

71

answers:

4

I'm making a forum.

I'm gonna store the id, subject, date, poster in a table named topics and keep the content in a table named posts. Now I just have to join them together nicely.

And how should I do to connect the post with the topic? I haven't slept in 30 hours so I'm a little slow :P

What do you guys think about this approach?

+2  A: 

You connect them by storing the TopicID with each Post record. As Alan said, sleep on that thought.

RedFilter
+1  A: 

First thing I would do is get some sleep.

Then, after a good rest, I would think about reading up on database design.

Here are some links.

Ed Guiness
+2  A: 

I agree with OrbMan. You should also use the same Primary key to connect to the table you use to store comments/replies

Ben Jones
A: 

You didn't mention 'post' as one of the fields in your question so I'll assume you want to keep it in a separate table.

You can link the two tables ('posts' and the one actually containing the posts [assume 'posttext'] having post stored in field 'postcontent') through the query: SELECT posts.subject, posts.date, posts.poster, posttext.postcontent FROM posts, posttext WHERE posts.id = posttext.id;

this id field could be any string, autonumber or hash generated at the time storing the post. you could hash the post text for example and store this hash as the id in both the tables ensuring uniqueness.

I would however suggest putting even the postcontent into the 'posts' table thereby saving two efforts:

  1. storing id in both table would be gone -> that means two queries one for each table now reduced to just one query (both while accessing and writing) so server time saved.
  2. database size would be mildly reduced because only one index would be used. since there is only one table not two.
OrangeRind