Can we store the id of the customer in the order collection? because if the number of orders exceeds then we will have to store a large number of orders in the customer collection unnecessarily
This is a many to many relationship, not one to many... The same order can be in multiple customers. To be one to many the order should have a reference to the customer...
How can multiple customers have the same order? Multiple customers can order the same product but no two customers will have the same order. Not possible.
Mongodb is misunderstood its not a relational database like sql but you can make relationships its also called no sql but you can use structured query languages on it.
I understood that MongoDB offers the possibility to have unstructured, nested data, as opposed to SQL and tables where your data is structured in a "rigid" way and you have to perform JOIN etc. But procademy's series of "Relations in MongoDB", course from #16 onwards, shows how you can design these relationships (embedding vs referencing), given the non-structure of the data, and which strategy is best given your use case/app performance needs.
Using customer reference in order collection is more correct way to deal with this scenario
In case if you cannot see the bottom of your screen, zoom out your screen by pressing [Ctrl/Cmd and minus(-)]
NIce explaination
MongoDB: One to Many Relationns using References, well explained. Thank you.
{2023-08-23}
Use "Enter" Bro, add spaces, i can't see if you typing in bottom of screen.
hello brother when write code kindly clear the screen and write top of the window, you are writing extreme footer side of the window
So, How do you get the order details, another lookup ?
Can we store the id of the customer in the order collection?
because if the number of orders exceeds then we will have to store a large number of orders in the customer collection unnecessarily
Yes you can
how do you find the product details along with the order details, please try to reply my comment
This is a many to many relationship, not one to many... The same order can be in multiple customers. To be one to many the order should have a reference to the customer...
How can multiple customers have the same order? Multiple customers can order the same product but no two customers will have the same order. Not possible.
how is mongo-db is non-relational database and we also use relations between collections like one to many and many to many ?
Mongodb is misunderstood its not a relational database like sql but you can make relationships its also called no sql but you can use structured query languages on it.
@@kip5.56 is there an alternative how to solve such problems? i think relations are a good option
I understood that MongoDB offers the possibility to have unstructured, nested data, as opposed to SQL and tables where your data is structured in a "rigid" way and you have to perform JOIN etc. But procademy's series of "Relations in MongoDB", course from #16 onwards, shows how you can design these relationships (embedding vs referencing), given the non-structure of the data, and which strategy is best given your use case/app performance needs.
Last screen not visible properly. Waste video.