+
{lesson.frontmatter.title}
diff --git a/src/data/courses/sql/chapters/introduction/lessons/basics-of-databases.md b/src/data/courses/sql/chapters/introduction/lessons/basics-of-databases.md
index 33df42937..b5ad3a97f 100644
--- a/src/data/courses/sql/chapters/introduction/lessons/basics-of-databases.md
+++ b/src/data/courses/sql/chapters/introduction/lessons/basics-of-databases.md
@@ -7,11 +7,38 @@ type: lesson
Before we dive into everything SQL, let's first get the basics out. This chapter covers the basics of databases, different types of databases, SQL, it's different flavors, and the types of queries.
+## Data in the Modern World
+
+In today's digital world, data is everywhere. Every application we use needs to store and manage data in some way:
+
+- Social media apps like Twitter, Facebook, and Instagram track billions of posts, likes, and connections between users
+- E-commerce platforms like Amazon, eBay, and Shopify handle massive product catalogs, customer profiles, and order histories
+- Banking systems process millions of transactions and maintain accurate account balances
+- Streaming services like Netflix, Hulu, and Spotify manage vast libraries of content and personalized user recommendations
+
+This ever-growing volume of data needs to be stored, organized, and accessed efficiently. This is where databases come in - they provide a way to store data in a structured way that allows for efficient retrieval and manipulation.
+
## What is a Database?
-Every application deals with data in one way or another. Whether it's a social media app storing your posts and friend connections, an e-commerce platform managing product inventories and customer orders, or a banking application handling transactions and account balances - all these applications need somewhere to store their data. This is where databases come in - they provide a systematic way to store, organize, manage and retrieve data efficiently.
+A database is essentially an organized collection of data stored electronically in a way that allows for efficient retrieval and manipulation.
+
+Let's say you're building an e-commerce platform - you'll need to store and manage various types of data for your users and products:
+
+- Product information like names, descriptions, prices, categories, and inventory levels
+- Customer data including profiles, shipping addresses, and purchase history
+- Order details tracking items purchased, quantities, prices, shipping status
+- Reviews and ratings from customers for different products
+- Financial data for sales, refunds, taxes, and revenue calculations
+
+The database apart from storing this information also enables complex operations like:
+
+- Calculating total revenue across different time periods
+- Tracking inventory and automatically flagging low stock items
+- Computing shopping cart totals with tax and shipping
+- Analyzing customer purchase patterns for personalized recommendations
+- Generating sales reports by product category or region
-To put it simply, a database is a structured collection of data stored in a way that allows for easy retrieval and manipulation. For example, a library database stores information about books, members, and borrowing records - tracking details like book titles, authors, ISBN numbers, member information, due dates, and lending history. This allows librarians to quickly look up books, check availability, manage memberships, and ensure timely returns.
+Without a proper database system, managing these interconnected pieces of data and performing these calculations would be extremely challenging. The database provides the foundation for building a scalable and efficient e-commerce platform.
## Database Management Systems (DBMS)
diff --git a/src/data/courses/sql/chapters/introduction/lessons/types-of-queries.md b/src/data/courses/sql/chapters/introduction/lessons/types-of-queries.md
index dc8771acf..1242dc132 100644
--- a/src/data/courses/sql/chapters/introduction/lessons/types-of-queries.md
+++ b/src/data/courses/sql/chapters/introduction/lessons/types-of-queries.md
@@ -5,22 +5,19 @@ order: 160
type: lesson
---
-SQL (Structured Query Language) is a powerful tool for managing and manipulating data in relational databases. It provides a variety of query types that serve different purposes, from retrieving data to modifying database structures and more. There are three core types of queries in SQL:
+SQL provides a variety of query types each designed to fulfill specific tasks from retrieving data to modifying database structures and controlling access. These query types can be categorized into five main groups:
-1. Data Query Language (DQL)
-2. Data Manipulation Language (DML)
-3. Data Definition Language (DDL)
+- Data Query Language (DQL)
+- Data Manipulation Language (DML)
+- Data Definition Language (DDL)
+- Data Control Language (DCL)
+- Transaction Control Language (TCL)
-However, there are two additional types of queries that are used to manage the database itself:
-
-1. Data Control Language (DCL)
-2. Transaction Control Language (TCL)
-
-DCL and TCL are not covered in this course, but we will cover the other three types of queries in detail.
+While this course focuses primarily on DQL, DML, and DDL, a brief overview of DCL and TCL is given below to give you an idea of what they are.
## Data Query Language (DQL)
-DQL is used to retrieve data from a database, enabling users to extract meaningful information based on specific conditions. The most common DQL statement is the `SELECT` statement.
+DQL is used to retrieve data from a database, enabling you to extract meaningful insights based on specified conditions. The primary statement in DQL is `SELECT`, which allows users to fetch data from tables.
For example, the following statement retrieves all rows from the `users` table:
@@ -30,7 +27,7 @@ SELECT * FROM users;
## Data Manipulation Language (DML)
-DML is used to manipulate data stored in the database, such as inserting, updating, or deleting records. The most common DML statements are `INSERT`, `UPDATE`, and `DELETE`.
+DML is used to modify data stored in a database. It includes commands to insert, update, and delete records. The most commonly used DML statements are `INSERT`, `UPDATE`, and `DELETE`.
For example, the following statement inserts a new row into the `users` table:
@@ -54,9 +51,11 @@ DELETE FROM users
WHERE id = 1;
```
+We will look each of these statements and more in detail in later chapters.
+
## Data Definition Language (DDL)
-DDL is used to define the structure of the database. The most common DDL statements are `CREATE`, `ALTER`, and `DROP`.
+Before we start inserting data into our database, we need to set up the database and the tables. This is done using the DDL statements. These statements are used to create, modify, and delete database objects such as tables, indexes, and views. Most common DDL statements are `CREATE`, `ALTER`, and `DROP`.
For example, the following statement creates a new table called `users`:
@@ -69,4 +68,45 @@ CREATE TABLE users (
);
```
-Don't worry if you don't understand the syntax of these statements yet, we will cover them in detail in later chapters.
\ No newline at end of file
+## Data Control Language (DCL)
+
+DCL is used to manage access permissions and security within a database. It allows administrators to grant or revoke rights to specific users. The most common DCL statements are `GRANT` and `REVOKE`.
+
+For example, the following statement grants the user `john` access to the `users` table:
+
+```sql
+GRANT SELECT, INSERT, UPDATE, DELETE ON users TO john;
+```
+
+Although DCL is not covered extensively in this course, it is crucial for database security and user management.
+
+## Transaction Control Language (TCL)
+
+TCL manages database transactions to ensure data integrity. Transactions group multiple operations into a single unit, allowing them to be committed or rolled back together. Example of transaction could be a bank transfer where money is deducted from one account and added to another account while updating the bank statement for both accounts. If any of these steps fail, the transaction is rolled back, and the database is left in a consistent state. Here is an simplified example of a transaction:
+
+```sql
+BEGIN;
+-- Deduct money from source account
+UPDATE accounts SET balance = balance - 100 WHERE account_id = 1;
+-- Add money to destination account
+UPDATE accounts SET balance = balance + 100 WHERE account_id = 2;
+-- Update bank statement for source and destination account
+UPDATE bank_statements SET balance = balance - 100 WHERE account_id = 1;
+UPDATE bank_statements SET balance = balance + 100 WHERE account_id = 2;
+COMMIT;
+```
+
+Most common TCL statements are `COMMIT` (saves the changes), `ROLLBACK` (undoes changes in case of an error), and `SAVEPOINT` (sets checkpoints within a transaction).
+
+---
+Takeaways
+
+- SQL provides a variety of query types each designed to fulfill specific tasks from retrieving data to modifying database structures and controlling access.
+- DQL is used to retrieve data from a database, enabling you to extract meaningful insights based on specified conditions. Common DQL statement is `SELECT`.
+- DML is used to modify data stored in a database. Common DML statements are `INSERT`, `UPDATE`, and `DELETE`.
+- DDL is used to create, modify, and delete database objects such as tables, indexes, and views. Common DDL statements are `CREATE`, `ALTER`, and `DROP`.
+- DCL is used to manage access permissions and security within a database. Common DCL statements are `GRANT` and `REVOKE`.
+- TCL manages database transactions to ensure data integrity. Common TCL statements are `COMMIT`, `ROLLBACK`, and `SAVEPOINT`.
+---
+
+In the next chapter, we will start looking at DQL queries first to get you started with SQL and then move on to DDL and DML.
\ No newline at end of file
diff --git a/src/data/courses/sql/chapters/introduction/lessons/what-is-sql.md b/src/data/courses/sql/chapters/introduction/lessons/what-is-sql.md
index a76029dff..5e6063e5a 100644
--- a/src/data/courses/sql/chapters/introduction/lessons/what-is-sql.md
+++ b/src/data/courses/sql/chapters/introduction/lessons/what-is-sql.md
@@ -67,6 +67,15 @@ SQL is a standard language based on the [ISO/IEC 9075 standard](https://en.wikip
While these flavors differ, they are all based on the same standard, and therefore, the SQL statements you write will be compatible with most of them. By completing this course, you will be able to write SQL statements that are compatible with most popular database systems.
-## Conclusion
-In this chapter, we covered the basics of SQL, the language for querying databases. We discussed the different operations that can be performed on a database, the components of a database, the syntax of SQL statements, and the different flavors of SQL. In the next chapter, we will cover the different types of queries in SQL.
+---
+
+## Key Takeaways
+
+- SQL is a declarative language that allows us to describe what we want to achieve rather than how to achieve it.
+- SQL is case-insensitive.
+- SQL statements are made up of clauses e.g. `SELECT`, `FROM`, `WHERE`, etc.
+- SQL is a standard language based on the ISO/IEC 9075 standard.
+- There are many different flavors of SQL that are based on the SQL standard.
+
+In this chapter, we covered the basics of SQL, the language for querying databases. We discussed the different operations that can be performed on a database, the components of a database, the syntax of SQL statements, and the different flavors of SQL. In the next chapter, we will cover the different types of queries in SQL.
\ No newline at end of file
diff --git a/src/data/courses/sql/outline.md b/src/data/courses/sql/outline.md
new file mode 100644
index 000000000..3c6320795
--- /dev/null
+++ b/src/data/courses/sql/outline.md
@@ -0,0 +1,55 @@
+SQL — Basics to Advanced
+
+- Introduction
+ - Basics of Databases
+ - What is SQL?
+ - Different SQL Flavors
+ - Types of Queries
+- SQL Basics
+ - SELECT fundamentals
+ - Filtering Data with Where
+ - Column Aliases and Concatenation
+ - Sorting Results with ORDER BY
+ - Selecting Distinct Data
+ - Limiting Results with LIMIT
+ - Handling Null Values
+- Data Definition Language
+ - Creating Tables
+ - Common Data Types in Tables
+ - Altering Table Structure
+ - Dropping Tables
+ - Truncating Data in Tables
+- Data Manipulation and Management
+ - INSERT Operations
+ - Updating Single vs Multiple
+ - Deleting Data from Table
+- Multi-table Queries
+ - Understanding Table Relationships
+ - Types of JOINs (INNER, LEFT, RIGHT, FULL OUTER)
+ - Using aliases for table names
+ - Self-joins and their use cases
+ - Multiple Joins in a Single Query
+- Aggregate Functions and Grouping
+ - COUNT, SUM, AVG, MIN, MAX functions
+ - GROUP BY clause
+ - Having vs Where
+- Subqueries and Common Table Expressions
+ - Single-row and Multi-row Subqueries
+ - Correlated Subqueries
+ - EXISTS and NOT EXISTS
+ - Common Table Expressions (CTEs)
+ - Recursive CTEs
+ - Performance Considerations
+ - Subqueries vs JOINs
+- Window Functions
+ - Aggregate Window Functions
+ - Ranking Window Functions
+ - Analytic Window Functions
+ - Performance Considerations
+- Database Design and Normalization
+ - Database Design Principles
+ - Entity Relationship Diagrams (ERDs)
+ - Normalization Forms (1NF, 2NF, 3NF, BCNF)
+ - Denormalization Considerations
+ - Primary Keys and Foreign Keys
+ - Database Constraints
\ No newline at end of file