diff --git a/02_activities/assignments/DC_Cohort/Assignment1.md b/02_activities/assignments/DC_Cohort/Assignment1.md index f650c9752..f71b4fe58 100644 --- a/02_activities/assignments/DC_Cohort/Assignment1.md +++ b/02_activities/assignments/DC_Cohort/Assignment1.md @@ -209,5 +209,9 @@ Consider, for example, concepts of fariness, inequality, social structures, marg ``` -Your thoughts... +Reading about Pakistan's family registration database made me think about all the times I've stared at a form, cursor blinking in a required field, realizing my reality doesn't fit any of the options. Databases aren't just storing our information—they're deciding what counts as real in the first place. +I see this every time I visit a new doctor. The intake form gives me two gender boxes and asks if I'm single, married, divorced, or widowed. What if you're none of those? What if your family doesn't look like what the database expects? You're forced to pick the "closest" option, which means the system never really sees you. And if the system doesn't see you, how can it properly care for you? +When I opened a bank account with my partner, the system automatically made one of us the "primary" holder based on whose name was entered first. It seemed like a small technical detail until we realized it affected everything from credit reporting to who could make certain decisions. The database assumed someone had to be in charge—there was no option for equals. +My LinkedIn profile bothers me too. It wants a neat timeline of jobs with increasingly impressive titles, but my actual career included taking time off to care for family and lateral moves for better work-life balance. The database treats these as gaps or failures rather than legitimate choices, making me invisible to recruiters whose searches assume everyone climbs straight up. +These aren't just inconveniences. When databases can't handle your reality, you get excluded from healthcare, banking, jobs, and education. The really frustrating part is how these systems present themselves as objective and neutral, when really they're making choices about whose lives are worth accommodating. Every dropdown menu is someone deciding whose existence matters enough to include. ``` diff --git a/02_activities/assignments/DC_Cohort/Entity-Relationship Diagram.png b/02_activities/assignments/DC_Cohort/Entity-Relationship Diagram.png new file mode 100644 index 000000000..9b4c8c181 Binary files /dev/null and b/02_activities/assignments/DC_Cohort/Entity-Relationship Diagram.png differ diff --git a/02_activities/assignments/DC_Cohort/assignment1.sql b/02_activities/assignments/DC_Cohort/assignment1.sql index 2ec561e2a..c232a44e9 100644 --- a/02_activities/assignments/DC_Cohort/assignment1.sql +++ b/02_activities/assignments/DC_Cohort/assignment1.sql @@ -6,9 +6,8 @@ --SELECT /* 1. Write a query that returns everything in the customer table. */ --QUERY 1 - - - +SELECT * +FROM customer; --END QUERY @@ -16,9 +15,10 @@ /* 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. */ --QUERY 2 - - - +SELECT * +FROM customer +ORDER BY customer_last_name, customer_first_name +LIMIT 10; --END QUERY @@ -27,9 +27,10 @@ sorted by customer_last_name, then customer_first_ name. */ /* 1. Write a query that returns all customer purchases of product IDs 4 and 9. Limit to 25 rows of output. */ --QUERY 3 - - - +SELECT * +FROM customer_purchases +WHERE product_id IN (4, 9) +LIMIT 25; --END QUERY @@ -42,9 +43,11 @@ filtered by customer IDs between 8 and 10 (inclusive) using either: Limit to 25 rows of output. */ --QUERY 4 - - - +SELECT *, + quantity * cost_to_customer_per_qty AS price +FROM customer_purchases +WHERE customer_id >= 8 AND customer_id <= 10 +LIMIT 25; --END QUERY @@ -55,9 +58,13 @@ Using the product table, write a query that outputs the product_id and product_n 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.” */ --QUERY 5 - - - +SELECT product_id, + product_name, + CASE + WHEN product_qty_type = 'unit' THEN 'unit' + ELSE 'bulk' + END AS prod_qty_type_condensed +FROM product; --END QUERY @@ -66,9 +73,17 @@ if the product_qty_type is “unit,” and otherwise displays the word “bulk. 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. */ --QUERY 6 - - - +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; --END QUERY @@ -78,9 +93,12 @@ contains the word “pepper” (regardless of capitalization), and otherwise out vendor_id field they both have in common, and sorts the result by market_date, then vendor_name. Limit to 24 rows of output. */ --QUERY 7 - - - +SELECT * +FROM vendor AS v +INNER JOIN vendor_booth_assignments AS vba + ON v.vendor_id = vba.vendor_id +ORDER BY vba.market_date, v.vendor_name +LIMIT 24; --END QUERY @@ -92,9 +110,10 @@ Limit to 24 rows of output. */ /* 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. */ --QUERY 8 - - - +SELECT vendor_id, + COUNT(*) AS booth_rental_count +FROM vendor_booth_assignments +GROUP BY vendor_id; --END QUERY @@ -105,9 +124,16 @@ 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. */ --QUERY 9 - - - +SELECT c.customer_id, + c.customer_first_name, + c.customer_last_name, + SUM(cp.quantity * cp.cost_to_customer_per_qty) AS total_spent +FROM customer AS c +INNER JOIN customer_purchases AS cp + ON c.customer_id = cp.customer_id +GROUP BY c.customer_id, c.customer_first_name, c.customer_last_name +HAVING total_spent > 2000 +ORDER BY c.customer_last_name, c.customer_first_name; --END QUERY @@ -124,9 +150,11 @@ When inserting the new vendor, you need to appropriately align the columns to be VALUES(col1,col2,col3,col4,col5) */ --QUERY 10 +CREATE TEMP TABLE new_vendor AS +SELECT * FROM vendor; - - +INSERT INTO temp.new_vendor +VALUES(10, 'Thomass Superfood Store', 'Fresh Focused', 'Thomas', 'Rosenthal'); --END QUERY @@ -138,9 +166,11 @@ HINT: you might need to search for strfrtime modifers sqlite on the web to know and year are! Limit to 25 rows of output. */ --QUERY 11 - - - +SELECT customer_id, + STRFTIME('%m', market_date) AS month, + STRFTIME('%Y', market_date) AS year +FROM customer_purchases +LIMIT 25; --END QUERY @@ -152,8 +182,11 @@ HINTS: you will need to AGGREGATE, GROUP BY, and filter... but remember, STRFTIME returns a STRING for your WHERE statement... AND be sure you remove the LIMIT from the previous query before aggregating!! */ --QUERY 12 - - - +SELECT customer_id, + SUM(quantity * cost_to_customer_per_qty) AS total_spent_april_2022 +FROM customer_purchases +WHERE STRFTIME('%Y', market_date) = '2022' + AND STRFTIME('%m', market_date) = '04' +GROUP BY customer_id; --END QUERY