From the course: MongoDB Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Flexible schema

Flexible schema

- [Instructor] The other keyword that you will often hear when people talk about MongoDB is schemaless, so what does that mean? A schema defines the structure, and contents of the data in a collection, by ensuring that documents in the collection contain the fields that are specified as required in the validator. And, that documents in the collection that contain fields specified in the validator, have to have field values that conform to the specified data types. Here is an example validator. The validator consists of JSON schema, which specifies the BSON type of the document, which is object. And then the required fields, which in this case, are name and message. After that, in the properties field value, the JSON schema specifies each fields BSON type, alongside a description. In this case, both the name and the message must be of BSON type string. MongoDB does not require you to define a schema for you to…

Contents