ProDeveloperTutorial.com

Tutorials and Programming Solutions
Menu
  • Shell Scripting
  • System Design
  • Linux System Programming
  • 4g LTE
  • Coding questions
  • C
  • C++
  • DSA
  • GIT
  • 450 DSA Cracker
  • 5G NR
  • O-RAN

System Design Topic 9: Choosing between SQL and NoSQL

prodevelopertutorial February 16, 2019

This topic we shall understand in brief about what is SQL DB, No-SQL DB and when to choose SQL and when to choose No-SQL.

9.1 SQL:

SQL stands for Structured Query Language. Here the data will be stored in a structured way in the form of rows and columns.
Each record will have a Schema. These schemas will help to do operations on the data. The data can be obtained from queries like ” SELECT name FROM username”. Similarly, we have commands for inserting, deleting, updating also.
When the data are distributed across tables, we use joins to retrieve the data. This is also called as relations.

9.1.1 Different types of relations are:

One to One: One user from “user” table will be having an email id in “contact” table..

One to Many: One user from “user” table will be ordering multiple produts from “products” table.

Many to Many: One user from “user” table, from “city” table, ordering “products”.

SQL DB are vertically scalable. i.e. by increasing memory, CPU. Most of the time they are used for monolithic applications. Scaling SQL DB can be expensive.

9.1.2 Some of the advantages of SQL over NoSQL DB:

1. It is better for relational data.
2. Normalization.
3. SQL language can be used to get the result that is very easy to learn.
4. Data integrity. As there is only one copy of data, any change can be done in that table itself.
5. Follows ACID properties.

9.2 NoSQL:

A NoSQL DB can be considered as a Non Relational database (no tables). No SQL will not have any schema. Usually we use NoSQL to work with big data and real-time web applications. The data will be stored as a collection.
The data can be stored in semi or no structured way. Because of this there is a possibility of duplication of the data. They provide Eventually consistent.
NoSQL is used for MicroServices or Distributed Applications.
NoSQL DB are horizontally scaled, means more servers can be added. Hence it is less cost for scalability.

9.2.1 Some of the advantages of NoSQL over SQL DB:

1. Can be used with Big Data
2. There is no predefined schema
3. NoSQL handles unstructured data.
4. Cheaper to manage.
5. Scaling is easy, horizontal scaling.

9.2.2 Types of NoSQL DB

MongoDB
CouchDB
Apache Cassandra
Neo4J

So which one to use? SQL or NoSQL DB?

SQL:

when we know that the data or schema is not going to change, then we choose SQL DB.
We want ACID compliance.

NoSQL:

When using Big Data
When the data needed to be stored across the servers.

Sometime in big projects, we use both of the database.

 

List Of Tutorials available in this website:

C Programming 20+ ChaptersC++ Programming 80+ Chapters
100+ Solved Coding QuestionsData Structures and Algorithms 85+ Chapters
System design 20+ ChaptersShell Scripting 12 Chapters
4g LTE 60+ ChaptersMost Frequently asked Coding questions
5G NR 50+ ChaptersLinux System Programming 20+ chapters
Share
Email
Tweet
Linkedin
Reddit
Stumble
Pinterest
Prev Article
Next Article

About The Author

prodevelopertutorial

Follow this blog to learn more about C, C++, Linux, Competitive Programming concepts, Data Structures.

Leave a Reply Cancel Reply

You must be logged in to post a comment.

ProDeveloperTutorial.com

Tutorials and Programming Solutions
Copyright © 2023 ProDeveloperTutorial.com
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT