Skip to content

Commit 092b7a3

Browse files
committed
Address block 3 suggestions
1 parent 7360284 commit 092b7a3

29 files changed

+271
-297
lines changed

learn-pr/azure-databases/postgresql/basic-sql-aggregate-functions-grouping/2-sample-database-overview.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
### YamlMime:ModuleUnit
22
uid: learn.wwl-azure.basic-sql-aggregate-functions-grouping.sample-database-overview
3-
title: Sample Database Overview
3+
title: Sample database
44
metadata:
5-
title: Sample Database Overview
5+
title: Sample database overview
66
description: "This unit introduces the structure and purpose of the sales sample database used throughout the module. It describes the key tables, their relationships via foreign keys, and how the database supports tracking orders, inventory, and customer activity. A schema diagram and SQL script are provided to help learners explore and understand the data model."
77
ms.date: 05/14/2025
88
author: milenak

learn-pr/azure-databases/postgresql/basic-sql-aggregate-functions-grouping/includes/2-sample-database-overview.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
The sales database is designed to simulate a typical sales environment for a company that sells various products to customers. It's structured to store information about customers, products, suppliers, orders, employees, and shipping. This database allows you to:
2+
23
- Track customer orders and purchase history
34
- Manage product inventory and pricing
45
- Analyze sales data and generate reports
@@ -1046,7 +1047,3 @@ INSERT INTO Sales.OrderDetails VALUES(518,10443,28,12);
10461047
```
10471048

10481049
</details>
1049-
1050-
## Sample database diagram
1051-
1052-
:::image type="content" source="../media/sample-database.png" alt-text="Screentshot of a sample database":::

learn-pr/azure-databases/postgresql/basic-sql-aggregate-functions-grouping/includes/3-aggregate-functions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Instead of retrieving individual rows, you frequently need to summarize data to understand trends or patterns. Aggregate functions are designed for this purpose, allowing you to perform calculations on a group of rows and return a single result. Common examples include determining the total sales, the average price of products, or the number of orders placed. These functions are fundamental tools for data analysis in SQL.
1+
Instead of retrieving individual rows, you frequently need to summarize data to understand trends or patterns.
2+
3+
Aggregate functions are designed for this purpose, allowing you to perform calculations on a group of rows and return a single result. Common examples include determining the total sales, the average price of products, or the number of orders placed. These functions are fundamental tools for data analysis in SQL.
24

35
Examples of aggregate functions include `COUNT` to count rows, `SUM` to calculate totals, `AVG` for averages, `MIN` to find the smallest value, and `MAX` to find the largest value in a dataset.
46

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
This tutorial provided a comprehensive overview of aggregate functions and data grouping techniques in SQL, specifically in the context of PostgreSQL.
2+
23
You should now be able to use functions such as `COUNT`, `SUM`, `AVG`, `MIN`, and `MAX` to perform calculations across multiple rows, as well as organize and summarize data using the `GROUP BY` and `HAVING` clauses.
34

45
By learning these concepts, you're well-equipped to analyze trends, generate meaningful summaries and filter grouped results effectively within relational databases.

learn-pr/azure-databases/postgresql/basic-sql-join-tables/2-sample-database-overview.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
### YamlMime:ModuleUnit
22
uid: learn.wwl-azure.basic-sql-joining-tables.sample-database-overview
3-
title: Sample Database Overview
3+
title: Sample database
44
metadata:
5-
title: Sample Database Overview
5+
title: Sample database overview
66
description: "This unit introduces the structure and purpose of the sales sample database used throughout the module. It describes the key tables, their relationships via foreign keys, and how the database supports tracking orders, inventory, and customer activity. A schema diagram and SQL script are provided to help learners explore and understand the data model."
77
ms.date: 05/14/2025
88
author: milenak

learn-pr/azure-databases/postgresql/basic-sql-join-tables/includes/1-introduction.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
21
<!-- 1. Topic sentences ----------------------------------------------------------------------------------
3-
42
Goal: Orient the learner to the area covered in this module.
53
64
Heading: None
@@ -44,12 +42,13 @@ In addition to managing individual tables, the ability to join tables is a criti
4442
Example: "In this module, we'll formally define several cybersecurity concepts like authentication
4543
and authorization. Then we'll put the concepts into context by describing some common
4644
authentication-based attacks. We'll also define some effective authorization security techniques."
47-
-->
48-
## What to expect?
45+
-->
46+
47+
## What to expect?
4948

5049
In this section, you learn how to combine data from multiple related tables using various types of SQL joins. You explore usage of `INNER JOIN`, `LEFT JOIN`, `RIGHT JOIN`, `FULL OUTER JOIN`, and `NATURAL JOIN` to retrieve connected data across tables. Through practical examples using the `sales` database, you gain the skills to query and interpret relationships between entities like `customers`, `orders`, and `employees`.
5150

52-
<!-- 5. Terminal learning objective ----------------------------------------------------------------------
51+
<!-- 5. Terminal learning objective ----------------------------------------------------------------------
5352
5453
Goal: Restate the module title as a complete sentence. You have more room here to convey the main goal
5554
than in a space-limited title. Make it outcome-focused so it describes the main skills and
@@ -59,7 +58,8 @@ In this section, you learn how to combine data from multiple related tables usin
5958
Heading: "## What is the main goal?"
6059
6160
Example: "By the end of the module, you'll have a comprehensive understanding of core cybersecurity concepts."
62-
-->
61+
-->
62+
6363
## What is the main goal?
6464

6565
The main goal of this section is to help you understand how to retrieve meaningful, connected data from multiple tables in a relational database using SQL joins. By understanding different types of joins and when to use them, you're able to write efficient queries that reflect real-world relationships between entities, enabling more complete and insightful data analysis.

learn-pr/azure-databases/postgresql/basic-sql-join-tables/includes/2-sample-database-overview.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
The sales database is designed to simulate a typical sales environment for a company that sells various products to customers. It's structured to store information about customers, products, suppliers, orders, employees, and shipping. This database allows you to:
22

3-
* Track customer orders and purchase history
4-
* Manage product inventory and pricing
5-
* Analyze sales data and generate reports
6-
* Track which employee handled which order
7-
* Track which shipper was used for each order
3+
- Track customer orders and purchase history
4+
- Manage product inventory and pricing
5+
- Analyze sales data and generate reports
6+
- Track which employee handled which order
7+
- Track which shipper was used for each order
88

9-
## Key tables:
9+
## Key tables
1010

11-
* customers: Stores customer details like names, addresses, and contact information
12-
* products: Contains product information, including names, prices, and categories
13-
* categories: Lists the categories to which the products belong
14-
* suppliers: Holds information about the companies supplying the products
15-
* orders: Records customer order details, including dates and customer IDs
16-
* order_details: Provides line-item details for each order, linking products and quantities
17-
* employees: Stores employee information
18-
* shippers: Contains details about shipping companies
11+
- customers: Stores customer details like names, addresses, and contact information
12+
- products: Contains product information, including names, prices, and categories
13+
- categories: Lists the categories to which the products belong
14+
- suppliers: Holds information about the companies supplying the products
15+
- orders: Records customer order details, including dates and customer IDs
16+
- order_details: Provides line-item details for each order, linking products and quantities
17+
- employees: Stores employee information
18+
- shippers: Contains details about shipping companies
1919

2020
The tables are interconnected using foreign keys, allowing for comprehensive data analysis and reporting on sales activities.
2121

@@ -24,20 +24,20 @@ Foreign keys are a concept in relational databases, used to establish and enforc
2424
## Sample database creation script
2525

2626
<details>
27-
<summary>Click to expand</summary>
27+
<summary>Select to expand</summary>
2828

2929
```sql
3030
CREATE SCHEMA Sales;
3131

3232
CREATE TABLE Sales.Categories
33-
(
33+
(
3434
CategoryID SERIAL PRIMARY KEY,
3535
CategoryName VARCHAR(25),
3636
Description VARCHAR(255)
3737
);
3838

3939
CREATE TABLE Sales.Customers
40-
(
40+
(
4141
CustomerID SERIAL PRIMARY KEY,
4242
CustomerName VARCHAR(50),
4343
ContactName VARCHAR(50),
@@ -81,8 +81,8 @@ CREATE TABLE Sales.Products(
8181
CategoryID INTEGER,
8282
Unit VARCHAR(25),
8383
Price NUMERIC,
84-
FOREIGN KEY (CategoryID) REFERENCES Sales.Categories (CategoryID),
85-
FOREIGN KEY (SupplierID) REFERENCES Sales.Suppliers (SupplierID)
84+
FOREIGN KEY (CategoryID) REFERENCES Sales.Categories (CategoryID),
85+
FOREIGN KEY (SupplierID) REFERENCES Sales.Suppliers (SupplierID)
8686
);
8787

8888
CREATE TABLE Sales.Orders(
@@ -101,8 +101,8 @@ CREATE TABLE Sales.OrderDetails(
101101
OrderID INTEGER,
102102
ProductID INTEGER,
103103
Quantity INTEGER,
104-
FOREIGN KEY (OrderID) REFERENCES Sales.Orders (OrderID),
105-
FOREIGN KEY (ProductID) REFERENCES Sales.Products (ProductID)
104+
FOREIGN KEY (OrderID) REFERENCES Sales.Orders (OrderID),
105+
FOREIGN KEY (ProductID) REFERENCES Sales.Products (ProductID)
106106
);
107107

108108
INSERT INTO Sales.Categories VALUES(1,'Beverages','Soft drinks, coffees, teas, beers, and ales');
@@ -1044,10 +1044,6 @@ INSERT INTO Sales.OrderDetails VALUES(515,10442,54,80);
10441044
INSERT INTO Sales.OrderDetails VALUES(516,10442,66,60);
10451045
INSERT INTO Sales.OrderDetails VALUES(517,10443,11,6);
10461046
INSERT INTO Sales.OrderDetails VALUES(518,10443,28,12);
1047-
10481047
```
1049-
</details>
1050-
1051-
## Sample database diagram
10521048

1053-
![Sample Database Schema](../media/sample-database.png)
1049+
</details>
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
## Join tables
32

4-
In relational databases, data is frequently organized into multiple tables to minimize redundancy and enhance data integrity. This design approach, known as normalization, avoids repeating the same information in different places. However, this means that useful information is often spread across multiple tables.
3+
In relational databases, data is frequently organized into multiple tables to minimize redundancy and enhance data integrity. This design approach, known as normalization, avoids repeating the same information in different places. However, this means that useful information is often spread across multiple tables.
54

6-
Joins are essential SQL operations that bridge this gap, allowing you to combine rows from two or more tables and retrieve related data in a single, unified result set. In essence, joins enable you to query information that is logically connected but physically separated. They achieve this combination by identifying and matching rows based on values found in one or more common columns between the tables. These common columns often serve as the link between a primary key in one table and a foreign key in another, establishing the relationships defined in the database schema.
5+
Joins are essential SQL operations that bridge this gap, allowing you to combine rows from two or more tables and retrieve related data in a single, unified result set. In essence, joins enable you to query information that is logically connected but physically separated. They achieve this combination by identifying and matching rows based on values found in one or more common columns between the tables. These common columns often serve as the link between a primary key in one table and a foreign key in another, establishing the relationships defined in the database schema.
76

8-
Note: A primary key is a unique identifier for each record in a table, ensuring that no two rows have the same value in this column. A foreign key, on the other hand, is a column in one table that references the primary key in another table, thereby linking the two tables.
7+
Note: A primary key is a unique identifier for each record in a table, ensuring that no two rows have the same value in this column. A foreign key, on the other hand, is a column in one table that references the primary key in another table, thereby linking the two tables.
98

10-
There are multiple 'flavors' of joins (`INNER`, `LEFT`, `RIGHT`, `FULL OUTER`, `NATURAL`), each designed to combine tables in slightly different ways. They provide control over which rows are included in the result set based on the presence or absence of matching values in the joined tables.
9+
There are multiple 'flavors' of joins (`INNER`, `LEFT`, `RIGHT`, `FULL OUTER`, `NATURAL`), each designed to combine tables in slightly different ways. They provide control over which rows are included in the result set based on the presence or absence of matching values in the joined tables.
1110

1211
## INNER JOIN
1312

@@ -16,12 +15,12 @@ An `INNER JOIN` is one of the most commonly used types of SQL joins. It combines
1615
When performing an `INNER JOIN`, only the rows that satisfy the condition from both tables are included in the result set, effectively filtering out any unmatched data. This makes `INNER JOIN` ideal for retrieving related information where connections between tables are explicitly defined, such as customer orders or employee assignments.
1716

1817
```sql
19-
SELECT orders.order_id, customers.customer_name, employees.first_name, employees.last_name
20-
FROM sales.orders AS orders
21-
INNER JOIN sales.customers AS customers ON orders.customer_id = customers.customer_id
18+
SELECT orders.order_id, customers.customer_name, employees.first_name, employees.last_name
19+
FROM sales.orders AS orders
20+
INNER JOIN sales.customers AS customers ON orders.customer_id = customers.customer_id
2221
INNER JOIN sales.employees AS employees ON orders.employee_id = employees.employee_id;
2322
```
2423

25-
The provided query employs multiple `INNER JOIN` operations to retrieve a unified result set containing details about `orders`, `customers`, and `employees`.
24+
The provided query employs multiple `INNER JOIN` operations to retrieve a unified result set containing details about `orders`, `customers`, and `employees`.
2625

27-
It matches the `customer_id` in the `orders` table with the corresponding `customer_id` in the `customers` table, and the `employee_id` in the `orders` table with the `employee_id` in the `employees` table. As a result, the query outputs each order's ID alongside the names of the customer and employee involved.
26+
It matches the `customer_id` in the `orders` table with the corresponding `customer_id` in the `customers` table, and the `employee_id` in the `orders` table with the `employee_id` in the `employees` table. As a result, the query outputs each order's ID alongside the names of the customer and employee involved.
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
## LEFT JOIN
32

43
A `LEFT JOIN`, also known as a `LEFT OUTER JOIN`, is a type of SQL operation that preserves all the rows from the left-hand (or first) table in the query, regardless of whether there's a matching row in the right-hand (or second) table.
5-
When a match is found, the columns from the right table are populated with the corresponding values. However, if no match exists, the result includes nulls in the columns originating from the right table.
6-
This join is useful when you need to create a comprehensive list from one table while appending related data from another, even when such relationships are incomplete or absent.
4+
When a match is found, the columns from the right table are populated with the corresponding values. However, if no match exists, the result includes nulls in the columns originating from the right table.
5+
This join is useful when you need to create a comprehensive list from one table while appending related data from another, even when such relationships are incomplete or absent.
76

87
```sql
98
SELECT customers.customer_name, orders.order_id
@@ -12,11 +11,11 @@ LEFT JOIN sales.orders AS orders ON customers.customer_id = orders.customer_id;
1211
```
1312

1413
The SQL query using a `LEFT JOIN` retrieves all customers from the `sales.customers` table, including those without any matching orders in the `sales.orders` table. The `ON` clause specifies that the `customer_id` field links the two tables.
15-
For customers who have placed orders, the `order_id` from the `orders` table is displayed. However, if a customer doesn't have any orders, the result still includes the customer, with the `order_id` column displaying null values.
14+
For customers who have placed orders, the `order_id` from the `orders` table is displayed. However, if a customer doesn't have any orders, the result still includes the customer, with the `order_id` column displaying null values.
1615

1716
## RIGHT JOIN
1817

19-
A `RIGHT JOIN`, also known as a `RIGHT OUTER JOIN`, is an SQL operation that ensures all rows from the right-hand (or second) table are included in the result, regardless of whether there's a matching row in the left-hand (or first) table.
18+
A `RIGHT JOIN`, also known as a `RIGHT OUTER JOIN`, is a SQL operation that ensures all rows from the right-hand (or second) table are included in the result, regardless of whether there's a matching row in the left-hand (or first) table.
2019
In cases where no match is found, the columns from the left table display null values.
2120
This type of join is commonly used to focus on the data in the right table while also appending information from the left table wherever relationships exist.
2221

@@ -27,4 +26,4 @@ RIGHT JOIN sales.orders AS orders ON customers.customer_id = orders.customer_id;
2726
```
2827

2928
This query retrieves all rows from the `sales.orders` table, ensuring that every order is included in the result, even if there's no associated entry in the `sales.customers` table.
30-
The `ON` clause specifies the relationship between the two tables via the `customer_id` column. If an order has a corresponding customer, the `customer_name` column is populated with the `customer_name`, null values are displayed for unmatched records.
29+
The `ON` clause specifies the relationship between the two tables via the `customer_id` column. If an order has a corresponding customer, the `customer_name` column is populated with the `customer_name`, null values are displayed for unmatched records.

learn-pr/azure-databases/postgresql/basic-sql-join-tables/includes/5-natural-and-full-join.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
## FULL OUTER JOIN
32

4-
A `FULL OUTER JOIN`, also referred to as a `FULL JOIN`, combines the characteristics of both `LEFT JOIN` and `RIGHT JOIN`, including all rows from both tables in the result set.
3+
A `FULL OUTER JOIN`, also referred to as a `FULL JOIN`, combines the characteristics of both `LEFT JOIN` and `RIGHT JOIN`, including all rows from both tables in the result set.
54
If there's a matching row between the tables based on the `ON` clause, the columns from both tables are populated. However, if a row in one table doesn't have a match in the other table, the columns from the unmatched table display null values.
65

76
```sql
@@ -19,7 +18,7 @@ You would use this approach for a comprehensive view of all customers and orders
1918
`NATURAL JOIN` is a type of SQL join that simplifies the process of combining tables by automatically matching columns with the same name and compatible data types from both tables.
2019
Unlike explicit joins, where the relationship between tables is defined using an `ON` clause, `NATURAL JOIN` relies on column names to identify shared attributes. It ensures that only rows with identical values in the matched columns are included in the result set, effectively filtering out mismatches.
2120

22-
This approach is useful when the tables being joined posses clearly defined relationships and matching column names, as it reduces the need for manual specification of join conditions.
21+
This approach is useful when the tables being joined posses clearly defined relationships and matching column names, as it reduces the need for manual specification of join conditions.
2322
However, users must exercise caution, as relying purely on column names can lead to unintended results if the tables contain columns with identical names but unrelated data.
2423

2524
```sql
@@ -28,4 +27,4 @@ FROM sales.customers AS c
2827
NATURAL JOIN sales.orders AS o;
2928
```
3029

31-
This query combines the `sales.customers` and `sales.orders` tables by automatically matching columns with the same name and compatible data types, such as `customer_id`.
30+
This query combines the `sales.customers` and `sales.orders` tables by automatically matching columns with the same name and compatible data types, such as `customer_id`.

0 commit comments

Comments
 (0)