diff --git a/02_activities/assignments/DC_Cohort/Assignment1.md b/02_activities/assignments/DC_Cohort/Assignment1.md
index f78778f5b..8caf8e723 100644
--- a/02_activities/assignments/DC_Cohort/Assignment1.md
+++ b/02_activities/assignments/DC_Cohort/Assignment1.md
@@ -106,6 +106,8 @@ Please do not pick the exact same tables that I have already diagrammed. For exa
-
- The column names can be found in a few spots (DB Schema window in the bottom right, the Database Structure tab in the main window by expanding each table entry, at the top of the Browse Data tab in the main window)
+
+
***
## Section 2:
@@ -123,6 +125,14 @@ Steps to complete this part of the assignment:
1. Write a query that returns everything in the customer table.
2. Write a query that displays all of the columns and 10 rows from the customer table, sorted by customer_last_name, then customer_first_ name.
+SELECT *
+FROM customer;
+
+SELECT *
+FROM customer
+ORDER BY customer_last_name, customer_first_name
+LIMIT 10;
+
-
#### WHERE
@@ -131,18 +141,67 @@ Steps to complete this part of the assignment:
1. two conditions using AND
2. one condition using BETWEEN
+SELECT *
+FROM customer_purchases
+WHERE product_id = 4 OR product_id = 9;
+
+-- option 1
+SELECT *,
+ quantity * cost_to_customer_per_qty AS price
+FROM customer_purchases
+WHERE customer_id >= 8 AND customer_id <= 10;
+
+
+-- option 2
+SELECT *,
+ quantity * cost_to_customer_per_qty AS price
+FROM customer_purchases
+WHERE customer_id BETWEEN 8 AND 10;
+
+
-
#### CASE
1. Products can be sold by the individual unit or by bulk measures like lbs. or oz. Using the product table, write a query that outputs the `product_id` and `product_name` columns and add a column called `prod_qty_type_condensed` that displays the word “unit” if the `product_qty_type` is “unit,” and otherwise displays the word “bulk.”
+SELECT
+product_id,
+product_name,
+CASE
+WHEN product_qty_type = 'unit' THEN 'unit'
+ELSE 'bulk'
+END AS prod_qty_type_condensed
+FROM product;
+
+
2. We want to flag all of the different types of pepper products that are sold at the market. Add a column to the previous query called `pepper_flag` that outputs a 1 if the product_name contains the word “pepper” (regardless of capitalization), and otherwise outputs 0.
+SELECT
+product_id,
+product_name,
+CASE
+WHEN product_qty_type = 'unit' THEN 'unit'
+ELSE 'bulk'
+END AS prod_qty_type_condensed,
+CASE
+WHEN LOWER(product_name) LIKE '%pepper%' THEN 1
+ELSE 0
+END AS pepper_flag
+FROM product;
+
+
-
#### JOIN
1. Write a query that `INNER JOIN`s the `vendor` table to the `vendor_booth_assignments` table on the `vendor_id` field they both have in common, and sorts the result by `vendor_name`, then `market_date`.
+
+SELECT *
+FROM vendor v
+INNER JOIN vendor_booth_assignments vba
+ON v.vendor_id = vba.vendor_id
+ORDER BY v.vendor_name, vba.market_date;
+
***
## Section 3:
@@ -154,6 +213,7 @@ Steps to complete this part of the assignment:
- or, from your local forked repository
- Complete each question
+
### Write SQL
#### AGGREGATE
@@ -162,6 +222,29 @@ Steps to complete this part of the assignment:
**HINT**: This query requires you to join two tables, use an aggregate function, and use the HAVING keyword.
+
+SELECT
+ v.vendor_id,
+ v.vendor_name,
+ COUNT(*) AS booth_rental_count
+FROM vendor v
+INNER JOIN vendor_booth_assignments vba
+ ON v.vendor_id = vba.vendor_id
+GROUP BY v.vendor_id, v.vendor_name
+ORDER BY v.vendor_name;
+
+SELECT
+ c.customer_id,
+ c.customer_first_name,
+ c.customer_last_name,
+ SUM(cp.cost_to_customer_per_qty) AS total_spent
+FROM customer c
+INNER JOIN customer_purchases cp
+ ON c.customer_id = cp.customer_id
+GROUP BY c.customer_id, c.customer_first_name, c.customer_last_name
+HAVING SUM(cp.cost_to_customer_per_qty) > 2000
+ORDER BY c.customer_last_name, c.customer_first_name;
+
-
#### Temp Table
@@ -172,6 +255,11 @@ Steps to complete this part of the assignment:
To insert the new row use VALUES, specifying the value you want for each column:
`VALUES(col1,col2,col3,col4,col5)`
+CREATE TEMP TABLE temp.new_vendor AS
+SELECT * FROM vendor;
+INSERT INTO temp.new_vendor (vendor_id, vendor_name, vendor_type, vendor_owner_first_name, vendor_owner_last_name)
+VALUES (10, 'Thomass Superfood Store', 'Fresh Focused', 'Thomas', 'Rosenthal');
+
-
#### Date
@@ -183,6 +271,8 @@ To insert the new row use VALUES, specifying the value you want for each column:
**HINTS**: you will need to AGGREGATE, GROUP BY, and filter...but remember, STRFTIME returns a STRING for your WHERE statement!!
+/* Not required */
+
***
## Section 4:
@@ -205,5 +295,11 @@ Consider, for example, concepts of fariness, inequality, social structures, marg
```
-Your thoughts...
+The Ghost of Values in Databases: A Marginalized Person’s Reflections
+Understanding schema and relational databases allowed me to see through the technology to the human choices embedded within it. When I grasped that database designers must deliberately encode which relationships “count,” I recognized this was not just computational but political. This insight directly connects to my research on algorithms and AI, where human bias seeps into algorithmic bias through training data and design choices.
+NADRA’s architects embedded assumptions about legitimate families into technical rules that marginalize orphans, khawaja sira communities, and single mothers. The schema itself becomes a gatekeeper of citizenship and rights. Edge cases reveal how the system works: orphans assigned random families, khawaja sira connected to gurus, women asked to fabricate marriage certificates. These are not bugs but the system working as designed, yet failing those whose lives do not fit the normalized template.
+Databases encode inequality by naturalizing dominant social structures while rendering others invisible. Fairness is not a post-hoc consideration but baked into every design decision. The schema choice determines whose existence the system recognizes.
+NADRA’s inflexibility reveals the danger of treating databases as static infrastructure rather than dynamic social systems. Good design must anticipate that categories will shift and that marginalized communities will demand recognition.
+This extends to databases in my daily life. Consider Instagram, which requires users to select from gender categories that reflect cisnormative assumptions. Or Canadian financial services that use algorithms trained on historical data reflecting racial bias in lending. These systems encode whose creditworthiness the institutions value, whose life experiences count as legitimate financial history, and whose identities are recognized. Understanding the technical architecture means understanding the power structures it enforces.
+
```
diff --git a/02_activities/assignments/DC_Cohort/assignment1.sql b/02_activities/assignments/DC_Cohort/assignment1.sql
index c992e3205..bc5953b05 100644
--- a/02_activities/assignments/DC_Cohort/assignment1.sql
+++ b/02_activities/assignments/DC_Cohort/assignment1.sql
@@ -4,16 +4,25 @@
--SELECT
/* 1. Write a query that returns everything in the customer table. */
+SELECT *
+FROM customer;
/* 2. Write a query that displays all of the columns and 10 rows from the cus- tomer table,
sorted by customer_last_name, then customer_first_ name. */
+SELECT *
+FROM customer
+ORDER BY customer_last_name, customer_first_name
+LIMIT 10;
--WHERE
/* 1. Write a query that returns all customer purchases of product IDs 4 and 9. */
+SELECT *
+FROM customer_purchases
+WHERE product_id = 4 OR product_id = 9;
@@ -23,9 +32,17 @@ filtered by customer IDs between 8 and 10 (inclusive) using either:
2. one condition using BETWEEN
*/
-- option 1
+SELECT *,
+ quantity * cost_to_customer_per_qty AS price
+FROM customer_purchases
+WHERE customer_id >= 8 AND customer_id <= 10;
-- option 2
+SELECT *,
+ quantity * cost_to_customer_per_qty AS price
+FROM customer_purchases
+WHERE customer_id BETWEEN 8 AND 10;
@@ -34,18 +51,41 @@ filtered by customer IDs between 8 and 10 (inclusive) using either:
Using the product table, write a query that outputs the product_id and product_name
columns and add a column called prod_qty_type_condensed that displays the word “unit”
if the product_qty_type is “unit,” and otherwise displays the word “bulk.” */
-
+SELECT
+product_id,
+product_name,
+CASE
+WHEN product_qty_type = 'unit' THEN 'unit'
+ELSE 'bulk'
+END AS prod_qty_type_condensed
+FROM product;
/* 2. We want to flag all of the different types of pepper products that are sold at the market.
add a column to the previous query called pepper_flag that outputs a 1 if the product_name
contains the word “pepper” (regardless of capitalization), and otherwise outputs 0. */
-
+SELECT
+product_id,
+product_name,
+CASE
+WHEN product_qty_type = 'unit' THEN 'unit'
+ELSE 'bulk'
+END AS prod_qty_type_condensed,
+CASE
+WHEN LOWER(product_name) LIKE '%pepper%' THEN 1
+ELSE 0
+END AS pepper_flag
+FROM product;
--JOIN
/* 1. Write a query that INNER JOINs the vendor table to the vendor_booth_assignments table on the
vendor_id field they both have in common, and sorts the result by vendor_name, then market_date. */
+SELECT *
+FROM vendor v
+INNER JOIN vendor_booth_assignments vba
+ON v.vendor_id = vba.vendor_id
+ORDER BY v.vendor_name, vba.market_date;
@@ -55,6 +95,15 @@ vendor_id field they both have in common, and sorts the result by vendor_name, t
-- AGGREGATE
/* 1. Write a query that determines how many times each vendor has rented a booth
at the farmer’s market by counting the vendor booth assignments per vendor_id. */
+SELECT
+ v.vendor_id,
+ v.vendor_name,
+ COUNT(*) AS booth_rental_count
+FROM vendor v
+INNER JOIN vendor_booth_assignments vba
+ ON v.vendor_id = vba.vendor_id
+GROUP BY v.vendor_id, v.vendor_name
+ORDER BY v.vendor_name;
@@ -63,6 +112,17 @@ sticker to everyone who has ever spent more than $2000 at the market. Write a qu
of customers for them to give stickers to, sorted by last name, then first name.
HINT: This query requires you to join two tables, use an aggregate function, and use the HAVING keyword. */
+SELECT
+ c.customer_id,
+ c.customer_first_name,
+ c.customer_last_name,
+ SUM(cp.cost_to_customer_per_qty) AS total_spent
+FROM customer c
+INNER JOIN customer_purchases cp
+ ON c.customer_id = cp.customer_id
+GROUP BY c.customer_id, c.customer_first_name, c.customer_last_name
+HAVING SUM(cp.cost_to_customer_per_qty) > 2000
+ORDER BY c.customer_last_name, c.customer_first_name;
@@ -77,6 +137,10 @@ When inserting the new vendor, you need to appropriately align the columns to be
-> To insert the new row use VALUES, specifying the value you want for each column:
VALUES(col1,col2,col3,col4,col5)
*/
+CREATE TEMP TABLE temp.new_vendor AS
+SELECT * FROM vendor;
+INSERT INTO temp.new_vendor (vendor_id, vendor_name, vendor_type, vendor_owner_first_name, vendor_owner_last_name)
+VALUES (10, 'Thomass Superfood Store', 'Fresh Focused', 'Thomas', 'Rosenthal');
@@ -86,7 +150,7 @@ VALUES(col1,col2,col3,col4,col5)
HINT: you might need to search for strfrtime modifers sqlite on the web to know what the modifers for month
and year are! */
-
+/* Not required */
/* 2. Using the previous query as a base, determine how much money each customer spent in April 2022.
Remember that money spent is quantity*cost_to_customer_per_qty.
@@ -94,3 +158,4 @@ Remember that money spent is quantity*cost_to_customer_per_qty.
HINTS: you will need to AGGREGATE, GROUP BY, and filter...
but remember, STRFTIME returns a STRING for your WHERE statement!! */
+/* Not required */
\ No newline at end of file
diff --git a/02_activities/assignments/DC_Cohort/images/Tanveer_SQL_Assigment_1_section_1.png b/02_activities/assignments/DC_Cohort/images/Tanveer_SQL_Assigment_1_section_1.png
new file mode 100644
index 000000000..118952760
Binary files /dev/null and b/02_activities/assignments/DC_Cohort/images/Tanveer_SQL_Assigment_1_section_1.png differ