mongodb - Post's publication: Save ids and retrieve info querying the database, or directly saving that infos together with the id? -


i creating network allows users insert new posts. post's content need save place b in post written. wondering, should save id c of place b, , querying database looking place b id c , retrieve data d (for example name, coordinates, etc.) there each time have return post a, or better store data d in post a, , not id c, when post uploaded, don't have query database each time need return post?

assuming can place id, query totally scalable, , want best balance between memory usage , cpu usage.

note data d i'd retrieve using place's id not few, names of place in several languages. why not sure of storing data each post, if not answer obvious.

thank

it depends on queries , change frequency of d. example, if none of data d ever displayed in list view, denormalization doesn't make sense in first place. if data d modified often, keeping data in sync tedious , expensive, again, indicate de-normalization not best option here.

if want show list of posts , details location, join/subquery becomes bit more complex, involving $in. still, queries relatively simple , fast because you're hitting _id index. in case, i'd go normalized version posts contain id of place.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -