CouchDB 中地址簿的最佳文档格式
我真的很努力,很努力,但我无法理解 couchdb :( 我必须记录几个人的联系方式,我应该将每个联系人放在一个文档中吗?
"1th documet"
{
"names" : [
Jake", "Lock"
]
"numbers" : [
"Jake's number", "Lock's number"
]
}
Future records:
"1th documet"
{
"names" : [
Jake", "Lock", "Kate", "Jin", ...
]
"numbers" : [
"Jake's number", "Lock's number", "Kate's number", "Jin's number", ...
]
}
还是放在不同的文档中?
"1th document"
{
"name" : "Jake"
"number" : "Jake's number"
}
"2th document"
{
"name" : "Lock"
"number" : "Lock's number"
}
Future records:
"1th document"
{
"name" : "Jake"
"number" : "Jake's number"
}
"2th document"
{
"name" : "Lock"
"number" : "Lock's number"
}
"3th document"
{
"name" : "Kate"
"number" : "Kate's number"
}
"4th document"
{
"name" : "Jin"
"number" : "Jin's number"
}
...
我很困惑,有人可以帮助我吗?
谢谢。
I really tried, tried so hard but i cant understand couchdb :( I must record the contact of several people, should i put every contact in a single document ?
"1th documet"
{
"names" : [
Jake", "Lock"
]
"numbers" : [
"Jake's number", "Lock's number"
]
}
Future records:
"1th documet"
{
"names" : [
Jake", "Lock", "Kate", "Jin", ...
]
"numbers" : [
"Jake's number", "Lock's number", "Kate's number", "Jin's number", ...
]
}
Or in different documents ?
"1th document"
{
"name" : "Jake"
"number" : "Jake's number"
}
"2th document"
{
"name" : "Lock"
"number" : "Lock's number"
}
Future records:
"1th document"
{
"name" : "Jake"
"number" : "Jake's number"
}
"2th document"
{
"name" : "Lock"
"number" : "Lock's number"
}
"3th document"
{
"name" : "Kate"
"number" : "Kate's number"
}
"4th document"
{
"name" : "Jin"
"number" : "Jin's number"
}
...
I confused, can somebody help me ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在存储这些联系人以形成某种地址簿样式的应用程序。根据这个假设,我想说你的第二个例子正是你想要做的。在我看来,每个“联系人”都是一个文档。该联系人的所有属性都包含在文档中。
更进一步来说,将来您可能决定希望为每个人存储多个号码,也许是不同类型的号码。我会将这些全部嵌入到特定联系人的文档中:
我发现设计用于文档数据库的模型的一个好方法是考虑您希望独立使用哪些项目。对于那些本身有意义的内容,他们可能应该进入自己的文档。对于那些只有在“容器”对象的上下文中查看才有意义的对象,请将它们嵌入其中。
我希望这对你有帮助。
I assume you are storing these contacts to form some kind of address-book style application. Going with this assumption, I would say your second example is exactly what you want to be doing. The way I look at it, each "contact" is a single document. All the attributes for this contact belong within the document.
To take this a bit further, in the future you might decide you wish to store multiple numbers per person, perhaps of different types. I would embed these all inside the document for the particular contact:
I find a good way to approach designing a model for use in a document database is to consider what items you will wish to use independently. For those which make sense on their own, they should probably go inside their own document. For those which only make sense when viewed in the context of their "container" object, embed them within it.
I hope this helps you.