"Say goodbye to confusion โ€” start writing SQL queries with total clarity."

Reshma SakthiReshma Sakthi
6 min read

Table to Contents - Day 1

  1. Introduction to SQL

  2. Understanding Databases

  3. Getting Started with SQL

  4. Basic SQL Commands

1.Introduction to SQL

SQL = Structured Query Language
So, what is SQL?

Wellโ€ฆ imagine you walk into a library ๐Ÿ“š where millions of books are stored (like data), and instead of searching by hand, you simply ask a robot:

โ€œHey, give me all the books written by J.K. Rowling between 1997 and 2007.โ€

Boom! The robot fetches your answer in a second.

Thatโ€™s SQL.
Itโ€™s the language you use to talk to databases โ€” to ask questions, pull out info, update records, or even delete stuff (carefully! ๐Ÿ˜…).

Why is SQL Important?

Think of raw data like a bag of coffee beans โ˜•โ€” full of potential but not very useful on its own.
SQL is your espresso machine ๐Ÿ–ฅ๏ธ โ€” helping you brew strong, rich insights to keep your decision-making sharp and energized.

SQL: Because plain data is too bitter without the right filter ๐Ÿ˜‰

Where Does SQL Fit in the Data World?

SQL is at the very core of data work.
Before you make charts in Power BI, build models in Python, or predict the future with AIโ€ฆ
You need to get the data. Clean the data. Understand the data.

And guess what? Youโ€™ll likely be using SQL to do all that. ๐ŸŽฏ

2.Understanding Databases

Where Your Data Actually Lives - Dude Okay, so imagine your brain trying to remember everyoneโ€™s birthday, their favorite food, and what they bought last week...
Now imagine doing that for millions of people. ๐Ÿ˜ต
Youโ€™d explode.

Thatโ€™s where databases come in โ€” theyโ€™re like super-organized digital brains that never forget. ๐Ÿง ๐Ÿ’พ

๐Ÿ’ก Whatโ€™s a Database?

A database is just a fancy place where data is stored in a neat and structured way.

Like a spreadsheet โ€” but smarter, faster, and doesnโ€™t crash when your cousin pastes 10,000 rows of pizza orders. ๐Ÿ•

๐Ÿงณ Why Do We Need It?

  • To store lots of information (names, orders, passwords, cat pics ๐Ÿฑ)

  • To find stuff fast (like โ€œshow me all users from Bangaloreโ€)

  • To update things easily (change your name from "Rshma" to "Reshma" ๐Ÿ˜…)

  • To keep it all safe and sound (so hackers canโ€™t just yoink it)


๐Ÿ“ฆ Real-Life Example

Imagine you're booking a flight on an app like MakeMyTrip or Indigo. โœˆ๏ธ

You enter your name, choose your destination, select a seat, and pay online. ๐Ÿ’ณ
Where does all that info go?
Yup โ€” into a database!

Behind the scenes, the airline has tables like:

  • passengers

  • flights

  • bookings

  • payments

  • seat_map

Each table is like a section in a super-organized filing cabinet ๐Ÿ—‚๏ธ โ€”
and SQL is the friendly assistant who knows exactly where your aisle seat is! ๐Ÿ˜„

Think of it as a giant digital brain that remembers everything โ€”
so you donโ€™t end up on a middle seat in row 42. ๐Ÿ™ƒ

๐Ÿค” So... Where Does SQL Fit?

SQL is the language you use to talk to these databases.

Itโ€™s how you say things like:

โ€œHey database, give me all the customers who love pineapple pizza.โ€ ๐Ÿ๐Ÿ•

And the database replies with a list โ€” fast, friendly, and accurate.

3.Getting started with SQL

๐Ÿ’พ Where and How to Write SQL

Think of SQL as chatting with your database. You type in a question ("query") and it gives you answers (data)!

You donโ€™t write SQL in Word or Notepad ๐Ÿ˜… โ€” you need a special tool, called a SQL editor, to connect to your database and write queries.

Popular Tools: MySQL Workbench, PostgreSQL, SQLite, DB Fiddle., etc

4.Basic SQL commands

Generated image

  1. Database software (DBMS/RDBMS): This is the main software used to manage and organize data.

    Examples: MySQL, PostgreSQL, Oracle, SQL Server

  2. Databases: A database is a container that holds schemas, tables, and data.

  3. Schemas: Itโ€™s a logical container within the database that can hold table, views, functions, etc.. and in simple terms we can say it as collection of tables. In mysql workbench both database and schema are similar only

  4. Tables: A table is where actual data stored in rows and columns

  5. Data: Storing The actual values stored inside tables.

DBMS (MySQL, PostgreSQL)

โ””โ”€โ”€ ๐Ÿ—„๏ธ Database (e.g. airline_db)

โ””โ”€โ”€ ๐Ÿ“ Schema (e.g. public)

โ””โ”€โ”€ ๐Ÿ“Š Table (e.g. bookings)

โ””โ”€โ”€ ๐Ÿงพ Data (rows + columns)

Image of MYSQL workbench where you will see these,

Creating Schema using this query:

create schema by_query default character set utf8mb4 collate utf8mb4_general_ci;

Explanation:

by_query - Schema name

default character set utf8mb4: Default character set for the schema is utf8mb4. The utf8mb4 character set is a Unicode character set that supports a wide range of characters, including emojis and symbols, by using up to four bytes per character.

collate utf8mb4_general_ci: This sets the default collation for the schema to utf8mb4_general_ci. Collation determines how string comparison is performed. The utf8mb4_general_ci collation is case-insensitive and is a general-purpose collation for the utf8mb4 character set.

Goal: Learn the real SQL commands that help you ask questions to your data.

๐Ÿง  Think of it like:
"Now that youโ€™ve found the kitchen (your database), itโ€™s time to cook up some tasty SQL recipes!" ๐Ÿณ๐Ÿ‘จโ€๐Ÿณ

๐Ÿ•ต๏ธโ€โ™€๏ธ SELECT โ€“ Fetch the data you want

SELECT name FROM employees;

โ†’ "Hey DB, give me all employee names."

๐Ÿ“ฆ FROM โ€“ Tell SQL where to look

SELECT name FROM employees;

โ†’ "I want data from the employees table."

๐ŸŽฏ WHERE โ€“ Filter only what matters

SELECT * FROM employees WHERE department = 'Sales';

โ†’ "Only show me employees from the Sales department."

๐Ÿงน DISTINCT โ€“ Remove duplicates

SELECT DISTINCT city FROM customers;

โ†’ "Give me a list of unique cities where customers live.โณ LIMIT โ€“ Show fewer rows (great for big data sets)

๐Ÿง‘โ€๐Ÿณ ORDER BY โ€“ Sort your results

SELECT name, age FROM users ORDER BY age DESC;

โ†’ "Show users sorted by age, from oldest to youngest."

โณ LIMIT โ€“ Show fewer rows (great for big data sets)

SELECT * FROM orders LIMIT 10;

โ†’ "Just give me the first 10 orders."

"


๐Ÿ’ก Pro Tip:

You can mix & match these commands like ingredients in a recipe:

SELECT name, salary 
FROM employees 
WHERE department = 'HR' 
ORDER BY salary DESC 
LIMIT 5;

"Give me the top 5 highest-paid HR employees."

1
Subscribe to my newsletter

Read articles from Reshma Sakthi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Reshma Sakthi
Reshma Sakthi

๐Ÿž Bug Hunter Turned Data Detective ๐Ÿ” After 2+ years in software testing, I'm chasing insights instead of bugs. On a journey to become a data analyst โ€” Learning SQL, Python, Excel & dashboards (Power BI |Tableau) โ€” and blogging what I learn along the way!