i m trying to convert a mysql database into mongodb,also i,m use mongodb with php,so need to convert mysql query into mongodb form. but there are no joins in mongodb. if you know easy way to connect two collections,please help to do it.
Asked
Active
Viewed 79 times
-1
-
visit this post may help you http://stackoverflow.com/questions/5681851/mongodb-combine-data-from-multiple-collections-in-to-one-how – Osama Jetawe Sep 29 '13 at 09:51
-
Read this as a starter: http://docs.mongodb.org/manual/core/data-modeling/ You can't connect two schema less collections automatically. There are many discussions on StackOverflow and the internet about various options. – WiredPrairie Sep 29 '13 at 12:08
-
Answers like this to similar questions: http://stackoverflow.com/a/18897965/95190 – WiredPrairie Sep 29 '13 at 12:13
1 Answers
0
There are two options in MongoDB, and which one you should use depends on the usecase.
You can either embed the document, or you could "reference it".
References are mostly a convention in MongoDB, and essentially are just a embedded hash (sub-document) that contains two fields: The collection name, and the _id of the document you are referencing. Then its up to your ODM, or application, to retrieve that document when you need it.
Both of these strategies are well explained in the manual at http://docs.mongodb.org/manual/core/data-modeling/

bjori
- 2,064
- 1
- 15
- 15