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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:53:50+00:00 2026-05-31T09:53:50+00:00

Although it is not recommended to use MongoDB for N:M relations, you could still

  • 0

Although it is not recommended to use MongoDB for N:M relations, you could still use it that way by storing an array of IDs in the document. Therefore models could have a method which queries on the referenced ID and returns an array of objects.

Now the question: Is there a guideline whether to save the “foreign key” (oh how dare I to call it like that!) as a string or as an ObjectId object? I guess the performance will be almost equal because you don’t index on them, but maybe they don’t need equal space? What would you consider as the better way?

  • 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-31T09:53:51+00:00Added an answer on May 31, 2026 at 9:53 am

    Simple math:

    MongoDB’s ObjectId is a 12-byte binary blob.

    The same data in string representation (example: ’47cc67093475061e3d95369d’) takes 24 bytes. And it also will have to be converted to ObjectId during the query.

    The choice is obvious, isn’t it?

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

Sidebar

Related Questions

I get a random issue with VS2008 (although not that random several times a
So why exactly is it that it's always recommended to use const as often
Although obviously not all scenarios can be covered by a single design, is it
Although I'm not a .NET developer I always get excited about the work DLR
The problem is not solved although I accepted one answer. Problem: Vim updates very
There is something I am trying to accomplish although I'm not really sure where
tried to search for this, although I am not even sure what I am
I wrote a site using ASP.NET MVC, and although it is not completely SEO
Basically I'm having some problems with Z-Index. Although I'm not amazing at CSS I
Since uni, I've programming in Java for 3 years, although I am not fully

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.