Saturday, July 19, 2025

Complete SQL Tutorial / PostgreSQL Notes

🎀Introduction To SQL

1️⃣. What is SQL

2️⃣. Basic SQL Commands ?

3️⃣. SQL v/s NoSQL

4️⃣. Types of SQL Commands

5️⃣. What is Database

1️⃣. What is SQL

SQL (Structured Query Language) is a standardized programming language used to manage and manipulate relational databases.
It allows you to interact with a database.


What You Can Do with SQL ?

💎Create databases and tables
💎Insert data into tables
💎Read/retrieve data (using SELECT)
💎Update existing data
💎Delete records
💎Control access to data (permissions)
💎Set constraints to maintain data accuracy

2️⃣. Basic SQL Commands

🗃 Command | 📇 Purpose
💎SELECT : Retrieve data
💎INSERT : Add new data
💎UPDATE : Modify data
💎DELETE : Remove data
💎CREATE : Create table or database
💎DROP : Delete table or database

3️⃣. SQL v/s NoSQL

⚔️ SQL vs NoSQL

Feature | 🗃️ SQL (Relational) | 📦 NoSQL (Non-relational)

(1.) Data Structure | Tables (rows and columns) | Varies: Documents, Key-Value, Graph, Column
(2.) Schema (Structure) | Fixed schema (predefined) | Flexible schema (dynamic fields)
(3.) Scalability | Vertical (scale up – bigger server) | Horizontal (scale out – more servers)
(4.) Query Language | SQL (Structured Query Language) | Various (e.g., JSON queries, key lookups)
(5.) performance | Low performance with huge volumes of data | Easily work with huge volumes of data
Examples | MySQL, PostgreSQL, Oracle, SQL Server | MongoDB, Cassandra, Firebase, Redis.

🧠 When to Use SQL ?

✅ Choose SQL when:
⚉ Your data is structured (like Excel tables).
⚉ You need complex queries (e.g., joins, filters).
⚉ You require strong consistency and data integrity.
☞ Example: Banking systems, HR systems, ERPs.

🚀 When to Use NoSQL ?

✅ Choose NoSQL when:

⚉ Your data is unstructured or semi-structured (JSON, logs, media)
⚉ You need to scale quickly and handle big data or traffic.
⚉ You want flexibility — schema changes frequently.
☞ Example: Social media apps, real-time analytics, IoT, chat apps.

🔧 Real-World Analogy

SQL = Rigid office form: same structure every time.

NoSQL = Free-form diary: different fields on each page.

4️⃣. Types of SQL Commands

✅ They are main types of SQL commands

🎴 1. DDL (Data Definition Language)

Used to define and change the structure of tables and databases (Create, Alter, Drop & Truncate)

🎴 2. DML (Data Manipulation Language)

Used to manage data inside the tables (Insert, Update and Delete)

🎴 3. DCL (Data Control Language)

Used to control access to data or permissions to users (Grant and Revoke)

🎴 4. DQL (Data Query Language)

Used to fetch data from a database ( SELECT )

5️⃣. What is Database

database is an organized collection of data that is stored and accessed electronically.
It allows you to store, manage, retrieve, and manipulate data easily and efficiently.
OR
database is like a smart digital notebook where data is stored in an organized way and can be easily managed using SQL or other tools.

✅ Key Features of a Database :

📁 Organized: Data is stored in structured formats (like tables)
🔎 Searchable: You can quickly retrieve information.
🛡️ Secure: Access can be restricted to certain users.
♻️ Modifiable: You can update, delete, or insert data.
🔗 Relational: Data in one table can be linked to data in another (in relational databases).

✅ Popular SQL Database Systems

Database Name | Description
MySQL : Open-source, widely used
PostgreSQL : Advanced features, open-source
SQLite : Lightweight, file-based
Oracle : Enterprise-grade
SQL Server : Developed by Microsoft

No comments:

Retail Analytics Dashboard on Zepto Dataset using PostgreSQL, Excel, and Power BI

📁 Retail Analytics Dashboard on Zepto Dataset using PostgreSQL, Excel, and Power BI 📝 Project Description: 🃏The project focuses on analyz...