Ric*_*nop 23 mysql database-schema
民意调查的最佳数据库架构是什么?一对多的关系对此有利吗?我正在考虑有两张桌子:
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
Run Code Online (Sandbox Code Playgroud)
然后还会有第三个表来跟踪谁投票给答案,这样用户只能投票一次:
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
Run Code Online (Sandbox Code Playgroud)
你的想法是什么?我在想它吗?