Wrapping my head around MongoDB, mongomapper and joins...

Posted by cbmeeks on Stack Overflow See other posts from Stack Overflow or by cbmeeks
Published on 2010-05-23T15:42:40Z Indexed on 2010/05/23 15:51 UTC
Read the original article Hit count: 491

I'm new to MongoDB and I've used RDBMS for years.

Anyway, let's say I have the following collections:

Realtors
 many :bookmarks
 key :name


Houses
 key :address, String
 key :bathrooms, Integer


Properties
 key :address, String
 key :landtype, String


Bookmark
 key :notes

I want a Realtor to be able to bookmark a House and/or a Property. Notice that Houses and Properties are stand-alone and have no idea about Realtors or Bookmarks. I want the Bookmark to be sort of like a "join table" in MySQL.

The Houses/Properties come from a different source so they can't be modified.

I would like to be able to do this in Rails:

r = Realtor.first r.bookmarks would give me:

House1 House2 PropertyABC PropertyOO1 etc...

There will be thousands of Houses and Properties.

I realize that this is what RDBMS were made for. But there are several reasons why I am using MongoDB so I would like to make this work.

Any suggestions on how to do something like this would be appreciated.

Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about associations