Lesson 1 of 60 – Introduction to SQL
2%

Introduction to SQL

SQL stands for Structured Query Language. It is a standard language used to communicate with relational databases.

SQL allows us to create databases and tables, store data, retrieve data, update existing data, delete data, and perform many other operations on structured data.

Note: SQL is a language, while MySQL is a database management system that uses SQL to work with data.
What is SQL?

SQL is a language designed for working with relational databases. It provides commands that allow applications and users to interact with structured data.

For example, we can use SQL to retrieve all students from a students table:

SELECT * FROM students;

This query asks the database to return all columns and rows from the students table.

Why Do We Need SQL?

Applications often need to store large amounts of information. For example, a school application may need to store:

  • Student names
  • Mobile numbers
  • Courses
  • Fees
  • Attendance
  • Examination marks

SQL provides a structured way to store and work with this data in a relational database.

SQL and Databases

A database is an organized collection of data. SQL provides commands for interacting with relational databases.

For example:

Database
   |
   ├── students
   ├── courses
   ├── fees
   └── attendance

Each table can contain related information.

SQL Example

Suppose we have a table named students:

id    name       course
1     Rahul      Python
2     Priya      SQL
3     Amit       Java

We can retrieve the students using:

SELECT * FROM students;

We can also retrieve only the names:

SELECT name FROM students;
What Can SQL Do?

SQL can perform many database operations.

  • Create databases
  • Create tables
  • Insert data
  • Retrieve data
  • Update data
  • Delete data
  • Filter data
  • Sort data
  • Group data
  • Join tables
  • Create views
  • Create indexes
  • Manage transactions
Basic SQL Commands

Some important SQL commands are:

CREATE
INSERT
SELECT
UPDATE
DELETE
ALTER
DROP

These commands are used for different database operations.

SELECT Command

The SELECT statement is used to retrieve data from one or more tables.

SELECT name, course
FROM students;

This query retrieves the name and course columns from the students table.

INSERT Command

The INSERT statement is used to add new records to a table.

INSERT INTO students
(name, course)
VALUES
('Rahul', 'Python');

This adds a new student record to the table.

UPDATE Command

The UPDATE statement changes existing records.

UPDATE students
SET course = 'SQL'
WHERE id = 1;

The WHERE condition identifies which record should be changed.

DELETE Command

The DELETE statement removes records from a table.

DELETE FROM students
WHERE id = 1;

The WHERE clause limits the deletion to the matching record.

SQL Keywords

SQL keywords are reserved words that have special meaning in SQL statements.

Examples include:

SELECT
FROM
WHERE
INSERT
UPDATE
DELETE
CREATE
ALTER
DROP
ORDER BY
GROUP BY
SQL Statements

An SQL statement is a complete instruction given to the database.

SELECT * FROM students;

The semicolon ; is commonly used to indicate the end of an SQL statement.

SQL Is Used with Relational Databases

SQL is primarily associated with relational database systems. Relational databases organize data into tables and can define relationships between those tables.

Examples of relational database systems include:

  • MySQL
  • PostgreSQL
  • Microsoft SQL Server
  • Oracle Database
  • SQLite
SQL vs MySQL

SQL and MySQL are not the same thing.

SQL MySQL
SQL is a database language. MySQL is a relational database management system.
SQL defines commands and syntax for working with relational data. MySQL provides a database server that executes SQL statements.
SQL can be used with many relational database systems. MySQL specifically refers to one database product.
Real-World Uses of SQL

SQL is commonly used in applications that need structured data storage and retrieval.

  • School Management Systems
  • Library Management Systems
  • Banking Applications
  • E-Commerce Websites
  • Hospital Management Systems
  • Employee Management Systems
  • Inventory Systems
  • Online Learning Platforms
  • Customer Management Systems
SQL in Web Development

SQL is frequently used as the database language in web applications. A web application can send SQL statements to a database through its backend code.

User
  ↓
Website
  ↓
Backend Application
  ↓
SQL Query
  ↓
Database
  ↓
Result

For example, a PHP or Python application can use SQL to retrieve student information from a database.

Example: Student Database

Consider a student management application. It may contain the following tables:

students
courses
fees
attendance
exams

The tables can contain related information and SQL can be used to retrieve and manage that information.

Advantages of Learning SQL
  • Useful for database programming.
  • Important for backend development.
  • Useful for data analysis.
  • Helps manage structured data.
  • Works with many relational database systems.
  • Useful for web and enterprise applications.
  • Important for database-related interviews.
SQL and Programming Languages

SQL is often used together with programming languages such as:

  • Python
  • PHP
  • Java
  • C#
  • JavaScript

For example, Python can send SQL queries to a database and process the returned results.

SQL Learning Path

In this SQL tutorial, you will gradually learn:

SQL Basics
     ↓
Database & Tables
     ↓
INSERT / SELECT / UPDATE / DELETE
     ↓
Filtering & Sorting
     ↓
Constraints
     ↓
Functions
     ↓
GROUP BY / HAVING
     ↓
JOINs
     ↓
Subqueries
     ↓
Views & Indexes
     ↓
Transactions
     ↓
Stored Procedures
     ↓
SQL Projects
Key Points
  • SQL stands for Structured Query Language.
  • SQL is used to work with relational databases.
  • SQL can create, retrieve, update and delete data.
  • SELECT retrieves data from tables.
  • INSERT adds new records.
  • UPDATE modifies existing records.
  • DELETE removes records.
  • SQL is different from MySQL.
  • MySQL is a relational database management system that uses SQL.
  • SQL is widely used in web development, backend development and data-related applications.

🧠 Quick Quiz

Question: What does SQL stand for?