🛢SQL and NoSQL Database

👉 What are these?
👉 Key Differences
👉 How to choose between them?

🧵 👇
1️⃣ What is a Database?

A database is an organised collection of data stored in a computer system (typically a server machine, but can be any machine) so that it can be accessed and managed easily.
✪ Initially each database had a separate way of data management. The way one database was storing and managing data may vary from another.

✪ But with time this practice got normalised. The "Relational Database" design came into picture.
2️⃣ What is a Relational Database?

✪ A relational database is a "collection of data items" that have some "pre-defined relationships" between them.

✪ Typically these items are organised as a set of "Tables" with "Columns" and "Rows".
✪ Relationship between 2 tables are established based on one or many similar columns between them.

✪ Relational database became very popular. Because of so many similar kind of database exist, it was thought to develop a common language to manage both data and structures.
3️⃣ What is SQL?

✪ SQL stands for Structured Query Language.

✪ SQL is a computer language for storing, manipulating and retrieving data stored in a relational database.
SQL has 2 parts.

→ DDL: Data Definition Language (to define the structure of data)

→ DML: Data Manipulation Language (to manipulate and, retrieve data)

✪ When we say "Structure" of data, it is also understood as "Schema" of data.
✪ Though a database is "Relational" and the language used in it is called "SQL". But it has become normal to use "Relational Database" and, "SQL Database" interchangeably.

✪ In a SQL Database, data are kept fully structured. Sometimes data are very tightly coupled.
4️⃣ NoSQL Database

✪ SQL Databases were good and served many purposes. But with time data volume increased like anything.

✪ For these big data, SQL was found to be inefficient at many occasions. To improve the efficiency, many started designing new databases.
✪ All these databases didn't keep it mandatory for data to be structured. Hence SQL was not going to work. So, a new term was coined "NoSQL".

✪ NoSQL doesn't mean "Not SQL" rather "Not Only SQL".
✪ NOSQL databases were mostly distributed. Hence they were following CAP Theorem.

✪ CAP Theorem states that no distributed system can support more than any two of Consistency, Availability and Partition tolerance.
5️⃣ NoSQL Categories

NoSQL Databases are categorised mostly in 4 categories.

→ Document Based
→ Key-Value Based
→ Column Based
→ Graph Based

I will describe each of these in separate threads.
6️⃣ SQL vs NoSQL

Now, as we have fundamentals cleared about both SQL and NoSQL databases, let's find out major differences.

Let's classify and then we will elaborate each one.

→ Architecture
→ Schema
→ Scalability
→ Data Structure
→ Properties
6️⃣.1️⃣ Architecture

✪ SQL Databases are "Relational" while NoSQL databases are "Not Relational".

✪ SQL Databases are not mandatorily distributed while NoSQL databases are architected for distributed systems.
6️⃣.2️⃣ Schema

✪ Schemas in SQL Database is mandatory and, predefined.

✪ Schemas in NoSQL Database is dynamic. It is not mandatory to define a Schema before creation of data.
6️⃣.3️⃣ Scalability

✪ SQL Databases are mostly "vertically scalable" means you need to increase the machine's CPU, RAM, Storage for scaling.

✪ NoSQL Databases are "horizontally scalable" means you just need to add new machines to scale up. NoSQL databases are hence distributed.
6️⃣.4️⃣ Data Structure

✪ SQL Databases are Table based.

✪ NoSQL databases are either Document based, Key-Value based, Column based or Graph based.
6️⃣.5️⃣ Properties

✪ SQL Databases are ACID compliant. It means consistency of data is of high priority.

✪ Where as NoSQL Databases support any 2 of CAP (Consistency, Availability and Partition Tolerance).
7️⃣ How to choose?

✪ SQL databases are better for multi-row transactions, while NoSQL is better for unstructured data like documents or JSON.

✪ If data can grow quickly and you want to scale up immediately on-demand, then NoSQL should be the preferred one.
8️⃣ Examples

✪ Relational Database: Oracle, MySQL, PostgreSQL, Microsoft SQL Server

✪ Document Based: MongoDB

✪ Key-Value Based: Redis, DynamoDB, Couchbase

✪ Column Based: Cassandra, HBase

✪ Graph Based: Neo4j, Dgraph
That's it for this 🧵

Hope you like it and find it useful. I will further describe about NoSQL databases in future threads.

Till then, 👋

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Swapna Kumar Panda ✨

Swapna Kumar Panda ✨ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @swapnakpanda

27 Oct
💡 JavaScript Interview Preparation Simplified

If you are a beginner or, a new learner and going to appear (or already appearing) for an interview, this 🧵 is for you.

I am getting many DM requests from students about preparing for JS interviews. So I thought of coming up with a series which may help who needs it.

This is going to be a series of threads and, this one is the very first in this series.
What is expected from you in an Interview?

1️⃣ Good behaviour
2️⃣ Knowledge of Syntax
3️⃣ Knowledge of Key Features and where to apply
4️⃣ Integration with other technologies in the stack
5️⃣ Usage of a framework
6️⃣ Analytical Ability

In this thread, we will cover 2️⃣ & 3️⃣
Read 16 tweets
27 Oct
JavaScript CookBook: 7️⃣ Recipes for this Week

Recipes

1️⃣ Complex String Formation
2️⃣ String Conversions
3️⃣ Default Value Assign
4️⃣ Default Function Parameters
5️⃣ Checking properties of a possibly Nullish Object
6️⃣ Fetching Values from an Object
7️⃣ Function Argument List
Recipe 1️⃣

✪ What to Cook?
Complex String Formation

✪ Ingredient
`` (String Template Literal)

✪ Cooking Process
You were cooking like this (tedious):

→ 'Hello ' + fName + ' ' + lName

Instead cook like this:

→`Hello ${fName} ${lName}'
Read 10 tweets
26 Oct
🔥 Resources to learn Data Structures and Algorithms

1️⃣ Twitter Threads

I post almost regular threads on DSA. Check out those 👇
twitter.com/i/events/14502…
2️⃣ Blogs/Articles

1️⃣ Swapna's blog is coming soon. It will include from simple to complex topics on DSA. It will also help you getting through how to approach for solving the problem. It should be your one-stop to get familiar with DSA.

Some more to look for 👇
Read 9 tweets
26 Oct
Linked List: Frequently used Operations

🔥 Interview Questions with Beginner Friendly Explanations and Pseudo Code 🔥

👇
0️⃣ Basics

✪ What is a Linked List?

• a LINEAR data structure
• its elements may not be in contiguous memory location
• each element has a reference to its next element

✪ What is an element in a Linked List popularly called?
A Node.

++
✪ What is the structure of a Node in Linked List?

A node has 2 parts.

• First one contains the value
• Second one contains the reference (or, pointer) to the next node. For the last node this is NULL as it doesn't point to any other node.

++
Read 20 tweets
25 Oct
Data Structures and Algorithms (DSA)

🔥 Frequently Asked Interview Questions 🔥

I am soon going to start my blog. All the questions featured here will be answered in detail over there. I will post answers for some of these in Twitter platform as well. Questions will be added with time. Stay tuned.

Now, let's go through the questions.

1️⃣ Basics

✪ What is an algorithm?
✪ What is time complexity?
✪ What is space complexity?
✪ What is a Data Structure?
✪ What are types of Data Structures? (Linear/Non-linear)
✪ What are different operations that can be performed on different data structures?
Read 14 tweets
23 Oct
Tree, Binary Tree and Binary Search Tree

Know the difference. 👇
0️⃣ Introduction to a Tree

✪ A Tree is a data structure where each element is called as a "Node".

✪ Unlike a Linked List, a Node in a Tree can point many (child) nodes.

✪ The first node from which traversal begins is called the Root Node.

++
✪ Each child node can be root of a separate tree. Each such trees are known as "Subtrees" of a given node.

✪ The number of parents, a node can have is called its "In-Degree" and it is always 1.

✪ The number of children, a node can have is called its "Out-Degree".
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(