mongodb: Schema designs for social networking like app <p>As I can think, We can define Schemas like following:</p> <p><strong>First Approach:</strong></p> <pre><code> var schema = new Schema({ name: { type: String, required: true, trim: true }, acc_conns: {//accepted connection request ids,here connection status is accepted type: [Schema.Types.ObjectId ] }, pnd_conns: {//my pending connection request ids,here connection status is pending type: [Schema.Types.ObjectId ] } }, options); </code></pre> <p>or </p> <p><strong>Second Approach:</strong></p> <pre><code> var schema = new Schema({ name: { type: String, required: true, trim: true }, acc_conns: {//accepted connection request ids,here connection status is accepted type: [Schema.Types.ObjectId ] }, rec_conns: {//received connection request ids,here connection status is pending type: [Schema.Types.ObjectId ] }, sent_conns: {//sent connection request ids,here connection status is pending type: [Schema.Types.ObjectId ] } }, options); </code></pre> <p>I added comments to explain what I'm thinking about these schemas.</p> <p>For example in the first approach If I want to find my pending connections(i.e connection request sent or receieved) I have to use my pending list plus the list of user ids which as user objects contain me in their pending list. </p> <p>So if I use the first approach My query becomes large or more formally I have to use my id as the source for finding my pending connections because I have to look in other user docs for finding who sends me invitation.</p> <p>And In the second approach I'm storing these ids on the user's schema itself. So there is no need to query other documents because each user object contains required information in the sense that he contains the sent invitations , received invitations , accepted invitations. So if one user sent invitation to other he may update his sent list and also another user received list. If I further extend my requirements my queries may look like this as a resource found here:</p> <p><a href="https://gist.github.com/levicook/4132037" rel="nofollow">https://gist.github.com/levicook/4132037</a></p> <p><strong>I want to ask which schema design is better if in addition docs come after some sort of condition checking or say I also want to add pagination on the filtered result?</strong></p> <p><strong>What are the pros and cons of both approach?</strong></p> <p><strong>Do we have another solutions?</strong></p>