gpt4 book ai didi

mysql - 轮询数据库模式

转载 作者:IT老高 更新时间:2023-10-28 23:49:06 25 4
gpt4 key购买 nike

民意测验的最佳数据库模式是什么?一对多关系对此有好处吗?我正在考虑有两个表:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com