This boils down to a classic question of whether to embed or not.
Here are a few links to get started before I explain some more:
Now to answer more specifically.
You must remember the server-side usage of foreign keys in SQL: JOINs. Embedding is a single round trip to get all the data you need in a single document however Joins are not, they are infact two selections based upon a range and then merged to omit duplicates (with significant overhead on some data sets).
So the use of foreign keys is not totally app dependant, it is also server and database dependant.
That being said some people misunderstand embedding in MongoDB and try and make all their data fit into one document. Unfortunately this is re-inforced by the common knowledge that you should always try to embed everything. The links and more will provide some useful guides on this.
Now that we cleared some things up the main pros of embedding over JOINs are:
- Single round trip
- Easy to update the document in a lot of cases, unless you embed many levels deep
- Can keep entity data with the entity it is related to
However embedding has a few flaws:
- The document must be paged in to get it's values, this can be problematic on larger documents
- Subdocuments are designed to be unique to that entity that do not require advanced querying so you normally would not get two separate entities that are related together, i.e. a
post
could embed comments
but a user
probably wouldn't embed posts
due to the query needs.
- Nesting more than 3 levels deep could effect your ability to use things such as the atomic lock.
So when used right MongoDBs embedding can become a huge power over SQL Joins but you must understand when to use it right.