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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:51:11+00:00 2026-05-24T06:51:11+00:00

I decided to give MongoDB a try and see how well we get along.

  • 0

I decided to give MongoDB a try and see how well we get along. I do have some questions though.

Premise

  • I have users(id, name, address, password, email, etc)
  • I have stamps(id, type, value, price, etc)
  • Users browse through a stamp archive and filter it in various ways(pagination, filter by price, type, name, etc), select a stamp then add it to their collection.
  • Users can add more then one stamp to their collection (1 piece of mint and one used or just 2 pieces of used)
  • Users can flag some of their stamps for sale or trade and perhapa specify a price.

So far

Here’s what I have so far:

{
 _id : objectid,
 Name: "bob",
 Email: "bob@bob.com",
 ...
 Stamps: [stampid-1, stampid-543,...,stampid-23]
}

Questions

  1. How should I add the state of the owned stamp, the quantity and condition?
  2. what would be some sample queries for the situations described earlier?
  3. As far as I know, ensureindex makes it so you reduce the number of “scanned” entries.

The accepted answer here keeps changing the index. Is that just for the purpose of explaining it or is this the way to do it? I mean it does make sense somehow but I keep thinking of it in sql terms and… it does not make ANY sense…

  • 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-24T06:51:12+00:00Added an answer on May 24, 2026 at 6:51 am

    The only change I would do is how you store the stamps that a user owns. I would store an array of objects representing the stamps and duplicating the values that are the more often accessed.

    For example something like that :

    {
        _id : objectid,
        Name: "bob",
        Email: "bob@bob.com",
        ...
        Stamps : [
            {
                _id: id,
                type: 'type',
                price: 20,
                forSale: true/false,
                quantity: 2
            },
            {
                _id: id2,
                type: 'type2',
                price: 5,
                forSale: false,
                quantity: 10
            }
        ]
    }
    

    You can see that some datas are duplicated between the stamps collection and the stamps array in the user collection. You do that with the properties that you access the more often. Because otherwise you would have to do a findOne for each stamps, and it is better to read directly the data that doing that in MongoDB. And this way you can add others properties such as quantity and forSale here.

    The goal of duplication here is to avoid to run a query for each stamp in the array.

    There is a link of a video that discusses MongoDB design and also explains what I tried to explain here.

    http://lacantine.ubicast.eu/videos/3-mongodb-deployment-strategies/

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

Sidebar

Related Questions

I decided to give a try to Magento. I have used my hosting provider´s
I have heard wonderful things about Mustache and decided to give it a try.
--UPDATE: I've decided to give AFNetworking a try. Even though RestKit has a really
I have a new Rails project and i decided to give heroku a try,
I came accross PetaPoco and decided to give it a try Did anyone come
I am new to Silverlight and have decided to give it a go. I
I'm coming from a TortoiseSVN background and decided to give TortoiseHg a try. One
I decided to try to my hand at this, and have had a somewhat
I decided to give PHP a try, and then bought lynda.com's essential training tutorial.
After experiencing some performances issues on my client side, we decided to give 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.