diff --git a/02_activities/assignments/DC_Cohort/.Rhistory b/02_activities/assignments/DC_Cohort/.Rhistory new file mode 100644 index 000000000..e69de29bb diff --git a/02_activities/assignments/DC_Cohort/Assignment1.md b/02_activities/assignments/DC_Cohort/Assignment1.md index f78778f5b..5db1ee553 100644 --- a/02_activities/assignments/DC_Cohort/Assignment1.md +++ b/02_activities/assignments/DC_Cohort/Assignment1.md @@ -205,5 +205,12 @@ Consider, for example, concepts of fariness, inequality, social structures, marg ``` -Your thoughts... + +In our daily lives we interact with databases and data systems that may seem neutral, but embed value systems shaped by the broader social structures in which they are created and deployed. When a system records only “standard” categories (e.g., male/female gender, certain ethnic groups, binary race options) or uses algorithms that assume typical behaviour as baseline, it privileges dominant populations and implicitly marginalizes those who don’t fit. Technology then becomes a mechanism through which existing social inequalities or power structures are reproduced. +The article reminded me that archival and data systems are not passive storehouses of information but they reflect decisions about what is collected, how it is structured, what is discarded or rendered invisible, and what relationships are acknowledged between data points. The act of creating and using a data system is a social act of selecting reality. Those selections echo values such as fairness (or its absence), equality (or neglect of difference), assumptions about normalcy, and the intersection of technology with society’s hierarchies and exclusions. +For instance, data systems may privilege quantifiable, easily measurable traits over more nuanced social realities (such as marginalization, intersectionality, lived experience). People who fall into multiple disadvantaged categories (race + gender + disability) may not be adequately represented if the system is designed only with “single-axis” categories. That omission encodes structural bias into the system. Further, when such systems are used in decision-making (for funding, for access, for monitoring), the embedded values have real impacts such as reinforcing marginalization, excluding certain groups from benefits, or misrepresenting experiences of inequality. +At the same time, technology and society co-construct one another. Data infrastructures aren’t merely technical A they carry the imprint of their designers’ assumptions, institutional logics, historical contexts. The design of a database including what fields are included, how privacy is handled, who has access, reflects social structures (who holds power, whose voices matter). And as society changes, these systems either adapt or become rigid. For example, if a system was built with a narrow conception of “user” based on a dominant group, it might fail to serve people from marginalized communities, thereby reproducing structural inequities in digital form. +In my own routines (as a student, teaching assistant, researcher) I interact with university information systems, learning-management platforms, research databases, etc. These environments embody value systems: ranking, assessing, benchmarking, tracking performance. They often focus on the measurable (grades, attendance, submission times) rather than the qualitative, relational, or structural factors that affect success (such as access, mentorship, socio-economic inequities, systemic bias). Therefore, they reflect wider societal structures of competition, credentialism, standardisation which may advantage those already positioned favourably and disadvantage those without resources or who don’t conform to the “norm”. +Recognising this helps me to reflect on how I might engage in data systems more critically. It invites awareness that technology isn’t neutral, but an active layer in the construction of social realities. Accordingly, when we design, use, or critique data systems, we must attend not only to technical correctness, but to the values embedded within. + ``` diff --git a/02_activities/assignments/DC_Cohort/DSI_SQL_LOGICAL DATA MODEL.pdf b/02_activities/assignments/DC_Cohort/DSI_SQL_LOGICAL DATA MODEL.pdf new file mode 100644 index 000000000..367cbffd4 Binary files /dev/null and b/02_activities/assignments/DC_Cohort/DSI_SQL_LOGICAL DATA MODEL.pdf differ diff --git a/02_activities/assignments/DC_Cohort/assignment1.sql b/02_activities/assignments/DC_Cohort/assignment1.sql index c992e3205..9db669cde 100644 --- a/02_activities/assignments/DC_Cohort/assignment1.sql +++ b/02_activities/assignments/DC_Cohort/assignment1.sql @@ -1,20 +1,29 @@ /* ASSIGNMENT 1 */ /* SECTION 2 */ +/* Ayesha Rashidi */ --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 IN (4, 9); /*2. Write a query that returns all customer purchases and a new calculated column 'price' (quantity * cost_to_customer_per_qty), @@ -24,10 +33,17 @@ filtered by customer IDs between 8 and 10 (inclusive) using either: */ -- 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. @@ -35,20 +51,42 @@ 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.” */ +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; /* SECTION 3 */ @@ -64,7 +102,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. */ - +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_purchases as cp +LEFT JOIN customer AS c -- In case there are customer IDs with no names in customer_purchases. +ON cp.customer_id = c.customer_id +GROUP BY cp.customer_id, c.customer_first_name, c.customer_last_name +HAVING total_spent > 2000 +ORDER BY c.customer_last_name,c.customer_first_name; --Temp Table /* 1. Insert the original vendor table into a temp.new_vendor and then add a 10th vendor: @@ -78,6 +125,26 @@ When inserting the new vendor, you need to appropriately align the columns to be VALUES(col1,col2,col3,col4,col5) */ +DROP TABLE IF EXISTS temp.new_vendor; -- If it previously existed, delete it. +CREATE 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, + 'Thomas Superfood Store', + 'Fresh Focused', + 'Thomas', + 'Rosenthal' +); +SELECT * +FROM temp.new_vendor; -- Date