This complete SQL article will teach you SQL from scratch , covering everything — SQL meaning, installation setup (Windows, Mac, Linux), real-world SQL examples.
Introduction
Imagine you have 10,000 photos saved on your computer.
If they are saved randomly, how will you find one specific photo?
It will take a lot of time, right?
Now think — if you keep all photos arranged year-wise, month-wise, event-wise, you can find any photo easily.
Similarly, computers also need a system to organize, store, and manage huge amounts of information.
This system is called a Database.
And the language used to talk to a database is called SQL.
What is SQL?
SQL stands for Structured Query Language.
It is used to create, store, modify, and retrieve data in a database.
In simple words:
SQL = Language to manage and talk to your database.
You can:
- Create new databases and tables
- Insert new data
- Update existing data
- Delete data
- Search and retrieve data
Why do we need SQL?
- To store data safely.
- To find any information fast.
- To manage millions of records easily.
- To protect important data with security rules.
Real-life example:
When you log into Instagram, SQL fetches your profile details from their database instantly!
History of SQL
- 1970 — E.F. Codd introduced the concept of Relational Databases.
- 1974 — SQL was developed by Donald D. Chamberlin and Raymond F. Boyce at IBM.
- Originally named SEQUEL (Structured English Query Language).
- Later changed to SQL.
- Now SQL is a standard language used by almost every organization.
How to Install SQL (MySQL Database)
We will install MySQL, one of the most popular free database systems.
Step-by-Step:
- Visit website
- Download MySQL Community Server.
- Install by clicking Next → Next → Next.
- Set a password during setup (remember it!).
- Install MySQL Workbench to write queries easily.
Now you’re ready to use SQL!
Components of SQL
SQL is divided into different parts:
Language | Meaning | Commands |
---|---|---|
DDL | Data Definition Language | CREATE, ALTER, DROP |
DML | Data Manipulation Language | INSERT, UPDATE, DELETE |
DQL | Data Query Language | SELECT |
DCL | Data Control Language | GRANT, REVOKE |
TCL | Transaction Control Language | COMMIT, ROLLBACK |
Important SQL Commands
DDL
- CREATE — To create a new database or table.
-- Create a new Database
CREATE DATABASE School;
-- Create a new Table
CREATE TABLE Students (
ID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT
);
Explanation:
CREATE DATABASE
creates a new database.CREATE TABLE
creates a table with columns ID, Name, and Age.
- ALTER — To modify existing table structure.
-- Add a new column to Students table
ALTER TABLE Students ADD Email VARCHAR(100);
Explanation:
We are adding a new column called Email
to the existing Students table.
- DROP — To delete a database or table.
-- Delete the Students table
DROP TABLE Students;
Warning:DROP
permanently deletes data.
DML Commands
- INSERT — To add new data.
-- Insert a record
INSERT INTO Students (ID, Name, Age) VALUES (1, 'John', 18);
- UPDATE — To modify existing data.
-- Update John's age
UPDATE Students SET Age = 19 WHERE ID = 1;
- DELETE — To remove data.
-- Delete John's record
DELETE FROM Students WHERE ID = 1;
DQL Command
- SELECT — To retrieve data.
-- View all students
SELECT * FROM Students;
-- View only names of students
SELECT Name FROM Students;
SQL Syntax
- SQL keywords are usually written in CAPITAL letters.
- Always use a semicolon (;) to end queries.
- Use WHERE clause carefully while updating or deleting data.
- Practice indentation for better readability.
Example:
SELECT Name
FROM Students
WHERE Age > 18;
Basic Interview Questions and Answers
Q1. What is SQL?
Answer:
SQL is a language used to manage and manipulate data in relational databases.
Q2. What is the difference between SQL and MySQL?
Answer:
- SQL is a language.
- MySQL is a database management system (software) that uses SQL to manage data.
Q3. What is a Primary Key?
Answer:
A Primary Key is a unique identifier for each record in a table.
Example:
CREATE TABLE Students (
ID INT PRIMARY KEY,
Name VARCHAR(50)
);
Here, ID
is the primary key — no two students can have the same ID.
Q4. What is a Foreign Key?
Answer:
A Foreign Key is a field that creates a relationship between two tables.
Example:
CREATE TABLE Courses (
CourseID INT PRIMARY KEY,
CourseName VARCHAR(50)
);
CREATE TABLE StudentCourses (
StudentID INT,
CourseID INT,
FOREIGN KEY (CourseID) REFERENCES Courses(CourseID)
);
Here, CourseID
in StudentCourses
is a foreign key linking it to the Courses
table.
Q5. What are Constraints in SQL?
Answer:
Constraints are rules applied to table columns to protect data.
Common constraints:
- NOT NULL — Cannot leave value empty.
- UNIQUE — All values must be different.
- PRIMARY KEY — Unique + Not Null.
- FOREIGN KEY — Connects two tables.
- CHECK — Limit values.
- DEFAULT — Set a default value.
Example:
CREATE TABLE Students (
ID INT PRIMARY KEY,
Age INT CHECK (Age >= 18)
);
Here, only students aged 18 or above are allowed.
Mini Project
Let’s build a small project:
Step 1: Create Database
CREATE DATABASE Company;
Step 2: Create Table
CREATE TABLE Employees (
EmpID INT PRIMARY KEY,
Name VARCHAR(50),
Department VARCHAR(30),
Salary INT
);
Step 3: Insert Data
INSERT INTO Employees (EmpID, Name, Department, Salary) VALUES
(1, 'Alice', 'HR', 40000),
(2, 'Bob', 'Finance', 55000),
(3, 'Charlie', 'IT', 60000);
Step 4: Select Data
-- View all Employees
SELECT * FROM Employees;
Step 5: Update Data
-- Increase salary of Bob
UPDATE Employees
SET Salary = 58000
WHERE Name = 'Bob';
Step 6: Delete Data
-- Remove Charlie from Employees
DELETE FROM Employees
WHERE Name = 'Charlie';
SQL is not difficult — it’s just like giving small English commands to the computer.
The more you practice, the more natural it becomes.
- Understand the basic commands.
- Try small projects.
- Solve practice exercises.
- Prepare interview questions properly.
Mastering SQL = Big step towards IT jobs!

2 thoughts on “SQL Full Course Part 1 | What is SQL? Basics to Intermediate | Installation Guide | Interview Preparation”