Skip to Content
Back to the blog

About MongoDB and many-to-many associations

 — #mongodb#nosql#databases

In a relational database, you might model a many-to-many relationship by creating a “join table.” MongoDB doesn’t have joins. But because arrays are first class citizens in MongoDB, you can simply store an array of ObjectId’s.

This little fragment from mongo_mappers gem documentation made my day.