node - mongodb database design mongoose schema
扔个三星炸死你
扔个三星炸死你 2017-06-16 09:19:06
0
3
1051

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?

扔个三星炸死你
扔个三星炸死你

reply all(3)
phpcn_u1582

You can put orders in the same collection and distinguish them by product type.
There is no need to put them in different collections according to different types. Mongodb is also generated for this kind of non-strict field alignment data.

迷茫

I think it must be put under one set, after all, there are only a few different parts

女神的闺蜜爱上我

It is recommended to consider taking advantage of MongoDB's dynamic schema, which means that each document does not need to follow the same schema.

The official document has detailed instructions on data modeling for your similar needs, please refer to the document link below:

https://docs.mongodb.com/ecos...

For reference.

Love MongoDB! Have fun!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template