Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6768305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:03:34+00:00 2026-05-26T15:03:34+00:00

I have two collections: Users Uploads Each upload has a User associated with it

  • 0

I have two collections:

  1. Users
  2. Uploads

Each upload has a User associated with it and I need to know their details when an Upload is viewed. Is it best practice to duplicate this data inside the the Uploads record, or use populate() to pull in these details from the Users collection referenced by _id?

OPTION 1

var UploadSchema = new Schema({
    _id: { type: Schema.ObjectId },
    _user: { type: Schema.ObjectId, ref: 'users'},
    title: { type: String },
});

OPTION 2

var UploadSchema = new Schema({
    _id: { type: Schema.ObjectId },
    user: { 
           name: { type: String },
           email: { type: String },
           avatar: { type: String },
           //...etc
          },
    title: { type: String },
});

With ‘Option 2’ if any of the data in the Users collection changes I will have to update this across all associated Upload records. With ‘Option 1’ on the other hand I can just chill out and let populate() ensure the latest User data is always shown.

Is the overhead of using populate() significant? What is the best practice in this common scenario?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:03:34+00:00Added an answer on May 26, 2026 at 3:03 pm

    If You need to query on your Users, keep users alone. If You need to query on your uploads, keep uploads alone.

    Another question you should ask yourself is: Every time i need this data, do I need the embedded objects (and vice-versa)? How many time this data will be updated? How many times this data will be read?

    Think about a friendship request:
    Each time you need the request you need the user which made the request, then embed the request inside the user document.

    You will be able to create an index on the embedded object too, and your search will be mono query / fast / consistent.


    Just a link to my previous reply on a similar question:
    Mongo DB relations between objects

    I think this post will be right for you http://www.mongodb.org/display/DOCS/Schema+Design

    Use Cases

    Customer / Order / Order Line-Item

    Orders should be a collection. customers a collection. line-items should be an array of line-items embedded in the order object.

    Blogging system.

    Posts should be a collection. post author might be a separate collection, or simply a field within posts if only an email address. comments should be embedded objects within a post for performance.

    Schema Design Basics

    Kyle Banker, 10gen

    http://www.10gen.com/presentation/mongosf2011/schemabasics

    Indexing & Query Optimization
    Alvin Richards, Senior Director of Enterprise Engineering

    http://www.10gen.com/presentation/mongosf-2011/mongodb-indexing-query-optimization

    **These 2 videos are the bests on mongoddb ever seen imho*

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two collections: List<int> ids; List<User> users; Where User has id, name, etc.
I have two collections which have property Email in both collections. I need to
I have a class which has two HashSet<String> collections as private members. Other classes
I have two tables: Users and Roles. A user may have more roles, so
I am using Rails 3.0.8 Lets say that I have two collections of users.
I have two classes: User : /** @Entity @Table(name=users) */ class User { /**
I have a many-to-many relationship between two models, Lists and Users. When a user
I have two Collection objects, I want to associate each object of these two
I have two applications written in Java that communicate with each other using XML
I have two collections of my own reference-type objects that I wrote my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.