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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:34:06+00:00 2026-06-09T03:34:06+00:00

say i have two collections in mongodb,one for users which contains users basic info,and

  • 0

say i have two collections in mongodb,one for users which contains users basic info,and one for apps which contains applications.now if users are allowed to add apps,and the next time when they login, the web should get the user added app for them.how should i construct this kind of database in mongodb.

users:{_id:ObjectId(),username:'username',password:'password'}
apps:{_id:ObjectId(),appname:'',developer:,description:};

and how should i get the user added app for them??? should i add something like addedAppId like:

users:{_id:ObjectId(),username:'username',password:'password',addedApppId:[]}

to indicate which app they have added,and then get the apps using addedAppId???

  • 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-09T03:34:07+00:00Added an answer on June 9, 2026 at 3:34 am

    Yep, there’s nothing wrong with the users collection keeping track of which apps a user has added like you’ve indicated.

    This is known as linking in MongoDB. In a relational system you’d probably create a separate table, added_apps, which had a user ID, app ID and any other relevant information. But since you can’t join, keeping this information in the users collection is entirely appropriate.

    From the docs:

    A key question when designing a MongoDB schema is when to embed and when to link. Embedding is the nesting of objects and arrays inside a BSON document. Links are references between documents.

    There are no joins in MongoDB – distributed joins would be difficult on a 1,000 server cluster. Embedding is a bit like "prejoined" data. Operations within a document are easy for the server to handle; these operations can be fairly rich. Links in contrast must be processed client-side by the application; the application does this by issuing a follow-up query.

    (this is the extra bit you’d need to do, fetch app information from the user’s stored AppId.)

    Generally, for "contains" relationships between entities, embedding should be be chosen. Use linking when not using linking would result in duplication of data.

    …

    Many to many relationships are generally done by linking.

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

Sidebar

Related Questions

I am using Rails 3.0.8 Lets say that I have two collections of users.
Consider I have two collections in MongoDB. One for products with documents like: {'_id':
Say I have two Java apps that I wrote: Ping.jar and Pong.jar and they
Say we have two tables in an MS Access db: Service Users: | ID
If I have two collections of files: A and B (say, two collections of
Let's say for example i have 2 collections Comments and Users.The comments include username
Say I have two Collections : Collection< Integer > foo = new ArrayList< Integer
I have two different collections with a common field say, a UserId. There are
I have two different collections: List<int> IEnumerable<IDataRecord> The first contains a list of primary
I'm currently experimenting a bit with LINQ. Let's say I have two collections of

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.