Order table design in trading scenario:
Assume there are four products. The order data of each product must have the same parts, such as: order number, order owner, order type, order status, order tracking timeline. At the same time, orders for different products also have their own special The data.
Do you define different schemas for different product designs, or do you only define the schema for one order, but specify a special
subdocument to store data unique to different products?
Should orders be stored in different collections according to different product types, or directly stored in the same order table?
可以把订单放在同一个collection里面,用产品类型区分.
没有必要按不同类型放在不同collection,mongodb也是对这种非严格字段对齐的数据而产生的.
我认为肯定是放在一个集合下,毕竟不同的部分只有一点
建议考虑利用到MongoDB的dynamic schema,意思是每一个document不必要遵循相同的schema。
官方文档有关于您类似的需求的data modeling的详细说明,请参看下面的文档链接:
https://docs.mongodb.com/ecos...
供参考。
Love MongoDB!Have fun!