Implement Association in MongoDB -


i need implement association between objects in mongodb allow retrieval queries level. suppose have model account->application->device->users. suppose want query on user collection using account reference, or level of hierarchy want query on users.

as have no support joins cannot keep separate association collection, if keep association collection have series of queries, , output association collection can huge array of objects , left 2 options use

  1. iterative query each object array

  2. use $in operator

both disastrous use if array big.

i have figured out approach keep tree of ancestors follow document.

{     _id: objectid(""),     name:"",     timestamp:isodate(" "),     ...     ancestors :[{_id:objectid(""),..},{_id:objectid(""),..},{_id:objectid(""),..}] } 

suppose users document ancestors deviceid,applicationid,accountid. not sure how useful be. 1 thing sure above model if new level in added updating going pain.

the main thing why want implement model implement loosely coupled model.

thanks advance!!!


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -