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
- How should I add the state of the owned stamp, the quantity and condition?
- what would be some sample queries for the situations described earlier?
- 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...