Categories
Programming Tips & Insights SQL / MySQL Tips and Tutorials

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.

By Yang Yang

Hello, I'm Yang. I build online businesses that please people. Want to join in and post some useful articles on Kavoir.com? Shoot me a message.

Leave a Reply

Your email address will not be published. Required fields are marked *