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 7578015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:19:49+00:00 2026-05-30T17:19:49+00:00

I have a collection of Parent s that contain EmbeddedThing s, and each EmbeddedThing

  • 0

I have a collection of Parents that contain EmbeddedThings, and each EmbeddedThing contains a reference to the User that created it.

UserCollection: [
  {
    _id: ObjectId(…),
    name: '…'
  },
  …
]

ParentCollection: [
  {
    _id: ObjectId(…),
      EmbeddedThings: [
      {
        _id: 1,
        userId: ObjectId(…)
      },
      {
        _id: 2,
        userId: ObjectId(…)
      }
    ]
  },
  …
]

I soon realized that I need to get all EmbeddedThings for a given user, which I managed to accomplish using map/reduce:

"results": [
  {
    "_id": 1,
    "value": [ `EmbeddedThing`, `EmbeddedThing`, … ]
  },
  {
    "_id": 2,
    "value": [ `EmbeddedThing`, `EmbeddedThing`, … ]
  },
  …
]

Is this where I should really just normalize EmbeddedThing into its own collection, or should I still keep map/reduce to accomplish this? Some other design perhaps?

If it helps, this is for users to see their list of EmbeddedThings across all Parents, as opposed to for some reporting/aggregation task (which made me realize I might me doing this wrong).

Thanks!

  • 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-30T17:19:51+00:00Added an answer on May 30, 2026 at 5:19 pm

    “To embed or not to embed: that is the question” 🙂

    My rules are:

    • embed if an embedded object has sense only in the context of parent objects. For example, OrderItem without an Order doesn’t make sense.
    • embed if dictated by performance requirements. It’s very cheap to read full document tree (as opposed to having to make several queries and joining them programmatically).

    You should look at your access patterns. If you load ParentThing several thousand times per second, and load User once a week, then map-reduce is probably a good choice. User query will be slow, but it might be ok for your application.

    Yet another approach is to denormalize even more. That is, when you add an embedded thing, add it to both parent thing and user.

    • Pros: queries are fast.
    • Cons: Complicated code. Double amount of writes. Potential loss of sync (you update/delete in one place, but forget to do in another).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection of parent div s that are labeled with unique order
I have a classic parent-collection of children relationship that is being used in a
I have a collection of different objects that derive from the same parent. How
I have a parent object (part of a DAL) that contains, amongst other things,
I have a domain model that contains a collection and I want to use
I have a collection of divs that contain either images or checkboxes. My end
I have a page that contains a parent record and several children records. There
I have a collection of classes that inherit from an abstract class I created.
I have a collection of checkboxes that are created on the fly based on
I have Collection List<Car> . How to compare each item from this collection with

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.