关系表优化 SuperKey
我知道如何解决这个问题,但我想知道解决这个问题的最佳方法是什么。
所以一个问题可以有多个答案 问题和答案可以有积分 只允许用户为每个问题/答案给出分数
Question:
id
title
Answer:
id
question_id
response
Points:
id
user_id
question_id
answer_id
points
因此,正如您所看到的,问题是带有 Question_id 和answer_id 的分数表。现在我想我可以通过拥有 Points_Question 表和 Points_Answer 表来解决这个问题,然后我可以加入 Total_points 表。这是最好的解决方案吗?
I have an idea of how to fix this but I was wondering what the best way to go about this.
So one Question can have multiple Answers
Question and Answers can have points
A user is only allowed to give points per question/answer
Question:
id
title
Answer:
id
question_id
response
Points:
id
user_id
question_id
answer_id
points
So as you can see the problem is the Points table with question_id and answer_id. Now I think I could solve this by having Points_Question table and Points_Answer table, then I could join the tables for total_points. Is this the best solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要在分数表中添加问题 ID,因为可以通过答案表中的答案 ID 访问问题。
you don't need to add questionid in points table as question can be accessed through answerid in answer table.