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

  • Home
  • SEARCH
  • 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 6229673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:36:46+00:00 2026-05-24T09:36:46+00:00

I am using MongoDB at work these days. So far, I find it a

  • 0

I am using MongoDB at work these days. So far, I find it a great experience.

However I am asked to make relations between collections with MongoDB. This goes against the purpose of the NoSQL concept to me but being a good old noob in this area, I came to ask for other opinions.

For example if we take the common Role / User relationship, is it possible to have a reference collection named “Roles” and to attribute a reference of one item to a User item?

I started thinking about creating an object which provides an ID to the object requested but it feels like something I should not have to do with NoSQL.

So are there people here who have been ask to do the same thing? Did you succeed and how?

  • 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-24T09:36:47+00:00Added an answer on May 24, 2026 at 9:36 am

    MongoDB (and most other NoSQL databases) do not natively support the concept of relations. RDBMSs have native query tools to define and make use of relationships (JOINs, for example) that MongoDB lacks.

    This doesn’t mean you cannot define relationships/references in NoSQL databases. It simply means there are no native query operators that are relation aware.

    There are three different ways to “refer” to one document from another in MongoDB :

    1. Store the referred document’s ID (usually an ObjectId) as a field in the referring document. This is the best approach if your app will know in which collection it has to look for the referred document. Example : {_id: ObjectId(...); userId: ObjectId(...) <- reference).

    2. The second approach is using the DBRef convention which defines a reference to a document in a formalized way : { $ref : <collname>, $id : <idvalue>[, $db : <dbname>] }. In almost all cases the first approach is preferred but DBRef does allow references to document the application may not know the type or location of. Furhter information here : http://www.mongodb.org/display/DOCS/Database+References#DatabaseReferences-DBRef and a good read on when to use them here : http://valyagolev.net/article/mongo_dbref/

    3. Not technically a reference but in a lot of cases it makes sense to embed (parts of) documents into other documents. Note that normalization of your schema should be less of a focus with NoSQL databases. Example : {_id: ObjectId(...); user: {_id: ObjectId(...), name:"Willy Wonka"}}.

    All that said, you can use a completely normalized schema in MongoDB and most ORM libraries will do a lot of the work for you that is not native to MongoDB. In most case this does mean you’d be better off with a traditional RDBMS though. If you’re switching to MongoDB because you think it’s a fast version of MySQL you have been misinformed. Both have functional sweetspots with only limited overlap. If your app relies heavily on relational functionality don’t use NoSQL.

    Other articles worth reading to get you up to speed on non-relational thinking :
    http://www.mongodb.org/display/DOCS/Schema+Design

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

Sidebar

Related Questions

would grails work with mongodb or cassandra? or would you simply be using their
I am using MongoDB in our project and I'm currently learning how things work.
I'm using Mongoid to work with MongoDB in Rails. What I'm looking for is
Using MongoDB C# driver ( http://github.com/samus/mongodb-csharp ), seems that I'm unable to get the
I'm currently using MongoDB to record application logs, and while I'm quite happy with
I am using MongoDB v1.4 and the mongodb-csharp driver and I try to group
I'm building a Rails application using MongoDB as the back-end and MongoMapper as the
I'm considering using MongoDb for a backing store for a WPF app that I'm
I'm using MongoDB geospatial queries -- $near , geoNear , etc. -- and I'd
I have very interested in using MongoDB it seems awesome. But I'm from a

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.