Is MongoDB schema-less?

Technology CommunityCategory: MongoDBIs MongoDB schema-less?
VietMX Staff asked 3 years ago

No. In MongoDB schema design is still important. MongoDB’s document model does, however, employ a different schema paradigm than traditional relational databases.

In MongoDB, documents are self-describing; there is no central catalog where schemas are declared and maintained. The schema can vary across documents, and the schema can evolve quickly without requiring the modification of existing data.

MongoDB’s dynamic schema also makes it easier to represent semi-structured and polymorphic data, as documents do not all need to have exactly the same fields. For example, a collection of financial trading positions might have positions that are equity positions, and some that are bonds, and some that are cash. All may have some fields in common, but some fields (‘ticker’, “number_of_shares”) do not apply to all position types.