我正在建立一个论坛网站,但我无法决定如何创建它的Mysql结构。就像在这里一样,用户会询问很多问题,用户会多次回答这些问题,如果他们回答得更多,他们都不会被覆盖。那么,我会为论坛网站创建一个问答表。如果我为每个用户创建一个问题和答案表,那么它们不会被覆盖吗?
答案 0 :(得分:1)
用户表:
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)
只是让你大致了解它应该是什么样子,当然你可以添加更多功能,如评级系统,民意调查等。
答案 1 :(得分:0)
这就是为什么你不会只为问题和答案创建一个表。相反,你有两张桌子。例如:
Question
========
question_id
question_text
和
Answer
======
answer_id
user_id
question_id
date_answered
answer_text
当然,上面的user_id意味着另一个用于包含用户的表。