When to use NoSQL (e.g. MongoDB) and when to use SQL (e.g. MySQL)?

NoSQL is mostly about document databases while SQL is about relational databases.

  1. NoSQL vs. SQL
  2. Documents vs. Tables
  3. MongoDB vs. MySQL
  4. Property vs. Entity

The trick is 4: Property vs. Entity

Design your data models on a piece of paper.

Use MongoDB if …

If you see more trivial *entities* such as category, tag, brand, origin, etc. that are actually properties, go with NoSQL databases such as MongoDB because these are properties of documents. What you are trying to store is some kind of documents of these properties.

Use MySQL if …

If you see more real entities such as business, person, product, event, etc., go with a relational database such as MySQL because these are entities that should get tables on their own. What you are trying to store is a network of related entities.

Conclusion

Go with the solution that mandates the LEAST tables or document types so the structure is as simple as possible.

If you find the data structure becoming increasingly complex and difficult to maintain, you are probably using the wrong database technology.

Scroll to Top