🗄️ SQL — Level 1: SQL Fundamentals & Databases
You've completed the major Excel section of the roadmap.
Now we're moving to one of the most important skills for a Data Analyst: SQL
If Excel helps you analyze spreadsheet-based data, SQL helps you work directly with data stored in databases.
A Data Analyst should be able to use SQL to:
• Retrieve data
• Filter records
• Sort results
• Summarize information
• Join tables
• Find trends
• Calculate KPIs
• Investigate business problems
1️⃣ What Is SQL?
SQL stands for: Structured Query Language
It's a language used to communicate with relational databases.
For example, suppose a company stores millions of sales records in a database.
Instead of opening a huge spreadsheet, you can ask the database:
"Give me all sales from the North region."
Or:
"What was total revenue last month?"
Or:
"Which 10 products generated the most revenue?"
SQL allows you to ask these questions directly.
2️⃣ Why Is SQL Important for Data Analysts?
Imagine a company has:
50 million transactions.
Excel isn't the right tool for storing and querying all that information.
The data may be stored in a database such as:
• PostgreSQL
• MySQL
• Microsoft SQL Server
• Oracle Database
• Snowflake
• BigQuery
As a Data Analyst, you may connect to the database and use SQL to extract the data you need.
A typical workflow looks like:
Database
↓
SQL Query
↓
Required Data
↓
Analysis
↓
Dashboard / Report
↓
Business Decision
3️⃣ What Is a Database?
A database is a system used to store and manage data.
For example, an e-commerce company might have:
• Customers
• Products
• Orders
• Payments
• Employees
Each represents a different type of information.
Instead of putting everything into one enormous table, relational databases typically organize related information into separate tables.
4️⃣ What Is a Table?
A table is a structured collection of data organized into:
Rows + Columns
For example:
Customers
Customer_ID Customer_Name City
101 John Mumbai
102 Sarah Pune
103 Mike Delhi
Each row represents one customer.
Each column represents an attribute.
This should look familiar from Excel.
5️⃣ Rows vs Columns
Just like Excel:
Row
Represents a record.
Example:
101 | John | Mumbai
represents one customer.
Column
Represents an attribute.
For example:
• Customer_ID
• Customer_Name
• City
A useful rule:
One row = one record
One column = one attribute
6️⃣ What Is a Primary Key?
A Primary Key uniquely identifies each record in a table.
For example:
Customer_ID Customer_Name
101 John
102 Sarah
103 Mike
Here:
Customer_ID
can be the primary key.
Each customer should have a unique ID.
101 → John
102 → Sarah
103 → Mike
You shouldn't have two different customers with the same primary key.
7️⃣ What Is a Foreign Key?
A Foreign Key is a column used to establish a relationship between tables.
Suppose:
Customers
Customer_ID Customer_Name
101 John
102 Sarah
Orders
Order_ID Customer_ID Sales
5001 101 50,000
5002 102 70,000
5003 101 30,000
Here:
Customers.Customer_ID
is the primary key.
Orders.Customer_ID
can be a foreign key.
