{"id":4647,"date":"2017-12-29T08:08:00","date_gmt":"2017-12-29T08:08:00","guid":{"rendered":"https:\/\/codewaveinsdev.wpengine.com\/?p=4647"},"modified":"2023-07-03T08:53:41","modified_gmt":"2023-07-03T08:53:41","slug":"when-to-use-mongodb-and-why","status":"publish","type":"post","link":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/","title":{"rendered":"When To Use MongoDB and Why?"},"content":{"rendered":"\n<h2 id=\"why-i-recommend-mongodb\" class=\"wp-block-heading\">W<strong>hy I recommend MongoDB<\/strong><\/h2>\n\n\n\n<p>Before we begin to develop an application, of any kind, any scale; we need to first thoroughly understand the requirement, to be more confident on what we are going to build. Few things we need to reflect on and evaluate at the beginning of the project \u2013 the programming language which we choose for the app, the backend architecture and framework on which the app will be built, the server on which we host and run the app, the configuration of the server and finally the choice of database and its design. The overall quality of the application, in terms of stability and reliability at varying levels of usage, is directly proportional to the above factors.<\/p>\n\n\n\n<p>In this post, I\u2019d be sharing few insights on making the right choice of database for your app; as storing, retrieving and updating data in a manner that the overall user experience on the app is seamless and smooth, is one of the most important challenges we need to address and solve as web developers. Whether it\u2019s a relational or non-relational database, it\u2019s entirely dependent on the nature of the app, data and usage.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background wp-element-button\" href=\"https:\/\/insights.codewave.com\/dynamodb-use-cases-architecture\/\" style=\"border-radius:5px;background-color:#7357eb\" target=\"_blank\" rel=\"noreferrer noopener\">DYNAMODB USE CASES &amp; ARCHITECTURE<\/a><\/div>\n<\/div>\n\n\n\n<h2 id=\"relational-versus-non-relational-db\" class=\"wp-block-heading\">Relational Versus Non-relational DB<\/h2>\n\n\n\n<p>A few years ago, when businesses were not much reliant on technology, it was enough to have a website with static data on few pages without much analytics or data mining. But today, websites and apps need visually rich \u2013 interactive pages, with a variety of fonts, videos, audios, images and deep integration with social media, to get users attention. Real-time data for decision making is becoming more important. Building websites &amp; apps for businesses that run on technology now go through rapid changes to meet market needs.<\/p>\n\n\n\n<p>In short, to develop products that are constantly evolving and dynamically changing, a traditional relational database fails to meet the need, as the relationships between entities are rigid, a small change in attributes \/ columns, require a lot of change in the&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Model-view-controller\" target=\"_blank\" rel=\"noreferrer noopener\">Model<\/a>(where the business logic resides). With a relational database, it\u2019s very difficult to add new content, new attribute or a new feature, without disrupting performance or taking the database offline. With non-relational databases (like MongoDB), you can store any type of content, incorporate any kind of data in a single database, make changes and enhancements to the application faster.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background wp-element-button\" href=\"https:\/\/insights.codewave.com\/building-scalable-powerful-apps-with-mean-stack-nodejs\/\" style=\"border-radius:5px;background-color:#7357eb\" target=\"_blank\" rel=\"noreferrer noopener\">BUILDING POWERFUL SCALABLE APPS USING MEAN STACK<\/a><\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/codewavetechnologies\/image\/upload\/q_auto:eco\/v1539916962\/MongoDB-nosql-vs-msql-relational_database-min.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<h2 id=\"my-experience-with-mongodb\" class=\"wp-block-heading\">My experience with MongoDB<\/h2>\n\n\n\n<p>For a marketplace portal called&nbsp;<a href=\"http:\/\/lawmatters.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">lawmatters.com<\/a>&nbsp;(that recently went live), I had to store, fetch and update data for about 10 million lawyers. I used mongoDB, as querying would be faster with Mongo compared to SQL, given the volume of data I had to handle. There were few reasons why I preferred Mongo to SQL:<\/p>\n\n\n\n<ul>\n<li>In future when the number of users registered on the application increases, there is no need to worry about the database, as MongoDB can scale horizontally using&nbsp;<a href=\"http:\/\/docs.mongodb.com\/manual\/sharding\" target=\"_blank\" rel=\"noreferrer noopener\">sharding<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/glossary\/#term-replica-set\" target=\"_blank\" rel=\"noreferrer noopener\">replica sets<\/a>.<\/li>\n\n\n\n<li>If we want to add more functionality to the application, there is no need to change the whole DB structure, as MongoDB is easy to maintain.<\/li>\n\n\n\n<li>One interesting thing is, MongoDB\u2019s Geospatial Indexes \u2013 which made listing based on users browsing location extremely easy.<\/li>\n<\/ul>\n\n\n\n<h2 id=\"when-mongodb-may-not-fit-best\" class=\"wp-block-heading\">When MongoDB may not fit best<\/h2>\n\n\n\n<ul>\n<li>Mongo or any other NoSQL solutions is not a good choice if you need full&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/ACID\" target=\"_blank\" rel=\"noreferrer noopener\">ACID<\/a>&nbsp;support or strong schema enforcement \u2013 in this case you can better go for a relational database such as MySQL or PostgreSQL.<\/li>\n\n\n\n<li>If you are doing deep, computation heavy analytics you can opt for something like&nbsp;<a href=\"http:\/\/hadoop.apache.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Hadoop<\/a>.<\/li>\n\n\n\n<li>If high write availability is critical and conflicts are okay, you could go for a Dynamo-style system like&nbsp;<a href=\"http:\/\/cassandra.apache.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Cassandra<\/a>&nbsp;and&nbsp;<a href=\"http:\/\/basho.com\/products\/\" target=\"_blank\" rel=\"noreferrer noopener\">Riak<\/a>.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background wp-element-button\" href=\"https:\/\/codewave.com\/contact\/\" style=\"border-radius:5px;background-color:#7357eb\" target=\"_blank\" rel=\"noreferrer noopener\">CONTACT CODEWAVE&#8217;S DATABASE SOLUTIONS ARCHITECT<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Visually rich &#8211; interactive pages &#038; modern apps often need real-time data, it is highly useful to know when to use MongoDB, type of apps where it can\/should be used.\n","protected":false},"author":1,"featured_media":4653,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"full","csco_page_load_nextpost":"","csco_post_video_location":[],"csco_post_video_url":"","csco_post_video_bg_start_time":0,"csco_post_video_bg_end_time":0,"footnotes":""},"categories":[34,31],"tags":[544,747,748,749,750,751,752],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>When To Use MongoDB and Why? -<\/title>\n<meta name=\"description\" content=\"Visually rich \u2013 interactive pages &amp; modern apps often need real-time data, it is highly useful to know when to use MongoDB, type of apps where it can\/should be used.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"When To Use MongoDB and Why? -\" \/>\n<meta property=\"og:description\" content=\"Visually rich \u2013 interactive pages &amp; modern apps often need real-time data, it is highly useful to know when to use MongoDB, type of apps where it can\/should be used.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codewave.inc\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-29T08:08:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-03T08:53:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Codewave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/codewave_inc\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Codewave\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/\",\"url\":\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/\",\"name\":\"When To Use MongoDB and Why? -\",\"isPartOf\":{\"@id\":\"https:\/\/codewave.com\/insights\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg\",\"datePublished\":\"2017-12-29T08:08:00+00:00\",\"dateModified\":\"2023-07-03T08:53:41+00:00\",\"author\":{\"@id\":\"https:\/\/codewave.com\/insights\/#\/schema\/person\/3657f01be1b168c52f7d5ba8996fd2f2\"},\"description\":\"Visually rich \u2013 interactive pages & modern apps often need real-time data, it is highly useful to know when to use MongoDB, type of apps where it can\/should be used.\",\"breadcrumb\":{\"@id\":\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#primaryimage\",\"url\":\"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg\",\"contentUrl\":\"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg\",\"width\":1600,\"height\":600,\"caption\":\"When To Use MongoDB and Why?\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codewave.com\/insights\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"When To Use MongoDB and Why?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codewave.com\/insights\/#website\",\"url\":\"https:\/\/codewave.com\/insights\/\",\"name\":\"\",\"description\":\"Innovate with tech, design, culture\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codewave.com\/insights\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/codewave.com\/insights\/#\/schema\/person\/3657f01be1b168c52f7d5ba8996fd2f2\",\"name\":\"Codewave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codewave.com\/insights\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8eaea4760f144032645a66b5f0e21153?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8eaea4760f144032645a66b5f0e21153?s=96&d=mm&r=g\",\"caption\":\"Codewave\"},\"description\":\"Codewave is a design thinking led digital transformation company enabling organisations with playful innovation using AI &amp; ML, IoT &amp; Edge, AR, VR, Cloud, Blockchain, and Data.\",\"sameAs\":[\"https:\/\/codewave.com\",\"https:\/\/www.facebook.com\/codewave.inc\",\"https:\/\/www.instagram.com\/codewavetech\/\",\"https:\/\/in.linkedin.com\/company\/codewave-inc\",\"https:\/\/x.com\/https:\/\/twitter.com\/codewave_inc\"],\"url\":\"https:\/\/codewave.com\/insights\/author\/codewaveinsdev\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"When To Use MongoDB and Why? -","description":"Visually rich \u2013 interactive pages & modern apps often need real-time data, it is highly useful to know when to use MongoDB, type of apps where it can\/should be used.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/","og_locale":"en_US","og_type":"article","og_title":"When To Use MongoDB and Why? -","og_description":"Visually rich \u2013 interactive pages & modern apps often need real-time data, it is highly useful to know when to use MongoDB, type of apps where it can\/should be used.","og_url":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/","article_author":"https:\/\/www.facebook.com\/codewave.inc","article_published_time":"2017-12-29T08:08:00+00:00","article_modified_time":"2023-07-03T08:53:41+00:00","og_image":[{"width":1600,"height":600,"url":"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg","type":"image\/jpeg"}],"author":"Codewave","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/codewave_inc","twitter_misc":{"Written by":"Codewave","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/","url":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/","name":"When To Use MongoDB and Why? -","isPartOf":{"@id":"https:\/\/codewave.com\/insights\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#primaryimage"},"image":{"@id":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#primaryimage"},"thumbnailUrl":"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg","datePublished":"2017-12-29T08:08:00+00:00","dateModified":"2023-07-03T08:53:41+00:00","author":{"@id":"https:\/\/codewave.com\/insights\/#\/schema\/person\/3657f01be1b168c52f7d5ba8996fd2f2"},"description":"Visually rich \u2013 interactive pages & modern apps often need real-time data, it is highly useful to know when to use MongoDB, type of apps where it can\/should be used.","breadcrumb":{"@id":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#primaryimage","url":"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg","contentUrl":"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1.jpg","width":1600,"height":600,"caption":"When To Use MongoDB and Why?"},{"@type":"BreadcrumbList","@id":"https:\/\/codewave.com\/insights\/when-to-use-mongodb-and-why\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codewave.com\/insights\/"},{"@type":"ListItem","position":2,"name":"When To Use MongoDB and Why?"}]},{"@type":"WebSite","@id":"https:\/\/codewave.com\/insights\/#website","url":"https:\/\/codewave.com\/insights\/","name":"","description":"Innovate with tech, design, culture","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codewave.com\/insights\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/codewave.com\/insights\/#\/schema\/person\/3657f01be1b168c52f7d5ba8996fd2f2","name":"Codewave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codewave.com\/insights\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8eaea4760f144032645a66b5f0e21153?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8eaea4760f144032645a66b5f0e21153?s=96&d=mm&r=g","caption":"Codewave"},"description":"Codewave is a design thinking led digital transformation company enabling organisations with playful innovation using AI &amp; ML, IoT &amp; Edge, AR, VR, Cloud, Blockchain, and Data.","sameAs":["https:\/\/codewave.com","https:\/\/www.facebook.com\/codewave.inc","https:\/\/www.instagram.com\/codewavetech\/","https:\/\/in.linkedin.com\/company\/codewave-inc","https:\/\/x.com\/https:\/\/twitter.com\/codewave_inc"],"url":"https:\/\/codewave.com\/insights\/author\/codewaveinsdev\/"}]}},"featured_image_src":"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1-600x400.jpg","featured_image_src_square":"https:\/\/codewave.com\/insights\/wp-content\/uploads\/2022\/08\/mongodb-background-codewave-nosql-insights-min1-600x600.jpg","author_info":{"display_name":"Codewave","author_link":"https:\/\/codewave.com\/insights\/author\/codewaveinsdev\/"},"_links":{"self":[{"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/posts\/4647"}],"collection":[{"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/comments?post=4647"}],"version-history":[{"count":0,"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/posts\/4647\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/media\/4653"}],"wp:attachment":[{"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/media?parent=4647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/categories?post=4647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codewave.com\/insights\/wp-json\/wp\/v2\/tags?post=4647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}