let me ask question in simpler way. this:
{ "name": { "first": "joe", "last": "coconut" } } or this:
{ "first_name": "joe", "last_name": "coconut" } but in basic form. if can either have 5 nested object vs 2 nested more columns?!
-- original -- understand modelling of data in mongodb relative application use general rule model better?
{ "company": "amc", "clients": [ { "name": "10gen", "contact": "01002033", "contracts": { "id": 123, "price": 1200 } }, { "name": "sun", "contact": "677689", "contracts": { "id": 23, "price": 34000 } } ] } vs
{ "company": "amc", "10gen": { "123": 1200, "contact": "01002033" }, "sun": { "23": 34000, "contact": "677689" } } since application layer takes care of operations isn't second approach more appropriate?
to structure data better bad practice nest data? 5 nested documents?
am missing obvious fact?
just fyi:
consider big document. consider below example ( have put small no of keys documents). , consider following 2 update.
db.mytest.update({b_e : 1}, {$set : { b_e : 2}}) db.mytest.update({'b.e' : 1}, {$set : { 'b.e' : 2}}) in mongodb updating in second case, relatively easy because less no key iteration required. cpu activity relatively less in second update. issue note when document contains huge no of keys. in case, won't matter because document small.
mongo > db.mytest.find().pretty() { "_id" : objectid("5188aae4eadc531d7386f524"), "a_b" : 1, "a_c" : 1, "b_c" : 1, "b_d" : 1, "b_e" : 1 } { "_id" : objectid("5188ab14eadc531d7386f525"), "a" : { "b" : 1, "c" : 1 }, "b" : { "c" : 1, "d" : 1, "e" : 1 } }
Comments
Post a Comment