Is it not recommended to use multi-table queries for mongodb non-relational databases?

question: is it not recommended to use multi-table queries for mongodb non-relational databases?


there is no absolute. The difficulty of Mongo is that there is no normal form constraint, the design of data model needs to be flexible and changeable according to the requirements, and beginners are easy to make mistakes on it. For example, if it is also the relationship between the author and the book, we can design different data models:

{
    isbn: '...',
    title: '...',
    author: {
        name: '',
        birthday: '1988-10-10'
    }
}

if the author's information changes frequently, I may choose the first design; otherwise, I may choose the second. Obviously, the second kind is efficient when querying, and inefficient when it comes to the modification of the author's information. So is the efficiency of reading more important to you or the efficiency of revision more important to you? This will determine which design you use. In the end, whether it is to look up the single table or the multi-table will be changed accordingly.

Menu