Volume 1·Beginner → Intermediate·Chapter 1

SQL Fundamentals — What, Why & How

Before writing a single query, you need to know what SQL is, why it exists, and how databases work. This chapter lays the mental foundation everything else builds on.

1.1What is SQL?

Simple Definition

SQL (Structured Query Language) is a language used to communicate with relational databases. You use it to create, read, update, and delete data stored in tables.

Real-World Analogy

Analogy
Think of a database as a giant Excel workbook. SQL is the language you use to ask questions ('Show me all rows where city = Mumbai'), make changes ('Update salary to 60000'), or add data ('Add this new employee'). Instead of clicking around the spreadsheet, you write instructions.

Why SQL Matters

  • Used by every company that stores data — banks, hospitals, e-commerce, apps
  • Powers the backend of almost every web application
  • Required for Data Analyst, Data Engineer, Backend Developer roles
  • Standardized — SQL knowledge transfers across MySQL, PostgreSQL, Oracle, SQL Server

1.2DBMS vs RDBMS

Term Full Form Definition Example

DBMS

Key Point
SQL is used with RDBMS. 'Relational' means tables can be linked to each other through keys — like a Customer table linked to an Orders table.

1.3SQL vs NoSQL

Feature SQL (Relational) NoSQL (Non-Relational) Data Structure Tables (rows & columns) Documents, Key-Value, Graph, Column-Family Schema Fixed, predefined schema Flexible / Dynamic schema

Query Language

Best For SQL (standardized) Varies by database (MongoDB uses BSON queries)

Examples

MySQL, PostgreSQL, Oracle, SQLite MongoDB, Redis, Cassandra, DynamoDB

Full ACID compliance Often sacrifices ACID for speed/scale

Rule of Thumb
Use SQL for structured, relational data (banking, ERP, CRM). Use NoSQL when data is unstructured, scale is massive, or schema changes frequently (social media, IoT).

1.4SQL Sub-Languages — DDL, DML, DQL, DCL, TCL

SQL is divided into 5 sub-languages, each with a different purpose. Every SQL command you will ever write belongs to one of these categories.

Sub-Language Purpose Commands Analogy

DQL — Data Query LangQuaugeery and retrieve data SELECT Asking a question and getting an

DCL — Data Control LangCuoangtreol access & permissions GRANT, REVOKE Building security / access cards

Memory Trick: DDDDT — Define, Manipulate, Query, Control, Transaction. DDL builds the table. DML fills the table. DQL reads the table. DCL secures it. TCL confirms changes.

Practice Questions

Q1. What does SQL stand for and what is it used for? Answer: Structured Query Language. Used to create, query, update, and delete data in relational databases.

Q2. Name the 5 SQL sub-languages and one command from each. Answer: DDL (CREATE), DML (INSERT), DQL (SELECT), DCL (GRANT), TCL (COMMIT).

Q3. What is the difference between DBMS and RDBMS? Answer: RDBMS stores data in structured tables with defined relationships between them. DBMS is any software for storing data, not necessarily structured.

Q4. Can you use SQL with NoSQL databases? Answer: Standard SQL is for RDBMS. Some NoSQL databases (like Amazon Athena on S3) support SQL-like syntax but it is not native SQL.