请说我想使用Mongodb设计一个新的数据库,其功能如下:
{[ name:company1, password:123, type:company, . . . categories{ Mobile device, Computer devices ], [ name:ihab salem, password:123, type:user, . . . intersted_category{ Home Appliance, Mobile Devices }] . . . }在这种情况下我应该如上所述使用Embed Colection,或者我应该将它们分成多个集合"类别的集合,用户的另一个集合以及公司的另一个集合......等等#34;。
答案 0 :(得分:1)
这在很大程度上取决于您的数据以及您将如何使用它。 This thread对一般规则有一个很好的解释。在这里你可以找到official recommendations。 不久:
所以,在你的情况下,我尽可能多地放入一份文件,特别是如果你的embedded documents are small ones - 直到那里它可能会破坏"自然"您的系统或嵌入式文档的数据模型往往会快速增长。