Introducing Schema Validation in MongoDB


 

This article is part of Robert Sheldon’s continuing series on Mongo DB. To see all of the items in the series, click here.

Similar to other NoSQL database systems, MongoDB is known for its flexible and variable schema models, unlike relational database systems in which well-defined schemas are essential to ensuring data integrity. In MongoDB, you can add documents to a collection that contain different fields or that include the same fields but with different data types or value ranges. You can even add documents that are completely unrelated. As long as you use proper Binary JSON (BSON) formatting, just