关系表优化 SuperKey

发布于 2024-09-24 12:19:04 字数 379 浏览 0 评论 0原文

我知道如何解决这个问题,但我想知道解决这个问题的最佳方法是什么。

所以一个问题可以有多个答案 问题和答案可以有积分 只允许用户为每个问题/答案给出分数

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2024-10-01 12:19:04

您不需要在分数表中添加问题 ID,因为可以通过答案表中的答案 ID 访问问题。

you don't need to add questionid in points table as question can be accessed through answerid in answer table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文