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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:07:50+00:00 2026-06-17T04:07:50+00:00

I have an List document with embedded Comments. Along with the user’s comment in

  • 0

I have an List document with embedded Comments. Along with the user’s comment in the view, I’d like to display their screen name and profile picture. The profile picture could change and so could the screen name.

I’m trying to determine what the best practice is here for design. To best leverage Mongo, it seems like like the embedded Comment should look like the following:

Comment Model

class Comment
  include Mongoid::Document
  field :user_id
  field :username
  field :profile_pic_url
  field :content
  field :created_at, type: Date
  embedded_in :list, :inverse_of => :comments
end

The risk though is that comment data (user’s screen name and profile pic) becomes stale if the user changes them unless there’s a after_save filter on the User model for instance that looks to update all instances in comments.

Any guidance on proper design? I could make it so that comments are not embedded and make it so that a user has many comments and a list has many comments, but I’m trying to play to Mongo’s strengths.

  • 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-06-17T04:07:51+00:00Added an answer on June 17, 2026 at 4:07 am

    Your application, it’s access patterns, scaling, and performance requirements trump backend issues. With SQL, normalization and linking/referencing is pretty much your only choice, but with MongoDB, you can embed.

    MongoDB provides the flexibility to match schema to the needs of your application, you can choose normalization/linking/referencing or denormalizing/embedding as needed, and Mongoid makes it easy to choose.

    (a) Normalization reduces redundancy, following the good principle of Don’t Repeat Yourself (DRY).
    (b) Denormalization introduces redundancy, following common practices such as caching or memoizing for performance.

    In general based on the needs of your application:

    High consistency required – yes: normalize / link, no: denormalize / embed

    High read performance required – yes: denormalize / embed, no: normalize / link

    High write performance required – yes: normalize / link, no: denormalize / embed

    High scaling required – yes: normalize / link, no: denormalize / embed

    Relationships:

    one-to-one – yes: denormalize / embed, no: …

    one-to-many – yes: denormalize / embed, no: …

    many-to-many – yes: normalize / link, no: …

    There are various techniques for handling consistency, ex., background or nightly process for eventual consistency, look-aside cache for immediate consistency, etc.

    The bad news is that there’s no formula that requires no thought. The good news is that MongoDB has the flexibility to match your application. 10gen offers talks on Schema Design.

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

Sidebar

Related Questions

I have a document structure in MongoDB like this: User |---> Posts |----> Comments
I have a List model. Lists have embedded Tags (using Mongoid). When a user
I would like to have an embedded document referred to by a map (as
I have list view. In which, every list item is a document(.pdf, .xls ,
I have a list of name/value pairs that I would like to map into
I have a list view class that just like NSCollectionView requires an additional prototype
I have an ordered list in my Word document, and I want to add
I have an aspx document that returns a list of incoming flights from a
I have a text document that contains a list of numbers and I want
I have created a repeat control that list some documents. I would like to

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.