Re: Relationships in Mongodb

147 views
Skip to first unread message

Tito George

unread,
Apr 19, 2013, 8:09:05 AM4/19/13
to mongod...@googlegroups.com
There is no JOIN is mongo. So relationships wont help. You still can do that with third party api's like in case of java spring-data-mongo. But here API would be handling the relationship not in mongoDb level.

To take full advantage of mongo, data should be as de-normalized as possible. 

On Friday, April 19, 2013 5:04:04 PM UTC+5:30, Vamsi Popuri wrote:
Hi Everyone,

I am aware that, How to do (1-1, 1-m, m-m) relationships in MYSQL..But I confused in Mongodb. Because here there is no foreign keys concept. Therefore, Please can anyone provide one small example for understanding the relationships in mongodb..thanks for advance



Vamsi Popuri

unread,
Apr 19, 2013, 8:32:24 AM4/19/13
to mongod...@googlegroups.com
I am using python ( Language), django (Framework), mongodb ( Database)....

Sam Millman

unread,
Apr 19, 2013, 9:09:11 AM4/19/13
to mongod...@googlegroups.com
I would go against that and say that data should not be as de-normalised as possible. De-normalisation can actually be a difficult thing to manage in MongoDB but rather that you should model around how your indexes and queries will work.

As for handling relationships, since MongoDB has no server-side resolution of JOINs, you will need to do them manually in your application by actually storing the data you normally would for a JOIN and doing queries in the application to pull out data.


--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Vamsi Popuri

unread,
Apr 19, 2013, 11:56:29 PM4/19/13
to mongod...@googlegroups.com
If possible, then can you provide a small example about the relationships models in mongodb...may be country, state, city.

MYSQL:

Class Country(models.Model)
   name = models.Charfield(max_length=10)

Class State(models.Model)
  Country = models.Foreignkey(Country)
  name = models.Charfield(max_length=10)

Class City(models.Model)
  State = models.Foreignkey(State)
  name = models.Charfield(max_length=10)

My questions is how to create models in mongodb ? your help is really appreciable

Reply all
Reply to author
Forward
0 new messages