Imagine you wake up tomorrow and AQAD suddenly becomes successful across the UAE.
Thousands of vendors are uploading products.
Thousands of retailers are placing orders.
Hundreds of delivery partners are moving products every hour.
Payments are happening every minute.
Notifications are being sent continuously.
Now imagine storing all of this information inside Excel files.
Very quickly, everything would become a disaster.
Files would be duplicated.
Data would be lost.
Employees would overwrite each other's work.
Finding a single order could take several minutes.
Generating reports could take hours.
This is exactly the problem databases were created to solve.
Before we understand MySQL, SQL queries, joins, indexes, optimization, or database design, we first need to understand a simple question:
What is a database?
A Simple Real-Life Story
Let's start with a story.
Imagine you own a small grocery shop.
On the first day, you have only 10 products.
You decide to keep product information in a notebook.
Your notebook contains:
Product Name
Price
Quantity
For a few days, everything works fine.
Then your business grows.
Now you have:
100 products
50 customers
Daily orders
Supplier information
Suddenly the notebook becomes difficult to manage.
You cannot quickly find information.
You accidentally write duplicate entries.
Some pages get damaged.
Some information becomes outdated.
Now imagine the business grows even more.
You have:
10,000 products
5,000 customers
Hundreds of daily orders
At this point, the notebook becomes completely useless.
You need a better system.
That better system is called a database.
The Simplest Definition of a Database
A database is an organized collection of information that can be stored, managed, updated, and retrieved efficiently.
In simple words:
A database is a digital storage system designed to keep data organized.
Just like a library stores books in an organized way, a database stores information in an organized way.
Database Analogy: The Library
Imagine entering a massive library.
The library contains:
Millions of books
Thousands of shelves
Multiple departments
Despite the huge amount of information, finding a book is easy.
Why?
Because everything is organized.
Books are categorized.
Shelves are labeled.
Indexes help locate books.
Records are maintained properly.
A database works in exactly the same way.
Instead of books, it stores data.
Instead of shelves, it uses tables.
Instead of librarians, it uses database systems.
Where Do We Use Databases Every Day?
Most people use databases without realizing it.
Whenever you use:
Amazon
Flipkart
Instagram
Facebook
WhatsApp
Netflix
Banking Applications
Food Delivery Apps
You are interacting with databases.
Every click usually triggers database operations.
For example:
When you log in:
Database checks your account.
When you place an order:
Database stores the order.
When you update your profile:
Database updates information.
When you search for products:
Database retrieves matching records.
Without databases, modern applications cannot function.
AQAD Example
Let's use our AQAD marketplace.
Imagine AQAD has:
Vendors
Al Madina Foods
Fresh Farm LLC
Gulf Beverage Traders
Retailers
ABC Supermarket
City Grocery
Smart Mart
Products
Milk
Rice
Juice
Coffee
Orders
Thousands every day.
Where should we store all this information?
Certainly not in text files.
Certainly not in Excel sheets.
Instead, we create a database.
The database stores:
Vendor Information
| Vendor ID | Vendor Name |
|---|---|
| 1 | Al Madina Foods |
| 2 | Fresh Farm LLC |
Retailer Information
| Retailer ID | Retailer Name |
|---|---|
| 101 | ABC Supermarket |
| 102 | Smart Mart |
Products
| Product ID | Product Name | Price |
|---|---|---|
| 1001 | Milk | 10 AED |
| 1002 | Rice | 25 AED |
Orders
| Order ID | Retailer | Product |
|---|---|---|
| 5001 | ABC Supermarket | Milk |
Everything becomes organized.
Everything becomes searchable.
Everything becomes manageable.
Why Developers Love Databases
Imagine AQAD's CEO asks:
"How many orders were placed today?"
Without a database:
Someone manually checks files.
With a database:
A query returns the answer in seconds.
Suppose the CEO asks:
"Which vendor sold the most products this month?"
Database can answer instantly.
Suppose finance asks:
"What is total revenue this year?"
Database can calculate it automatically.
Databases transform raw information into useful business insights.
Data vs Information
Beginners often confuse data and information.
Let's understand the difference.
Data
Raw facts.
Example:
Milk
20 AED
Vendor ID 12
Quantity 50
These values alone don't tell much.
Information
Processed and meaningful data.
Example:
"Vendor Al Madina Foods sold 500 units of Milk this week."
That is information.
A database stores raw data so it can later generate useful information.
The Evolution of Data Storage
Before databases existed, businesses stored data using:
Paper Records
Problems:
Easily lost
Difficult to search
Difficult to update
File Systems
Later businesses used:
Text files
CSV files
Excel sheets
This solved some problems.
But new issues appeared:
Duplicate records
Data inconsistency
Slow searching
No relationships between files
Difficult reporting
This led to the invention of database management systems.
What Is a Database Management System (DBMS)?
A database alone is simply stored information.
We need software to manage it.
That software is called a DBMS.
DBMS stands for:
Database Management System.
Its job is to:
Store data
Retrieve data
Update data
Delete data
Secure data
Organize data
Think of a DBMS as a warehouse manager.
The warehouse contains products.
The manager knows:
Where products are stored
How to retrieve them
How to update inventory
How to prevent mistakes
Similarly, a DBMS manages data.
Popular Database Systems
There are many DBMS solutions available.
Examples include:
MySQL
PostgreSQL
Oracle
Microsoft SQL Server
SQLite
MariaDB
In this pillar article, our primary focus will be MySQL because it is one of the most popular databases used in web development.
Many companies use MySQL for:
E-commerce platforms
SaaS applications
Content management systems
Business applications
Backend APIs
Why MySQL Became So Popular
Developers love MySQL because it is:
Easy to learn
Fast
Reliable
Open source
Well documented
Widely supported
Many successful companies started with MySQL.
For beginner developers, MySQL is often the first database they learn.
How a Database Fits Into a Web Application
Let's revisit AQAD.
A retailer places an order.
The flow looks like this:
Step 1:
Retailer opens AQAD app.
↓
Step 2:
App sends request to backend.
↓
Step 3:
Backend processes request.
↓
Step 4:
Database stores order.
↓
Step 5:
Backend returns success response.
↓
Step 6:
Retailer sees order confirmation.
The database acts as the long-term memory of the application.
Without it, every order would disappear after the application restarts.
Think of a Database as the Brain's Memory
Imagine your brain could remember nothing after every hour.
Life would be impossible.
Applications have the same problem.
Backend servers process requests.
But databases remember information permanently.
In simple words:
Backend = Brain Processing
Database = Long-Term Memory
Together they create useful applications.
Common Mistakes Beginners Make
Mistake 1
Thinking Database = MySQL
Wrong.
Database is the concept.
MySQL is one implementation.
Mistake 2
Thinking Databases Only Store Large Data
Even small applications need databases.
Mistake 3
Ignoring Database Design
Poor design causes major performance issues later.
Mistake 4
Using Excel Instead of a Database
Excel is useful for reports.
Databases are designed for application data.
Mini Exercise
Imagine AQAD launches tomorrow.
List what information should be stored in the database.
Possible answers:
Users
Vendors
Retailers
Products
Categories
Orders
Payments
Deliveries
Notifications
Inventory
This exercise helps develop database thinking.
Try It Yourself
Open any application on your phone.
Ask yourself:
What data does this app store?
What tables might exist?
What information changes daily?
Which information must be permanent?
This simple exercise helps you think like a backend developer.
Why Databases Exist
The Problems Before Databases
Before we learn SQL, tables, relationships, joins, and advanced MySQL concepts, we need to understand one important question:
Why were databases invented in the first place?
Most developers jump directly into writing SQL queries.
They learn:
SELECT * FROM products;
without understanding the real problem databases were designed to solve.
When you understand the problem, every database concept starts making sense.
So let's travel back in time.
A Story From Before Databases Existed
Imagine AQAD existed 40 years ago.
No MySQL.
No PostgreSQL.
No Oracle.
No cloud platforms.
No database servers.
The AQAD team still has:
Vendors
Retailers
Products
Orders
Payments
Deliveries
The business still needs to manage information.
How would they do it?
Simple.
Using paper.
Lots and lots of paper.
Phase 1: Paper-Based Systems
Imagine a warehouse employee receives a new vendor.
They create a paper file.
Vendor File
Vendor Name: Fresh Farm LLC
Phone: +971xxxxxxxx
Address: Dubai
Products:
Milk
Cheese
Butter
Every new vendor gets a separate file.
Every new retailer gets another file.
Every order gets another paper form.
At first this seems manageable.
The Business Starts Growing
AQAD now has:
100 vendors
500 retailers
10,000 products
Hundreds of orders daily
Suddenly problems begin appearing.
A retailer calls:
"I placed an order last month."
Employee starts searching.
Cabinet 1.
Cabinet 2.
Cabinet 3.
Hundreds of papers.
Several minutes later they finally find the record.
Sometimes they never find it.
Problem #1: Slow Searching
The biggest issue with paper systems is searching.
Imagine asking:
Which vendor sold the most rice this month?
With paper records:
Someone manually checks hundreds or thousands of pages.
The process might take hours.
Maybe days.
For growing businesses, this becomes impossible.
Problem #2: Duplicate Information
Suppose a retailer changes address.
Old Address:
Dubai Marina
New Address:
Business Bay
The retailer information exists in:
Customer file
Order forms
Delivery records
Payment records
An employee updates only some records.
Now different documents contain different addresses.
Nobody knows which one is correct.
This problem is called:
Data Duplication
The same information exists in multiple places.
Problem #3: Data Inconsistency
Data duplication creates another problem.
Data inconsistency.
Example:
Document A:
Retailer Name:
ABC Supermarket
Document B:
ABC Super Market
Document C:
ABC Market
Are these three retailers?
Or one retailer?
Nobody knows.
The system becomes unreliable.
Problem #4: Human Errors
Humans make mistakes.
An employee accidentally writes:
1000 units
instead of
100 units.
A payment amount is recorded incorrectly.
A vendor name is misspelled.
A page is lost.
A document is damaged.
Paper systems heavily depend on manual accuracy.
Mistakes become common.
Problem #5: No Reporting
Imagine AQAD management asks:
"What was our total revenue this year?"
Employees begin checking:
Order books
Payment files
Delivery logs
Calculations take days.
Reports become difficult.
Decision-making becomes slow.
Business growth suffers.
Problem #6: Security Issues
Paper files can be:
Stolen
Lost
Damaged
Destroyed
A fire.
A flood.
An accident.
Years of business records could disappear.
There is no backup.
No recovery.
No protection.
Problem #7: Scalability Problems
A small shop might manage:
50 customers.
But what happens when AQAD reaches:
50,000 retailers
10,000 vendors
100,000 products
Paper systems collapse.
The amount of information becomes impossible to manage manually.
Businesses Move to Computer Files
Eventually companies started using computers.
Instead of paper records they used:
Text files
CSV files
Excel spreadsheets
This was a huge improvement.
Searching became faster.
Storage became easier.
Sharing became possible.
Businesses thought they had solved the problem.
Unfortunately, new problems appeared.
Phase 2: File-Based Systems
Imagine AQAD stores data like this:
vendors.xlsx
retailers.xlsx
products.xlsx
orders.xlsx
payments.xlsx
Each department manages its own file.
Everything looks organized.
At first.
The Vendor Department Problem
Vendor department updates:
Fresh Farm LLC
Phone Number:
+971500000001
Finance department still has:
+971500000000
Delivery department has:
+971500000002
Now three different phone numbers exist.
Which one is correct?
Nobody knows.
File-Based Systems Create Silos
Each department owns separate files.
Information becomes isolated.
These isolated information groups are called:
Data Silos
Think of silos as separate rooms where information is locked away.
Vendor team has one version.
Finance team has another.
Delivery team has another.
The business loses a single source of truth.
Real AQAD Example
Suppose a retailer places an order.
Information affects:
Inventory
Orders
Payments
Delivery
If these systems are separate files:
All files must be updated manually.
If one update is missed:
Problems begin immediately.
Inventory becomes incorrect.
Reports become incorrect.
Customers become unhappy.
Problem #8: Data Redundancy
Redundancy means storing the same data multiple times.
Example:
Vendor Name:
Fresh Farm LLC
Stored in:
Vendor file
Product file
Invoice file
Delivery file
Payment file
Now imagine the vendor changes their company name.
Every file must be updated.
Miss one file and data becomes inconsistent.
Problem #9: Difficult Relationships
Businesses naturally have relationships.
AQAD Example:
Vendor → Products
Retailer → Orders
Order → Payments
Order → Deliveries
File systems struggle to manage these relationships.
Information becomes disconnected.
Tracking becomes difficult.
Problem #10: Multi-User Access
Imagine five AQAD employees open:
orders.xlsx
at the same time.
Problems occur:
Conflicting edits
Overwritten data
File locking
Lost updates
Businesses need multiple employees working simultaneously.
File systems struggle with this requirement.
Problem #11: Performance Becomes Slow
Suppose AQAD stores:
1 million products
inside one spreadsheet.
Searching becomes slower.
Reports become slower.
Updates become slower.
As data grows, performance decreases dramatically.
Businesses Needed Something Better
Developers and businesses realized:
Paper systems were not enough.
File systems were not enough.
A new solution was required.
That solution became:
Database Management Systems (DBMS).
Enter Databases
Databases solved many major business problems.
Instead of separate files:
Everything lives inside a centralized system.
Now:
Vendor data exists once.
Retailer data exists once.
Product data exists once.
Order data exists once.
Everyone accesses the same information.
How Databases Solved the Problems
Let's compare.
Paper System
Searching takes hours.
Database
Searching takes milliseconds.
Paper System
Data duplicated everywhere.
Database
Single source of truth.
Paper System
No automatic reports.
Database
Instant reporting.
Paper System
Manual calculations.
Database
Automatic calculations.
Paper System
Easy to lose records.
Database
Backup and recovery.
Paper System
Limited scalability.
Database
Millions or billions of records.
The Single Source of Truth Concept
This is one of the most important ideas in database design.
Imagine AQAD stores retailer information once.
Every department accesses the same record.
Now when the retailer updates their address:
Every department immediately sees the new information.
No confusion.
No duplicates.
No inconsistencies.
This is called:
Single Source of Truth.
Modern software depends heavily on this concept.
Why Modern Applications Cannot Survive Without Databases
Think about:
Every photo needs storage.
Every like needs storage.
Every comment needs storage.
Every user needs storage.
Now think about:
AQAD
Every vendor.
Every retailer.
Every product.
Every order.
Every delivery.
Every payment.
Without databases, managing this information would be impossible.
Database Thinking for Developers
When developers build software, they start asking:
What information must be stored?
What information changes?
How are records connected?
How can data be retrieved quickly?
These questions naturally lead to database design.
This is why databases became a core part of backend development.
Common Mistakes Beginners Make
Mistake 1
Thinking databases only store data.
Databases also help organize, secure, and retrieve data efficiently.
Mistake 2
Ignoring duplication problems.
Duplicate data causes major issues later.
Mistake 3
Using spreadsheets for growing applications.
Spreadsheets work for small operations.
Applications require databases.
Mistake 4
Not planning relationships early.
Relationships become critical as systems grow.
Mini Exercise
Imagine AQAD stores all data in Excel files.
List at least five problems that could occur.
Possible answers:
Duplicate records
Slow searching
Incorrect reports
Conflicting updates
Lost files
Security issues
Scalability limitations
Try It Yourself
Open any application you use daily.
Examples:
Amazon
Flipkart
Swiggy
Zomato
Instagram
Now think:
What would happen if they stored everything in Excel files?
How would they handle:
Millions of users?
Millions of orders?
Simultaneous updates?
Real-time reports?
This exercise helps you understand why databases became essential.
Introduction to SQL
The Language That Lets You Talk to Databases
In the previous chapters, we learned:
What a database is
Why databases were invented
Problems with paper records and spreadsheets
Why modern applications depend on databases
Now we face an important question.
Imagine AQAD already has a database.
The database contains:
Vendors
Retailers
Products
Orders
Payments
Deliveries
Great.
But how do we actually use this database?
How do we:
Add products?
Find orders?
Update inventory?
Delete old records?
Generate reports?
A database cannot read your mind.
You must communicate with it.
And that communication happens through a language called SQL.
A Real-Life Story
Imagine you visit a restaurant.
You sit at a table.
The kitchen is ready.
The chefs are working.
The ingredients are available.
But there is a problem.
How will the kitchen know what food you want?
You need a way to communicate.
You tell the waiter:
"I want one pizza and one coffee."
The waiter carries your request to the kitchen.
The kitchen processes it.
Food arrives.
Databases work in a very similar way.
The database is like the kitchen.
You are like the customer.
SQL is the language used to place requests.
Without SQL, the database doesn't know what you want.
What Does SQL Stand For?
SQL stands for:
Structured Query Language
The name sounds complicated.
Ignore the fancy words.
For developers, SQL simply means:
The language used to communicate with databases.
That's it.
Think of SQL as a Translator
Imagine AQAD's backend wants product information.
Backend understands JavaScript.
Database understands SQL.
The backend cannot directly speak database language.
SQL acts as a translator.
Flow:
User
↓
React Application
↓
Node.js Backend
↓
SQL Query
↓
MySQL Database
↓
Result Returned
Without SQL, the backend and database cannot communicate properly.
Real AQAD Example
Suppose a retailer searches:
"Milk"
The AQAD backend sends a request to the database.
The SQL query might look like:
SELECT * FROM products
WHERE product_name = 'Milk';
The database receives the request.
It searches products.
It returns matching results.
The retailer sees:
Milk 1L
Milk 2L
Organic Milk
All of this happens in seconds.
Why SQL Became So Popular
Before SQL became popular, every database had its own way of working.
This created problems.
Developers had to learn different systems.
SQL introduced a standard way to work with data.
Today SQL is used across many database systems.
Examples:
MySQL
PostgreSQL
SQL Server
Oracle
MariaDB
Once you understand SQL fundamentals, learning another relational database becomes much easier.
SQL Is Similar to English
One reason SQL became successful is that it reads almost like English.
Example:
SELECT * FROM products;
Even a beginner can guess what this means.
It says:
"Select everything from products."
Another example:
SELECT * FROM vendors;
Meaning:
"Show all vendors."
SQL commands are surprisingly readable.
What Can SQL Do?
SQL can perform many tasks.
The most common are:
Create Data
Add new information.
Example:
Add a new vendor.
Read Data
Retrieve information.
Example:
Show all orders.
Update Data
Modify information.
Example:
Update product price.
Delete Data
Remove information.
Example:
Delete discontinued products.
These four operations are so important that they have a special name.
CRUD.
We will cover CRUD in detail in the next chapter.
Understanding Queries
Whenever you send instructions to a database, that instruction is called a query.
Think of a query as a question or request.
Examples:
Show all products.
Show all vendors.
Find today's orders.
Calculate total sales.
Every request is a query.
Your First SQL Query
Let's start with the most famous SQL statement.
SELECT * FROM products;
Let's break it down.
SELECT
Means:
"I want information."
- Means:
"Give me everything."
FROM products
Means:
"Get the information from the products table."
The complete sentence becomes:
"Give me all information from the products table."
Simple.
AQAD Products Table Example
Imagine AQAD has:
| Product ID | Product Name | Price |
|---|---|---|
| 1 | Milk | 10 |
| 2 | Rice | 25 |
| 3 | Juice | 15 |
When we run:
SELECT * FROM products;
Result:
| Product ID | Product Name | Price |
|---|---|---|
| 1 | Milk | 10 |
| 2 | Rice | 25 |
| 3 | Juice | 15 |
The database returns all rows.
Selecting Specific Columns
Sometimes we don't need everything.
Suppose AQAD only needs product names.
Instead of:
SELECT * FROM products;
We can write:
SELECT product_name
FROM products;
Result:
Milk
Rice
Juice
Only the requested column is returned.
This improves efficiency.
Retrieving Multiple Columns
We can also select specific columns.
Example:
SELECT product_name, price
FROM products;
Result:
Milk — 10
Rice — 25
Juice — 15
This is very common in real applications.
Filtering Data with WHERE
Imagine AQAD has 100,000 products.
We only want Milk.
We use WHERE.
SELECT *
FROM products
WHERE product_name = 'Milk';
The WHERE clause acts like a filter.
Think of it like a warehouse employee searching only one shelf instead of the entire warehouse.
AQAD Retailer Example
Suppose we want orders placed by a specific retailer.
SELECT *
FROM orders
WHERE retailer_id = 101;
The database only returns matching orders.
This saves time and resources.
SQL Keywords
Words like:
SELECT
FROM
WHERE
are called SQL keywords.
These keywords have special meaning.
Think of them as commands given to the database.
Some common SQL keywords:
SELECT
INSERT
UPDATE
DELETE
CREATE
ALTER
DROP
WHERE
ORDER BY
GROUP BY
You will learn these throughout this pillar article.
How SQL Fits Into Node.js Applications
Let's revisit AQAD.
Retailer clicks:
"View Products"
The process looks like this:
Retailer
↓
React Frontend
↓
Node.js Backend
↓
SQL Query
↓
MySQL Database
↓
Product Data
↓
Node.js Backend
↓
Frontend
↓
Retailer
This flow happens thousands of times every day.
SQL Behind Popular Applications
Every major application uses SQL-like queries.
Examples:
Finding followers.
Amazon
Finding products.
Netflix
Finding movies.
AQAD
Finding products, orders, payments, and deliveries.
Whenever information must be retrieved, SQL is often involved.
Why Developers Should Learn SQL Well
Many beginners focus only on:
JavaScript
React
Node.js
And ignore SQL.
This becomes a huge mistake.
Most backend applications spend a significant amount of time interacting with databases.
A great backend developer understands:
APIs
Business Logic
Databases
Not just one of them.
Common Mistakes Beginners Make
Mistake 1
Memorizing Queries Without Understanding Them
Learn what each keyword does.
Don't just copy and paste.
Mistake 2
Always Using SELECT *
Fetch only required columns.
This improves performance.
Mistake 3
Ignoring Data Filtering
Without WHERE, databases return unnecessary data.
Mistake 4
Thinking SQL Is Difficult
SQL is often easier than programming languages.
Most commands read like English.
Mini Exercise
Suppose AQAD has a products table.
Write a query that returns all products.
Answer:
SELECT * FROM products;
Now write a query that returns only product names.
Answer:
SELECT product_name
FROM products;
Try It Yourself
Create a notebook.
Pretend you have a products table.
Write queries for:
Show all products.
Show only prices.
Show product names and prices.
Find Milk products.
Don't worry about execution.
Focus on understanding the logic.
SQL Is Like Learning a New Language
When you first learn English:
You start with simple words.
Then sentences.
Then conversations.
SQL works exactly the same way.
Today we learned:
SELECT
FROM
WHERE
Soon you'll learn:
INSERT
UPDATE
DELETE
JOINS
INDEXES
TRANSACTIONS
And eventually you'll be able to build complete applications backed by MySQL.
Introduction to SQL
The Language That Lets You Talk to Databases
In the previous chapters, we learned:
What a database is
Why databases were invented
Problems with paper records and spreadsheets
Why modern applications depend on databases
Now we face an important question.
Imagine AQAD already has a database.
The database contains:
Vendors
Retailers
Products
Orders
Payments
Deliveries
Great.
But how do we actually use this database?
How do we:
Add products?
Find orders?
Update inventory?
Delete old records?
Generate reports?
A database cannot read your mind.
You must communicate with it.
And that communication happens through a language called SQL.
A Real-Life Story
Imagine you visit a restaurant.
You sit at a table.
The kitchen is ready.
The chefs are working.
The ingredients are available.
But there is a problem.
How will the kitchen know what food you want?
You need a way to communicate.
You tell the waiter:
"I want one pizza and one coffee."
The waiter carries your request to the kitchen.
The kitchen processes it.
Food arrives.
Databases work in a very similar way.
The database is like the kitchen.
You are like the customer.
SQL is the language used to place requests.
Without SQL, the database doesn't know what you want.
What Does SQL Stand For?
SQL stands for:
Structured Query Language
The name sounds complicated.
Ignore the fancy words.
For developers, SQL simply means:
The language used to communicate with databases.
That's it.
Think of SQL as a Translator
Imagine AQAD's backend wants product information.
Backend understands JavaScript.
Database understands SQL.
The backend cannot directly speak database language.
SQL acts as a translator.
Flow:
User
↓
React Application
↓
Node.js Backend
↓
SQL Query
↓
MySQL Database
↓
Result Returned
Without SQL, the backend and database cannot communicate properly.
Real AQAD Example
Suppose a retailer searches:
"Milk"
The AQAD backend sends a request to the database.
The SQL query might look like:
SELECT * FROM products
WHERE product_name = 'Milk';
The database receives the request.
It searches products.
It returns matching results.
The retailer sees:
Milk 1L
Milk 2L
Organic Milk
All of this happens in seconds.
Why SQL Became So Popular
Before SQL became popular, every database had its own way of working.
This created problems.
Developers had to learn different systems.
SQL introduced a standard way to work with data.
Today SQL is used across many database systems.
Examples:
MySQL
PostgreSQL
SQL Server
Oracle
MariaDB
Once you understand SQL fundamentals, learning another relational database becomes much easier.
SQL Is Similar to English
One reason SQL became successful is that it reads almost like English.
Example:
SELECT * FROM products;
Even a beginner can guess what this means.
It says:
"Select everything from products."
Another example:
SELECT * FROM vendors;
Meaning:
"Show all vendors."
SQL commands are surprisingly readable.
What Can SQL Do?
SQL can perform many tasks.
The most common are:
Create Data
Add new information.
Example:
Add a new vendor.
Read Data
Retrieve information.
Example:
Show all orders.
Update Data
Modify information.
Example:
Update product price.
Delete Data
Remove information.
Example:
Delete discontinued products.
These four operations are so important that they have a special name.
CRUD.
We will cover CRUD in detail in the next chapter.
Understanding Queries
Whenever you send instructions to a database, that instruction is called a query.
Think of a query as a question or request.
Examples:
Show all products.
Show all vendors.
Find today's orders.
Calculate total sales.
Every request is a query.
Your First SQL Query
Let's start with the most famous SQL statement.
SELECT * FROM products;
Let's break it down.
SELECT
Means:
"I want information."
- Means:
"Give me everything."
FROM products
Means:
"Get the information from the products table."
The complete sentence becomes:
"Give me all information from the products table."
Simple.
AQAD Products Table Example
Imagine AQAD has:
| Product ID | Product Name | Price |
|---|---|---|
| 1 | Milk | 10 |
| 2 | Rice | 25 |
| 3 | Juice | 15 |
When we run:
SELECT * FROM products;
Result:
| Product ID | Product Name | Price |
|---|---|---|
| 1 | Milk | 10 |
| 2 | Rice | 25 |
| 3 | Juice | 15 |
The database returns all rows.
Selecting Specific Columns
Sometimes we don't need everything.
Suppose AQAD only needs product names.
Instead of:
SELECT * FROM products;
We can write:
SELECT product_name
FROM products;
Result:
Milk
Rice
Juice
Only the requested column is returned.
This improves efficiency.
Retrieving Multiple Columns
We can also select specific columns.
Example:
SELECT product_name, price
FROM products;
Result:
Milk — 10
Rice — 25
Juice — 15
This is very common in real applications.
Filtering Data with WHERE
Imagine AQAD has 100,000 products.
We only want Milk.
We use WHERE.
SELECT *
FROM products
WHERE product_name = 'Milk';
The WHERE clause acts like a filter.
Think of it like a warehouse employee searching only one shelf instead of the entire warehouse.
AQAD Retailer Example
Suppose we want orders placed by a specific retailer.
SELECT *
FROM orders
WHERE retailer_id = 101;
The database only returns matching orders.
This saves time and resources.
SQL Keywords
Words like:
SELECT
FROM
WHERE
are called SQL keywords.
These keywords have special meaning.
Think of them as commands given to the database.
Some common SQL keywords:
SELECT
INSERT
UPDATE
DELETE
CREATE
ALTER
DROP
WHERE
ORDER BY
GROUP BY
You will learn these throughout this pillar article.
How SQL Fits Into Node.js Applications
Let's revisit AQAD.
Retailer clicks:
"View Products"
The process looks like this:
Retailer
↓
React Frontend
↓
Node.js Backend
↓
SQL Query
↓
MySQL Database
↓
Product Data
↓
Node.js Backend
↓
Frontend
↓
Retailer
This flow happens thousands of times every day.
SQL Behind Popular Applications
Every major application uses SQL-like queries.
Examples:
Finding followers.
Amazon
Finding products.
Netflix
Finding movies.
AQAD
Finding products, orders, payments, and deliveries.
Whenever information must be retrieved, SQL is often involved.
Why Developers Should Learn SQL Well
Many beginners focus only on:
JavaScript
React
Node.js
And ignore SQL.
This becomes a huge mistake.
Most backend applications spend a significant amount of time interacting with databases.
A great backend developer understands:
APIs
Business Logic
Databases
Not just one of them.
Common Mistakes Beginners Make
Mistake 1
Memorizing Queries Without Understanding Them
Learn what each keyword does.
Don't just copy and paste.
Mistake 2
Always Using SELECT *
Fetch only required columns.
This improves performance.
Mistake 3
Ignoring Data Filtering
Without WHERE, databases return unnecessary data.
Mistake 4
Thinking SQL Is Difficult
SQL is often easier than programming languages.
Most commands read like English.
Mini Exercise
Suppose AQAD has a products table.
Write a query that returns all products.
Answer:
SELECT * FROM products;
Now write a query that returns only product names.
Answer:
SELECT product_name
FROM products;
Try It Yourself
Create a notebook.
Pretend you have a products table.
Write queries for:
Show all products.
Show only prices.
Show product names and prices.
Find Milk products.
Don't worry about execution.
Focus on understanding the logic.
SQL Is Like Learning a New Language
When you first learn English:
You start with simple words.
Then sentences.
Then conversations.
SQL works exactly the same way.
Today we learned:
SELECT
FROM
WHERE
Soon you'll learn:
INSERT
UPDATE
DELETE
JOINS
INDEXES
TRANSACTIONS
And eventually you'll be able to build complete applications backed by MySQL.

0 Comments