embbed vs link vs reference

27 views
Skip to first unread message

slothy

unread,
Feb 4, 2012, 10:33:54 AM2/4/12
to mongod...@googlegroups.com
Hi everybody!

I've been reading the mongodocs and reading the tutorial. For testing purposes i have made this little script with python / pymongo
Basically, 3 dbs, with 2 collections each, "orders" and "products"
The same products are inserted in the products collection, and one order is placed in each order collection, the difference is
the way products are "related" to orders, in one are linked, in other are embedded and the last are referenced.

My questions are:
1 - Are the "relations" well done.
2- Should the "embedded" order reflect the changes in item prices, reflect the change.

The code is here:
http://dpaste.com/hold/697459/

Thanks! and apologies for my English.
--
Alex.
Slothy, the Angry Wombat
http://slothy_webcurriculum.ep.io
http://qrcolors.ep.io
http://pixelz.ep.io/


Barrie

unread,
Feb 6, 2012, 9:44:48 AM2/6/12
to mongodb-user

slothy

unread,
Feb 6, 2012, 11:05:54 AM2/6/12
to mongod...@googlegroups.com
Hi Barrie,

Yes, it's my stackoverflow profile,  I've made the same question there, it's a really newbie to mongo/NoSQL question, but i'm not really sure if it's well formulated.
I think, have misunderstand the "embedded" relation concept. The code is for testing, with the pymongo driver. Now I'm playing with Flask-mongoAlchemy.

Anyway, the question is not yet clear to me, and of course, if somebody in the list thinks,post it there and ask here, is impolite/improper, is not my intention, and i'll remove the question from there, if necessary. When have a good response i'll publish there if no good answers are published.

Regards.


2012/2/6 Barrie <bar...@10gen.com>
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.




--
Alex.

Sam Millman

unread,
Feb 6, 2012, 11:34:15 AM2/6/12
to mongod...@googlegroups.com

Sam Millman

unread,
Feb 6, 2012, 11:37:28 AM2/6/12
to mongod...@googlegroups.com
It is better to ask in one place to be honest. It is ok to have a question on SO but link it in your post so we can steal the reward :P.

Its not impolite or improper to post there it is just (as I know from having a run in with the SO community recently) many of the "good" users would not want to answer that kind of question. For various reasons SO puts its "good" users before those it is trying trying to help despite being a Q&A site.

slothy

unread,
Feb 6, 2012, 12:52:06 PM2/6/12
to mongod...@googlegroups.com
xD Ok! the reward is yours!

The answer, if somebody is interested:

"I am answering from the google groups so forgive me if the answer seems off from the one posted above.

'2- Should the "embedded" order reflect the changes in item prices, reflect the change.'

Never, imagine a user places an order and then before it is despatched suddenly realises the price has changed for no apparent reasons. You should duplicate the price upon ordering and place it in the embedded products list. This is what most (if not all) e-commerce sites do.

'The same products are inserted in the products collection, and one order is placed in each order collection, the difference is the way products are "related" to orders, in one are linked, in other are embedded and the last are referenced.'

Any of the three are valid depending on how the embbeding is done of course. If you are embbeding ordered products within orders then that is fine, embedding orders within products would not be a sound solution. Since I doubt anyone will order enough products to exceed the 16Mb limit you should be safe.

Hope this helps,"


Really, thanks.

I'll have it in mind for the next mailing-list/SO question. In fact, you seem kind, so, where have you the run in?  just curiosity.

2012/2/6 Sam Millman <sam.m...@gmail.com>

Sam Millman

unread,
Feb 6, 2012, 1:37:07 PM2/6/12
to mongod...@googlegroups.com
I asked a question which apparently was too "narrow" for anyone to be bothered to help and everyone it voted down, despite not understanding my problem. Instead of replying with a meaningful answer they just kinda blanked me. Fortunately one "good" user did actually have the heart to help.

After some discussion with senior members and owners of SO I found that their policy is basically "you can ask any question here so long as we like it otherwise we will delete it" not only that but after asking the question to the mods and admins I was trolled by the "good" users for asking why my question had been down voted.

When I said to them that their motto kinda goes against the purpose of a Q&A site they said they have to appease their elitist user group who answer the questions. Quite frankly if those elitist users are not there to help then what are they doing there at all?

I didn't ask for anyone to code for me or anything, or put time in that I should actually have hired some one; I was just asking for a second pair of eyes on something that confused me.

Fair enough helping is not always glamourse and I understand that these users dont want to waste their time on repeated questions and having to code for a person who should really hire them instead etc etc. But at the end of the day you gotta take the good with the bad. As I said I was asking for legitamite help. If you have a Q&A community which only cares for those users who never ask then the site kinda loses its point of existance (it is infact how other community sites have failed over the years). I did keep my conversation with them polite but I learned a valuable lesson about SO and other stack exchange sites.

Sam Millman

unread,
Feb 6, 2012, 1:38:07 PM2/6/12
to mongod...@googlegroups.com
10gen have considered using Stack Exchange for their Q&A instead of Google Groups, I say nay forever.

Sam Millman

unread,
Feb 6, 2012, 1:41:41 PM2/6/12
to mongod...@googlegroups.com
Plus one more thing I learned. Their only care in terms of your question is for SEO, that's pretty much what they confirmed to me is the reason why they don't like narrow questions is cos the SEO isn't worth the storage space...

Barrie

unread,
Feb 6, 2012, 2:07:56 PM2/6/12
to mongodb-user
Alex,

I provided the link to your SO question only in case your question was
answered there first (which it was, thanks Sam!). This way others who
might have similar questions and look here first have immediate access
to an answer. :-)

Barrie
> *http://slothy_webcurriculum.ep.io*http://qrcolors.ep.iohttp://pixelz.ep.io/

slothy

unread,
Feb 6, 2012, 4:43:16 PM2/6/12
to mongod...@googlegroups.com

This thread is really going off-topic, but just the last...

When I register in the mailing-list, began to receive mails about advanced mongodb topics, so I thought that the question was going to remain unanswered, so that where my motivation about publishing in SO.

Sam, now you say, this make sense, due the kind of results when searching for programming questions.

Barri, no problem, didn't see any bad attitude, just my fault, keep the good work, congrats, it's really amazing!

Thanks

2012/2/6 Sam Millman <sam.m...@gmail.com>

Reply all
Reply to author
Forward
0 new messages