民意调查的最佳数据库架构是什么?一对多的关系对此有好处吗?我正在考虑有两张桌子:
poll_questions
int id
varchar body
datetime created_at
datetime updated_at
poll_answers
int id
varchar body
int votes default 0
int question_id (foreign key to poll_questions.id)
datetime created_at
datetime updated_at
然后还会有第三个表格用于跟踪谁为答案投票,因此用户只能投票一次:
poll_voting_history
int id
int question_id (foreign key to poll_questions.id)
int answer_id (foreign key to poll_answers.id)
int user_id (foreign key to the id in the users table)
datetime created_at
datetime updated_at
你怎么认为?我想对了吗?