SQL vs NoSQL
SQL vs NoSQL
Title: Comparative Study of SQL and NoSQL Databases
1. Aim
To study and compare SQL (Relational) and NoSQL (Non-relational) databases based on structure, data models, query languages, scalability, consistency, and use-cases.
2. Objectives
By the end of the experiment, the student will be able to:
-
Understand the fundamental differences between SQL and NoSQL databases.
-
Identify different types of NoSQL databases.
-
Write basic queries in SQL and NoSQL.
-
Analyze the ACID and BASE properties.
-
Understand appropriate use-cases for both database models.
3. Theory
⭐ 3.1 What is SQL?
SQL (Structured Query Language) is used to manage relational databases that store data in tables.
It uses a fixed schema and supports relationships using keys.
Examples of SQL Databases:
-
MySQL
-
PostgreSQL
-
Oracle
-
Microsoft SQL Server
ACID properties ensure high reliability.
⭐ 3.2 What is NoSQL?
NoSQL stands for Not Only SQL. It is used for storing unstructured, semi-structured, or distributed data.
NoSQL databases are schema-less and scale horizontally.
Examples of NoSQL Databases:
-
MongoDB (Document)
-
Redis (Key-Value)
-
Cassandra (Column Store)
-
Neo4j (Graph)
Uses BASE properties and supports massive real-time data.
⭐ 3.3 Types of NoSQL Databases
| Type | Description | Example |
|---|---|---|
| Document Store | JSON-like documents | MongoDB |
| Key-Value Store | Key → value pairs | Redis |
| Column-Family Store | Columns inside families | Cassandra |
| Graph Database | Nodes and relationships | Neo4j |
⭐ 3.4 ACID vs BASE
| ACID (SQL) | BASE (NoSQL) |
|---|---|
| Atomicity | Basically Available |
| Consistency | Soft State |
| Isolation | Eventual Consistency |
| Durability | — |
4. SQL vs NoSQL – Comparison Table
| Feature | SQL | NoSQL |
|---|---|---|
| Data Model | Tables | Documents, Key-values, Graphs |
| Schema | Fixed | Flexible |
| Query Language | SQL | No standard |
| Scalability | Vertical | Horizontal |
| Consistency | Strong | Eventual |
| Best for | Complex transactions | Big Data, real-time apps |
5. Procedure
Step 1: Install MySQL (SQL Database)
Start MySQL server and open MySQL Shell.
Step 2: Install MongoDB (NoSQL Database)
Start MongoDB service and open mongo shell.
Step 3: Perform SQL Operations
Create a table, insert data, and run a query.
Step 4: Perform NoSQL Operations
Insert a document, retrieve it, and observe the structure.
Step 5: Record differences based on output.
6. SQL Commands (MySQL)
✔ Create a table
✔ Insert values
✔ Select data
7. NoSQL Commands (MongoDB)
✔ Insert document
✔ Retrieve document
8. Expected Output
SQL Output
NoSQL Output
9. Applications
✔ SQL Applications
Banking
ERP systems
College administration
Inventory systems
Banking
ERP systems
College administration
Inventory systems
✔ NoSQL Applications
Social media platforms
Big Data analytics
IoT applications
Real-time systems (chat apps, gaming)
Social media platforms
Big Data analytics
IoT applications
Real-time systems (chat apps, gaming)
10. Result
The differences between SQL and NoSQL databases were studied.
SQL was observed to follow a structured relational model, whereas NoSQL stores data in a flexible and scalable format. Both are useful for different application needs.
Comments
Post a Comment