In your specific example the First version is a lot more appropriate and simple. You have to think in terms of how you would query your document.
It is a lot simpler to query your database like this: db.collection.find({"data.Identifier": "AB002"})
Although I'm not 100% sure why you even need the inner document. Why can't structure your document like:
{
_id: "AB002",
insertDate: ISODate("2012-10-15T21:26:17Z"),
flag: true,
Person: "John002",
Date: ISODate("2013-11-16T21:26:17Z"),
Count: 1
}
Pros of first example:
- Simple to query
- Enforces unique keys, but your data won't have two columns with the same name anyway
- I would assume mongoDB would generate better query plans because the structure is a lot more simple (haven't tested)
Pros of second example:
- Allows multiple entries with the same key/field, but I don't feel that is useful in your case
- A single index on the array can be used for all of its entries regardless of their field name