1.

What are the different storage engine options available for MongoDB?

Answer»

When "FAST reads" are the single most important criteria, EMBEDDED documents can be the best way to model one-to-one and one-to-many relationships.

Consider the example of certifications awarded to an employee, in the below example the certification data is embedded in the employee document which is a denormalized way of storing data

{    _id: "10",    name: "Sarah Jones",    certifications: [                 { certification: "Certified Project Management Professional”,     certifying_auth: “PMI”,     DATE: "06/06/2015"                 },                 {  certification: "Oracle Certified Professional”,      certifying_auth: “Oracle Corporation”,      date: "10/10/2017"                 }               ]  }

In a normalized form, there would be a reference to the employee document from the certificate document, example

{                  employee_id: "10",          certification: "Certified Project Management PROFESIONAL”,          certifying_auth: “PMI”,          date: "06/06/2015" }

Embedded documents are best used when the entire relationship data needs to be frequently retrieved together. Data can be retrieved via single query and hence is much faster.

Note: Embedded documents should not grow unbounded, otherwise it can slow down both read and write operations. Other factors like consistency and frequency of data change should be considered before making the final design decision for the application.



Discussion

No Comment Found