diff --git a/02_activities/assignments/DC_Cohort/Assignment1.md b/02_activities/assignments/DC_Cohort/Assignment1.md index d5ff55ce4..82243b7be 100644 --- a/02_activities/assignments/DC_Cohort/Assignment1.md +++ b/02_activities/assignments/DC_Cohort/Assignment1.md @@ -206,8 +206,20 @@ Link if you encounter a paywall: https://archive.is/srKHV or https://web.archive **What values systems are embedded in databases and data systems you encounter in your day-to-day life?** Consider, for example, concepts of fariness, inequality, social structures, marginalization, intersection of technology and society, etc. - - ``` Your thoughts... ``` +China's national ID (身份证 shenfenzheng) and household registration (户口 hukou). Similar to what I have read about the database of Pakistan, I think these systems reflect certain heteronormative assumptions about gender and family structures. + +First, the official gender classification recorded on Chinese national IDs is binary — either male or female. This excludes people who identify as non-binary, as there is no option that accurately represents their gender identity. +Consequently, non-binary individuals may feel marginalized or invisible within the legal system, since their identities cannot be adequately represented in official records. +What I find particularly interesting is that this binary classification is treated as a seemingly natural and objective way of categorizing people, even though it reflects particular social understandings of gender. + +Meanwhile, because same-sex marriage is not legally recognized in mainland China, same-sex couples cannot register as married partners. This can create significant difficulties when dealing with legal and administrative matters. +For instance, if one partner experiences a medical emergency and cannot make decisions independently, the other partner is not automatically recognized as their legal spouse or next of kin. +Same-sex couples do not automatically receive the same legal recognition as married heterosexual couples. + +Furthermore, even if same-sex partners raise children together, both partners may not be legally recognized as the children's parents in the household registration system. +In particular, a non-biological parent may face difficulties establishing a legally recognized parental relationship, despite having actively participated in raising the child. +This can create complications in matters involving guardianship, inheritance, and other parental responsibilities involved in schooling and children's education. + diff --git a/02_activities/assignments/DC_Cohort/assignment1.sql b/02_activities/assignments/DC_Cohort/assignment1.sql index a80923591..058a96d24 100644 --- a/02_activities/assignments/DC_Cohort/assignment1.sql +++ b/02_activities/assignments/DC_Cohort/assignment1.sql @@ -6,7 +6,7 @@ --SELECT /* 1. Write a query that returns everything in the customer table. */ --QUERY 1 - +SELECT * FROM customer ; @@ -17,9 +17,10 @@ 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 +28,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 = 4 OR product_id = 9 +LIMIT 25; --END QUERY @@ -42,10 +44,10 @@ filtered by customer IDs between 8 and 10 (inclusive) using either: Limit to 25 rows of output. */ --QUERY 4 - - - - +SELECT *, quantity * cost_per_quantity AS price +FROM customer_purchases +WHERE customer_id BETWEEN 8 AND 10 +LIMIT 25; --END QUERY @@ -55,9 +57,12 @@ 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 @@ -67,8 +72,16 @@ add a column to the previous query called pepper_flag that outputs a 1 if the pr 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 product_name LIKE '%pepper%' THEN 1 + ELSE 0 + END AS pepper_flag +FROM product; --END QUERY @@ -78,9 +91,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 market_date, vendor_name +LIMIT 24; --END QUERY @@ -92,9 +108,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, + SUM (booth_number) AS vendor_renting_times +FROM vendor_booth_assignments +GROUP BY vendor_id; --END QUERY @@ -106,8 +123,13 @@ 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 cp.customer_id, cp.quantity, cp.cost_per_quantity, c.customer_id, c.customer_first_name, c.customer_last_name, + SUM(cp.quantity * cp.cost_per_quantity) AS total_purchase +FROM customer_purchases AS cp +INNER JOIN customer AS c +ON cp.customer_id = c.customer_id +GROUP BY c.customer_id +HAVING total_purchase > 2000; --END QUERY @@ -124,9 +146,12 @@ 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 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' ) --END QUERY @@ -134,14 +159,14 @@ VALUES(col1,col2,col3,col4,col5) -- Date /*1. Get the customer_id, month, and year (in separate columns) of every purchase in the customer_purchases table. -HINT: you might need to search for strfrtime modifers sqlite on the web to know what the modifers for month +HINT: you might need to search for strfrtime modifiers sqlite on the web to know what the modifiers for month 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; --END QUERY @@ -152,8 +177,13 @@ 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 - - - - ---END QUERY +SELECT customer_id, + quantity, + cost_per_quantity, + STRFTIME('%m', market_date) AS month, + STRFTIME('%Y', market_date) AS year, + SUM(quantity * cost_per_quantity) AS total_purchase +FROM customer_purchases +WHERE month = '04' AND year = '2022' +GROUP BY customer_id, year, month; +--END QUERY \ No newline at end of file diff --git a/02_activities/assignments/DC_Cohort/logical_datamodel_XL.png b/02_activities/assignments/DC_Cohort/logical_datamodel_XL.png new file mode 100644 index 000000000..37908d5fb Binary files /dev/null and b/02_activities/assignments/DC_Cohort/logical_datamodel_XL.png differ