民意测验的最佳数据库模式是什么?一对多关系对此有好处吗?我正在考虑有两个表:
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
你有什么想法?我的想法对吗?
最佳答案
架构看起来不错,是的,您需要 track the user votes as well .
关于mysql - 轮询数据库模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2264750/