2011-08-15 104 views
0

我正在建立一個論壇網站,但我無法決定如何創建它的Mysql結構。就像在這裏一樣,用戶提出了很多問題,用戶多次回答他們,如果他們回答更多,他們都不會被覆蓋。所以,我會爲論壇網站的問題和答案表創建一個表格。如果我爲每個用戶創建一個問題表和答案表,他們不會被覆蓋嗎?論壇網站的Mysql結構

回答

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) 

只是給你一個廣泛的思路應該是什麼樣子,當然你也可以添加更多的功能,如評級體系,民意調查等

0

這就是爲什麼你不會爲問題和答案創建一個表。相反,你會有兩張桌子。例如:

Question 
======== 
question_id 
question_text 

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

當然,上述user_id說明意味着另一個表用於包含用戶。