fix(curriculum): remove product column in 2NF lesson (#63786)

This commit is contained in:
Diem-Trang Pham
2025-11-13 03:06:52 -06:00
committed by GitHub
parent 958fb2b155
commit e1af98e5d9

View File

@@ -59,7 +59,7 @@ The Second Normal Form (2NF) is based on addressing partial dependencies. A part
For example, let's say we have an `orders` table with these columns:
```sql
order_id | item_id | order_date | product | quantity | order_shipping_city
order_id | item_id | order_date | quantity | order_shipping_city
```
In this table, the primary key is the combination of `order_id` and `item_id` because the same item ID can be in different orders, but their combination will be unique. You can see that there is a partial dependency between `order_id` and `order_shipping_city`. `order_id` is part of the primary key. `order_shipping_city` depends on `order_id` because every order with the same ID will have the same shipping city. However, the shipping city does not depend on the `item_id`, but this is also part of the primary key. Therefore, `order_shipping_city` does not depend on the entire primary key.
@@ -73,7 +73,7 @@ order_id | order_date | order_shipping_city
In the `order_items` table, you could store information about the items in the different orders that were submitted:
```sql
order_id | item_id | product | quantity
order_id | item_id | quantity
```
With these changes, both tables will be in Second Normal Form (2NF).
@@ -90,7 +90,7 @@ To understand the Third Normal Form (3NF), you need to understand transitive dep
For example, let's modify our `orders` table to have these columns:
```sql
order_id | customer_id | customer_city | city_postal_code | order_date | product | quantity
order_id | customer_id | customer_city | city_postal_code | order_date | quantity
```
The primary key in this new table is `order_id` because it uniquely identifies each row.
@@ -106,7 +106,7 @@ The city's postal code is determined by the customer's city, which is determined
To solve the transitive dependency, you would need to split the table into multiple tables. First, an `orders` table:
```sql
order_id | customer_id | order_date | product | quantity
order_id | customer_id | order_date | quantity
```
Then, a `customers` table: