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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:06:01+00:00 2026-06-16T06:06:01+00:00

Are there any particular advantages to MongoDB’s ability to embed objects within a document,

  • 0

Are there any particular advantages to MongoDB’s ability to embed objects within a document, compared to SQL’s use of foreign keys for the same logic?

It seems to me that the only advantage is ease of use (and perhaps performance?), and even that seems like it could be easily abstracted away (e.g. Django seems to handle SQL’s foreign keys pretty intuitively).

  • 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-16T06:06:02+00:00Added an answer on June 16, 2026 at 6:06 am

    This boils down to a classic question of whether to embed or not.

    Here are a few links to get started before I explain some more:

    • Where should I put activities timeline in mongodb, embedded in user or separately?
    • MongoDB schema design — Choose two collection approach or embedded document
    • MongoDB schema for storing user location history

    Now to answer more specifically.

    You must remember the server-side usage of foreign keys in SQL: JOINs. Embedding is a single round trip to get all the data you need in a single document however Joins are not, they are infact two selections based upon a range and then merged to omit duplicates (with significant overhead on some data sets).

    So the use of foreign keys is not totally app dependant, it is also server and database dependant.

    That being said some people misunderstand embedding in MongoDB and try and make all their data fit into one document. Unfortunately this is re-inforced by the common knowledge that you should always try to embed everything. The links and more will provide some useful guides on this.

    Now that we cleared some things up the main pros of embedding over JOINs are:

    • Single round trip
    • Easy to update the document in a lot of cases, unless you embed many levels deep
    • Can keep entity data with the entity it is related to

    However embedding has a few flaws:

    • The document must be paged in to get it’s values, this can be problematic on larger documents
    • Subdocuments are designed to be unique to that entity that do not require advanced querying so you normally would not get two separate entities that are related together, i.e. a post could embed comments but a user probably wouldn’t embed posts due to the query needs.
    • Nesting more than 3 levels deep could effect your ability to use things such as the atomic lock.

    So when used right MongoDBs embedding can become a huge power over SQL Joins but you must understand when to use it right.

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

Sidebar

Related Questions

Is there any particular way in which we can access the Web SQL Database
I there any particular reason about MySQL not allowing the use of date_sent_at in
Is there any particular reason to use one over the other? I personally tend
Is there any particular way to integrate Captch code validation in iPhone application? is
Is there any particular reason that all data members in a class are private
Is there any way to find particular C language function's input and output parameters
Is there any way in SSIS to identify which particular task has failed? My
Is there any way to tell GCC to not initialize a particular global array
Is there any other command for redirecting a controller to a particular view page
Is there any way to ensure that a class posts a particular NSNotification? (I

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.