在数据库中存储问卷有什么有效的方法? [英] What's an effecient way to store a questionnaire in a database?

查看:721
本文介绍了在数据库中存储问卷有什么有效的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于问卷总是可以改变,问题本身可能很长,因此将问题用作列名似乎很愚蠢。
在数据库中存储问卷是否有任何约定或已证明的方法?

Since questionnaires can always change and the questions themselves could be lengthy it seems silly to use questions as column names. Is there any convention or proven method for storing a questionnaire within a database?

我在想一个表格包含(问题ID,问题)然后是问题id和答案的第二个表。但是这个解决方案可能太慢,因为第三次加入对于加入特定用户的问题是必要的。

I was thinking of having a table with (Question-ID, Question) and then a second table for question-id and answer. But this solution might be too slow cause a third join would be necessary to join the questions with a particular user.

推荐答案

与加入?

将问题存储在一个表中。

Store questions in one table.

存储问题

如果回答是预定义的,并且在多个问题之间是共同的,那么在他们自己的表中存储公共答案,并创建另一个表, a AnswerID。

If answers are predefined those and are common among more then one question then store common answers in their own table and create another table that has a QuestionID with an AnswerID.

不要害怕联接,它们是关系数据库的一部分。没有连接,你只是处理平面文件。

Don't be scared of joins, they are part of relational databases. Without joins you're merely dealing with flat files.

这篇关于在数据库中存储问卷有什么有效的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆