对于 Mongodb 中的客户用户关系,哪种方案最合适?
Which scheme would be the best one for client users relation in Mongodb?
我是 mongodb 的新手,正在阅读一些有关关系的示例,但仍然可以理解它,也许是因为我与 sql 相处的时间太长了。所以我有 table 个客户,table 个用户,我在 MongoDB 中标明了我可以嵌入这样的东西
db.clients.findOne()
{
id : '1',
name: 'Client',
users : [
{ name: 'User 1', id: '1' },
{ name: 'User 2', id: '2' }
]
}
或
两个分开的 tables
clients : [
{ name: 'User 1', id: '1'}
]
And
users : [
{ name: 'User 1', id: '1', clientId:'1' },
{ name: 'User 2', id: '2', clientId:'1' }
]
假设客户和用户会很多,因为条目哪种方式更好?提前谢谢你。
所以我想找到了一个适合有同样困境的人的东西,他们可以试试这个 http://openmymind.net/Multiple-Collections-Versus-Embedded-Documents/#11
如果有人想更深入地解释或指出其他资源,可以随时进行。
我是 mongodb 的新手,正在阅读一些有关关系的示例,但仍然可以理解它,也许是因为我与 sql 相处的时间太长了。所以我有 table 个客户,table 个用户,我在 MongoDB 中标明了我可以嵌入这样的东西
db.clients.findOne()
{
id : '1',
name: 'Client',
users : [
{ name: 'User 1', id: '1' },
{ name: 'User 2', id: '2' }
]
}
或 两个分开的 tables
clients : [
{ name: 'User 1', id: '1'}
]
And
users : [
{ name: 'User 1', id: '1', clientId:'1' },
{ name: 'User 2', id: '2', clientId:'1' }
]
假设客户和用户会很多,因为条目哪种方式更好?提前谢谢你。
所以我想找到了一个适合有同样困境的人的东西,他们可以试试这个 http://openmymind.net/Multiple-Collections-Versus-Embedded-Documents/#11
如果有人想更深入地解释或指出其他资源,可以随时进行。