2011-08-15 6 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 사용자를 포함하기위한 또 다른 테이블을 의미한다.