Single Collection Design in Mongodb similar to single table design in dynamodb

Is single collection design in mongodb same way as single table design in dynamodb a recommended schema design for mongod? Like I want to store different type of entities in the same collection with generic primary key and indexed attributes. For example for a document of user entity, the _id will be USR#{uuid()}, for a document of type product entity the _id will be PROD#{uuid()}. Similar all types of entities will be stored in the same collection with additional indexes. I couldn’t find anything on the internet regarding this, would love a mongodb expert’s insight and recommendation regarding this.

mongodb doesn’t enforce schema by default. so you can store anything inside a document, be it same/similar/not-at-all entity or not.

is that a good design? that’s a question for you, not for mongodb.

1 Like