Hello all… I am new to mongoDB and I have a couple questions. I plan on asking them one at at time so here goes for my first question.
I am currently coding an application in Python… That being said, the switch for me from .net to Python isn’t without its pains. This brings be to my first question.
In taking the Developer Courses I have come to one big question… Embed Objects verses using Lookup.
I currently am running one database titled KLD9_Bazaar with 7 collections. They are
Cart
Country
Invoice
Product
Session
Store
User
The User collection is where my question begins. I currently am trying to embed objects within the user object. Below is my current schema for the user collection.
Specifically Address and Card (Credit Card) are embedded objects.
First… Is this the best way to do this, or should I use a lookup query to embed the other objects within the user display when returned?
Example: John Doe logs in to purchase some items… When he logs in, the lookup is used for both the card (or cards) he uses and his identified addresses (billing and shipping)?
It seems that I am trying to over complicate this and I wanted to get some recommendations. I will use the recommendations to further develop the application… The store collection will have product in it… Populate the products in the store by using the lookup for the product collection to add the products when the store is loaded.
for example:
ABC and XYZ sell shirts. Then the customer looks at ABC store, the products that ABC sells will be loaded by using the lookup query.
Is it better to use lookup or embed… and if embedding is better, should it be embedded as an object?
Thanks for taking the time to read this and give me some pointers… Once this is answered… I will move on to my next question… Indexing… LOL.
Respectfully,
Dave Thompson
Co-Founder
Global Kloud Solutions