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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:38:50+00:00 2026-06-15T10:38:50+00:00

In relational database, 1-n n-n relationships mean 2 or more tables. But in mongoDB,

  • 0

In relational database, 1-n n-n relationships mean 2 or more tables.
But in mongoDB, since it is possible to directly store those things into one model like this:

Article{
  content: String, 
  uid: String,
  comments:[Comment]
}

I am getting confused about how to manage those relations. For example, in article-comments model, should I directly store all the comments into the article model and then read out the entire article object into JSON every time? But what if the comments grow really large? Like if there is 1,000 comments in an article object, will such strategy make the GET process very slow every time?

  • 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-15T10:38:51+00:00Added an answer on June 15, 2026 at 10:38 am

    I am by no means an expert on this, however I’ve worked through similar situations before.

    From the few demos I’ve seen yes you should store all the comments directly in line. This is going to give you the best performance (unless you’re expecting some ridiculous amount of comments). This way you have everything in your document.

    In the future if things start going great and you do notice things going slower you could do a few things. You Could look to store the latest (insert arbitrary number) of comments with a reference to where the other comments are stored, then map-reduce old comments out into a “bucket” to keep loading times quick.

    However initially I’d store it in one document.

    So would have a model that looked maybe something like this:

    Article{    
        content: String, 
        uid: String,
        comments:[
            {"comment":"hi", "user":"jack"},
            {"comment":"hi", "user":"jack"},
        ]
        "oldCommentsIdentifier":12345
    }
    

    Then only have oldCommentsIdentifier populated if you did move comments out of your comment string, however I really wouldn’t do this for less then 1000 comments and maybe even more. Would take a bit of testing here to see what the “sweet” spot would be.

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

Sidebar

Related Questions

Is it good to store the uploaded file into a relational database or put
I need a relational database schema to store vCard ver 3 data elements. Rather
I needed to store arbitrary data in a relational database of multiple data-types so
With the following simple relational database structure: An Order has one or more OrderItems,
For a read-only application, I am currently storing data in a relational database, but
I have a bunch of tables in a relational database which, obviously, are dependent
Imagine 2 tables in a relational database, e.g. Person and Billing. There is a
I am using Excel to store data kind of as a relational database for
I was experiencing a hard time creating FK relationships in my relational SQL database
I know how a relational database stores data. I know the basics of indexeddb

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.