Ask a Practical mongodb Data Table Design Problem

  mongodb, question

I have now built a notebook_list table, and each notebook of mine has two related data, namely book_name and count.

Which of the following ways should I store my data?

1.
 {
 "_id": "597060e4465ea15770fbebf2",
 "user": "a@a.com",
 "book_name": "This is Test Notebook 1",
 "count": 0
 }
 {
 "_id": "597060f7465ea15770fbebf3",
 "user": "a@a.com",
 "book_name": "This is Test Notebook 2",
 "count": 0
 }
 
 2.
 {
 "_id":"597060f7465ea15770fbebf3",
 "user":"a@a.com",
 "notebook":[
 {
 "book_name": "This is Test Notebook 1",
 "count": 0
 },
 {
 "book_name": "This is Test Notebook 2",
 "count": 0
 }
 ]
 }

MongoDB’s modeling is not a particularly complicated thing.

1. First of all, MongoDB data modeling usually does not design too many collection;;

2. Secondly, Data Modeling is business-oriented and is usually modeled by Denormalization.

MongoDB provides detailed reference contents for data modeling in official documents, but the placement position is not prominent. It is estimated that many people have not paid attention to it. Please refer to it and it is worth reading:

https://docs.mongodb.com/ecos …The use cases section of.

For reference.

Love MongoDB! Have fun!