Choosing the right database schema for your application impacts performance and your ability to quickly adapt to evolving business requirements. A flexible data model, such as the one found in MongoDB, lets you store or aggregate any type of data and dynamically change schema without application downtime.
Data in MongoDB is stored in documents and similarly structured documents are typically organized into collections. Also, MongoDB documents tend to have all data for a given record in a single document.
Let’s use a database schema example from a blogging application to help illustrate the document model in MongoDB. For the blog, you could model the data as two collections -- one to represent visitors and the other for the articles. Each document of this blog database could contain multiple comments, multiple tags, and multiple categories, each expressed as an embedded array.
Here is an illustration of this database schema example:
To learn more about MongoDB’s flexible data model and its benefits, read our white paper.