Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions 02_activities/assignments/DC_Cohort/Assignment1.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Checklist:
- [ ] Create a branch called `assignment-one`.
- [ ] Ensure that the repository is public.
- [ ] Review [the PR description guidelines](https://github.com/UofT-DSI/onboarding/blob/main/onboarding_documents/submissions.md#guidelines-for-pull-request-descriptions) and adhere to them.
- [ ] Review [t_cohe PR description guidelines](https://github.com/UofT-DSI/onboarding/blob/main/onboarding_documents/submissions.md#guidelines-for-pull-request-descriptions) and adhere to them.
- [ ] Verify that the link is accessible in a private browser window.

If you encounter any difficulties or have questions, please don't hesitate to reach out to our team via our Slack. Our Technical Facilitators and Learning Support staff are here to help you navigate any challenges.
Expand All @@ -41,7 +41,7 @@ If this is your first time in DB Browser for SQLite, the following instructions
- ![db_browser_for_sqlite_choose_db.png](./images/01_db_browser_for_sqlite_choose_db.png)

#### 2) Configure your windows
By default, DB Browser for SQLite has three windows, with four tabs in the main window and three tabs in the bottom right window
By default, DB Browser for SQLite has three windows, with four tabs in the main window and three tabs in the bottom right windolsw
- Window 1: Main Window (Centre)
- Stay in the Database Structure tab for now
- Window 2: Edit Database Cell (Top Right)
Expand Down Expand Up @@ -207,7 +207,12 @@ Link if you encounter a paywall: https://archive.is/srKHV or https://web.archive

Consider, for example, concepts of fariness, inequality, social structures, marginalization, intersection of technology and society, etc.

I come across these issues every single day as my PhD research engages directly with the issue of biometric identification systems in immigration processes. Specifically, my project examines how DNA testing is used in Canadian immigration processes to verify biological relationships for family reunificaiton applications. While this can be a useful tool for families where documentation of relationships is missing (often seen in conflict or environmental disaster), the use of DNA testing enforces and reproduces a biological notion of family that is not reflective of the social organization of families. Furthermore, requests for DNA testing disproportionately target racialized and lowclass migrants from the Global South, functioning as a tool of exclusion and surveillance.
In this work, I often encounter work that interrogates the use of biometric databases (i.e. fingerprint, iris scans, facial recognition databases) in immigration systems, asking how these systems are used to surveil and exclude migrants. For example, in the context of the EU, the EURODAC database is used to enforce the Dublin regulation which stipulates that a person must claim asylum in the first country in which they arrive. This means that many people seeking to reunite with their families are denied that right. Thousands of people's lives have been uprooted as they are deported from one EU country to another. Using fingerprint matches from the EURODAC databases, Frontex, the EU border enforcement agency, has arrested people while they are in hospital receiving urgent medical care, has uprooted and separated families, and has subjected asylum seekers to horrific acts of violence. Embedded in the logic of the EURODAC database is the idea that some people deserve to move freely, and others do not.

```
Your thoughts...
```
I come across these issues every single day as my PhD research engages directly with the issue of biometric identification systems in immigration processes. Specifically, my project examines how DNA testing is used in Canadian immigration processes to verify biological relationships for family reunificaiton applications. While this can be a useful tool for families where documentation of relationships is missing (often seen in conflict or environmental disaster), the use of DNA testing enforces and reproduces a biological notion of family that is not reflective of the social organization of families. Furthermore, requests for DNA testing disproportionately target racialized and lowclass migrants from the Global South, functioning as a tool of exclusion and surveillance. In this work, I often encounter work that interrogates the use of biometric databases (i.e. fingerprint, iris scans, facial recognition databases) in immigration systems, asking how these systems are used to surveil and exclude migrants. For example, in the context of the EU, the EURODAC database is used to enforce the Dublin regulation which stipulates that a person must claim asylum in the first country in which they arrive. This means that many people seeking to reunite with their families are denied that right. Thousands of people's lives have been uprooted as they are deported from one EU country to another. Using fingerprint matches from the EURODAC databases, Frontex, the EU border enforcement agency, has arrested people while they are in hospital receiving urgent medical care, has uprooted and separated families, and has subjected asylum seekers to horrific acts of violence. Embedded in the logic of the EURODAC database is the idea that some people deserve to move freely, and others do not.


127 changes: 87 additions & 40 deletions 02_activities/assignments/DC_Cohort/assignment1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,31 @@
--SELECT
/* 1. Write a query that returns everything in the customer table. */
--QUERY 1



# SELECT * FROM customer;

--END QUERY


/* 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


--WHERE
/* 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



Expand All @@ -35,10 +40,13 @@ filtered by customer IDs between 8 and 10 (inclusive) using either:
2. one condition using BETWEEN
Limit to 25 rows of output.
*/
--QUERY 3


--QUERY 4

SELECT *,
quantity * cost_to_customer_per_qty AS price
FROM customer_purchases
WHERE customer_id BETWEEN 8 AND 10
LIMIT 25;

--END QUERY

Expand All @@ -48,47 +56,65 @@ Limit to 25 rows of output.
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.” */
--QUERY 4


--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


/* 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. */
--QUERY 5


--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


--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 market_date, then vendor_name.
Limit to 24 rows of output. */
--QUERY 6


--QUERY 7

SELECT *
FROM vendor v
INNER JOIN vendor_booth_assignments vb
ON v.vendor_id = vb.vendor_id
ORDER BY vb.market_date, v.vendor_name
LIMIT 24;

--END QUERY



/* SECTION 3 */

-- 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. */
--QUERY 7



--QUERY 8
SELECT vendor_id,
COUNT(*) AS booth_rentals
FROM vendor_booth_assignments
GROUP BY vendor_id;

--END QUERY

Expand All @@ -98,10 +124,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. */
--QUERY 8



--QUERY 9
SELECT c.customer_id,
c.customer_first_name,
c.customer_last_name,
SUM(p.quantity * p.cost_to_customer_per_qty) AS total_spent
FROM customer c
JOIN customer_purchases p
ON c.customer_id = p.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

Expand All @@ -117,10 +150,15 @@ 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)
*/
--QUERY 9


--QUERY 10
# Part 1
CREATE TEMP TABLE new_vendor AS
SELECT *
FROM vendor;

#Part 2
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

Expand All @@ -131,10 +169,14 @@ 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!
Limit to 25 rows of output. */
--QUERY 10


--QUERY 11

SELECT
customer_id,
strftime('%m', market_date) AS month,
strftime('%Y', market_date) AS year
FROM customer_purchases
LIMIT 25;

--END QUERY

Expand All @@ -145,9 +187,14 @@ 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...
AND be sure you remove the LIMIT from the previous query before aggregating!! */
--QUERY 11



--QUERY 12

SELECT
customer_id,
SUM(quantity * cost_to_customer_per_qty) AS total_spent
FROM customer_purchases
WHERE strftime('%m', market_date) = '04'
AND strftime('%Y', market_date) = '2022'
GROUP BY customer_id;

--END QUERY
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion 03_instructional_team/sqbpro_originals/module_3.sqbpro
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Filter to number of purchases between 300 and 500 */
/* 2. What is the single item that has been bought in the greatest quantity?*/


--------------------------------------------------------------------------------------------------------------------------------------------
</sql><sql name="subquery_where">/* MODULE 3 */
/* Subquery WHERE */

Expand All @@ -122,7 +123,7 @@ Filter to number of purchases between 300 and 500 */
/* some structural code */
/* ...heads up, sometimes this query can be finnicky -- it's good to try highlighting different sections to help it succeed...*/

-- if a table named new_vendor_inventory exists, delete it, other do NOTHING
-- if a table named new_vendor_inventory exists, delete it, otherwise do NOTHING
DROP TABLE IF EXISTS temp.new_vendor_inventory;

--make the table
Expand Down
2 changes: 1 addition & 1 deletion 04_this_cohort/custom_slides/markdown/slides_02.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class: top, left, inverse
---

class: top, left, inverse
### Filtering a FULL (OUTER) JOIN
# Filtering a FULL (OUTER) JOIN
- All OUTER JOIN syntax can be filtered to exclude the _matching_ criteria
- Often called an ANTI JOIN, i.e. what's _not_ in the other table

Expand Down
36 changes: 36 additions & 0 deletions 04_this_cohort/live_code/module_2/CASE.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* MODULE 2 */
/* CASE */


SELECT *
/* 1. Add a CASE statement declaring which days vendors should come */
,CASE WHEN vendor_type = 'Fresh Focused' THEN 'Wednesday'
WHEN vendor_type = 'Eggs & Meats' THEN 'Thursday'
ELSE 'Saturday'
END as day_of_specialty


/* 2. Add another CASE statement for Pie Day */
,CASE WHEN vendor_name = "Annie's Pies" -- double quotes okay here
THEN 'Annie is the best'
END as pi_day


/* 3. Add another CASE statement with an ELSE clause to handle rows evaluating to False */
,CASE WHEN vendor_name LIKE '%pie%'
THEN 'Wendesday'
ELSE 'Friday'
END as another_pie_day

FROM vendor;

/* 4. Experiment with selecting a different column instead of just a string value */

SELECT *
,CASE WHEN cost_to_customer_per_qty < 1.00
THEN cost_to_customer_per_qty*5
ELSE cost_to_customer_per_qty
END AS inflation

FROM customer_purchases
--------------------------------------------------------------------------------------------------------------------------------------------
40 changes: 40 additions & 0 deletions 04_this_cohort/live_code/module_2/DISTINCT.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* MODULE 2 */
/* DISTINCT */


/* 1. Compare how many customer_ids are the customer_purchases table, one select with distinct, one without */

-- 4221 rows
SELECT customer_id FROM customer_purchases ;

SELECT DISTINCT customer_id FROM customer_purchases;



/* 2. Compare the difference between selecting market_day in market_date_info, with and without distinct:
what do these difference mean?*/
SELECT market_day
FROM market_date_info;

-- market is only open on 2 days, wed and sat
SELECT DISTINCT market_day
FROM market_date_info;


/* 3. Which vendor has sold products to a customer */
SELECT DISTINCT vendor_id
FROM customer_purchases;


/* 4. Which vendor has sold products to a customer ... and which product was it */
SELECT DISTINCT vendor_id, product_id
FROM customer_purchases;


/* 5. Which vendor has sold products to a customer
... and which product was it?
... AND to whom was it sold*/
SELECT DISTINCT vendor_id, product_id, customer_id
FROM customer_purchases

--------------------------------------------------------------------------------------------------------------------------------------------
39 changes: 39 additions & 0 deletions 04_this_cohort/live_code/module_2/INNER JOIN.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* MODULE 2 */
/* INNER JOIN */


/* 1. Get product names (from product table) alongside customer_purchases
... use an INNER JOIN to see only products that have been purchased */

-- without table aliases
SELECT product_name, -- coming from the product table
vendor_id, -- rest of these are coming from the customer_purchases table
market_date,
customer_id,
customer_purchases.product_id,
product.product_id

FROM product
INNER JOIN customer_purchases
ON customer_purchases.product_id = product.product_id;



/* 2. Using the Query #5 from DISTINCT earlier
(Which vendor has sold products to a customer AND which product was it AND to whom was it sold)
Add customers' first and last names with an INNER JOIN */

-- using table aliases
SELECT DISTINCT
vendor_id, -- coming from cp
product_id,
c.customer_id, -- coming from c
customer_first_name,
customer_last_name

FROM customer_purchases AS cp
INNER JOIN customer AS c
ON c.customer_id = cp.customer_id

--------------------------------------------------------------------------------------------------------------------------------------------
Loading