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
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
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
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.