In the following sections, we will explain how we can translate relationships in RDBMS theory into MongoDB's document-collection hierarchy. We will also examine how we can model our data for text search in MongoDB.
Modeling relationships
One-to-one
Coming from the relational DB world, we identify objects by their relationships. A one-to-one relationship could be a person with an address. Modeling it in a relational database would most probably require two tables: a Person and an Address table with a foreign key person_id in the Address table, as shown in the following diagram:
The perfect analogy in MongoDB would be two collections, Person and Address, as shown in the following code:
> db.Person.findOne()
{
"_id...