民意调查的最佳数据库架构是什么?一对多关系对此有好处吗?我正在考虑有两张桌子:
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
你怎么看?我想的对吗?
该架构看起来不错,是的,您需要还跟踪用户投票 https://stackoverflow.com/questions/2260406/voting-stopping-abuse-from-client-side-asp-net-mvc/2263045#2263045.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)