数据库设计:两次保存值?

发布于 2024-11-01 17:11:33 字数 264 浏览 1 评论 0原文

我必须设计一个问卷系统。我们一起讨论了很多事情,包括如何把握答案,如何把握可能的答案。现在,我刚刚向我的同事屈服了,尽管我确实不同意。我只是想知道你对此的看法以及原因。 对我来说,两次保存相同的信息是一个非常糟糕的主意:

我们有一个表 Question_answer,它只保存一个问题 ID 和一个答案文本。 在另一个表中,我们保存答案,也带有文本字段。

我的想法是通过 id 将可能的答案链接到答案表,如果它是某种不同的答案,例如开放问题,我会将其放在可选的文本字段中......

I have to design a questionnaire system. We've been discussing a lot of things together, including how to hold answers, and how to hold the possible answers. Now, I've just given in to my collegue though I do disagree. I just want to know your opinions about it and why.
For me it's just a very bad idea to hold the same information twice:

We have a table question_answer, that just holds a question Id and an answer TEXT.
In another table, we hold answers, also with a TEXT field.

My idea was to just link a possible answer to the answer's table by id, and if it was some kind of different answer, like an open question, I would put it in a text field that is optional...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

来日方长 2024-11-08 17:11:34

我可能会从包含最多数据的表格开始 - 在这种情况下,这可能是将给定采访的问题与答案联系起来的调查回复(我刚刚将其建模为一对受访者和外国代表)键)。

调查表将问题链接到标准答案。我已将可选答案放入“响应”表中,但它们可以改为进入“答案”表(或者它可以是标准答案加可选答案表的视图,但您喜欢)。

问卷架构

I would probably start from the table that is going to hold the most data - which in this case is likely to be the survey responses that link questions to answers for a given interview (which I have just modeled as a pair of Respondant and Representative foreign keys).

The Surveys table links questions to standard answers. I've put optional answers into the Responses table, but they could go into the Answers table instead (or it could be a view onto Standard answers plus Optional answers tables, however you prefer).

Questionnaire Schema

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