Mysql结构的论坛网站



我正在建设一个论坛网站,但我不能决定如何创建Mysql的结构。就像在这里,一个用户问了很多问题,用户回答了很多次,如果他们回答得更多,这些问题都不会被覆盖。所以,我会为论坛网站的问题和答案表创建一个表。如果我为每个用户只创建一个问题和答案表,它们不会被覆盖吗?

用户表:

user_id (int, auto_increment)
username (varchar)
password (varchar, 32 (md5))
email (varchar (to recover password))

论坛表:

forum_id (int, auto_increment)
forum_title (varchar)
forum_category (int)

论坛子类别:

forum_subcat_id (int, auto_increment)
forum_id (int)
forum_subcat_title (varchar)
forum_subcat_description (text)

论坛线程:

thread_id (int, auto_increment)
thread_title (varchar)
thread_body (text, regular thread format)
forum_subcategory (int, where it belongs)
posted_by (int, the user that posts the thread)
posted_on (int, timestamp of the time the thread was posted)

评论表:

comment_id (int, auto_increment)
comment_body (text, comment text)
thread_id (int)
commented_by (int, user_id)
comment_time (int, timestamp of the time the comment was posted)

只是给你一个大概的概念,当然你可以添加更多的功能,比如评分系统,投票等

这就是为什么不能为问题和答案创建一个表的原因。相反,您将有两个表。例如:

Question
========
question_id
question_text

Answer
======
answer_id
user_id
question_id
date_answered
answer_text

当然,上面的user_id暗示了另一个包含用户的表

最新更新