How to better design one-to-many mongodb

the business structure to be designed is as follows:

var mySchema = new Schema({
  projectname:  String,
  author: String,
  body:   String,
  task: {
    taskname: String,
    user: String,
    picture: {
    url1,
    url2,
    url3,
    ...
    },
  }
});

describe the business structure in words, that is, each project contains n task, and n pictures under each task.
the daily operation is
1. New project = > New task = > upload n images.
2. Update the project task and so on.

I would like to ask whether the design of my database is reasonable. Is there a better way. Using express development.

Mar.30,2021

absolutely! Some business scenarios are particularly suitable for this nested subset design. To use data project data, you need to use task as well. This only needs to query one table, which is very efficient. And mongo supports subcollections better.

Menu