mongodb - Database design for queries that has tons of sql-like join -


i have collection named posts consisting of multiple article posts , collection called users has lot of user info. each post has field called author references post author in users collection.

on home page query posts collection , return list of posts client. since want display author of post need sql-like join commands posts have author names, ids,...etc.

if return list of 40 posts i'd have 40 sqllike-joins. means each time 41 queries list of posts author info. seems expensive.

i thinking store author info @ time storing post info. way need 1 query retrieve posts , author info. when user info changes (such name changes) list outdated , seems not quite easy manage lists this.

so there's better or standard approach this?

p.s: using mongodb

mongo nosql db. definition, nosql solutions meant denormalized(all required data should located @ same location)

in example, relationship between authors , posts 1 many ratio of authors compared posts small. in simple words, no. of authors compared no. of posts small.

based on this, can safely store author info in posts collection.

if need query posts collection i.e. if know queries executed on posts collection makes sense store author in posts. wont take huge space store 1 attribute make huge difference in query performance , easiness code/retrieve data.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -