【发布时间】:2016-01-14 05:41:05
【问题描述】:
我是 NoSql 数据库的新手,我很难弄清楚如何处理本地驱动器上可能超过 20MB 的非常大的 JSON 文档。这种结构肯定会随着时间的推移而增加,我担心查询的速度以及必须通过返回的 JSON 对象嵌套进行深入搜索才能得到一个字符串。例如,我的 JSON 嵌套很深。
{
"exams": {
"exam1": {
"year": {
"math": {
"questions": [
{
"question_text": "first question",
"options": [
"option1",
"option2",
"option3",
"option4",
"option5"
],
"answer": 1,
"explaination": "explain the answer"
},
{
"question_text": "second question",
"options": [
"option1",
"option2",
"option3",
"option4",
"option5"
],
"answer": 1,
"explaination": "explain the answer"
},
{
"question_text": "third question",
"options": [
"option1",
"option2",
"option3",
"option4",
"option5"
],
"answer": 1,
"explaination": "explain the answer"
}
]
},
"english": {same structure as above}
},
"1961": {}
},
"exam2": {},
"exam3": {},
"exam4": {}
}
}
在主应用程序中,根据考试类型、年份和主题创建和附加问题对象,使得 JSON 文档随着时间的推移变得庞大。我该如何重新建模以避免将来查询缓慢?
【问题讨论】:
-
听起来您需要创建更多文档,而不是不断扩展同一个文档。
-
谢谢 Dominic,我知道我应该像使用 SQL 数据库那样做,但是如何“规范化”和关联子文档对我来说有点困惑。
标签: json database nosql couchdb document-database