From b255d89015a04657241c98269c75250ccc9b704f Mon Sep 17 00:00:00 2001 From: Brigid Goulem Date: Tue, 31 Mar 2026 18:37:11 -0400 Subject: [PATCH 1/8] Wrote section 4 on ethics, responding to the Wired article on biometric databases in Pakistan --- 02_activities/assignments/DC_Cohort/Assignment1.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/02_activities/assignments/DC_Cohort/Assignment1.md b/02_activities/assignments/DC_Cohort/Assignment1.md index f650c9752..70257f581 100644 --- a/02_activities/assignments/DC_Cohort/Assignment1.md +++ b/02_activities/assignments/DC_Cohort/Assignment1.md @@ -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. @@ -207,6 +207,8 @@ 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... From 426d0be81506e3739d547519b4c33c37c518b023 Mon Sep 17 00:00:00 2001 From: Brigid Goulem Date: Tue, 31 Mar 2026 20:42:51 -0400 Subject: [PATCH 2/8] Prompt # 1 has been completed, image of data model has been downloaded and added to assignment file --- .../DC_Cohort/logicaldatamodel_assignment_1.png | Bin 0 -> 17321 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 02_activities/assignments/DC_Cohort/logicaldatamodel_assignment_1.png diff --git a/02_activities/assignments/DC_Cohort/logicaldatamodel_assignment_1.png b/02_activities/assignments/DC_Cohort/logicaldatamodel_assignment_1.png new file mode 100644 index 0000000000000000000000000000000000000000..c8961115002e6f72429c344c5b696977e163aa10 GIT binary patch literal 17321 zcmd741z45Qwl<2ekOfF1EgdSg=>28*EH;90Mba$5^p@4KtcOyurv~?qF!`$Yf*c z1QgM*NzgzzC2M1f%e{E)F zYxQSxf7;jq^Zpmstz@AviRMWo8!;$V6CN1q2?BUduDc5Sw-Na0-U~Bz%9sl%0!z%fI|K0ys z4F^-3KU4XCB92Yo-9<{?)ZE!Zg~NeS!bsBITI{cO*%|($k3ZcyI=TN{ZwFgv8xvF5 z9s!yv>S_UXGF7oNG=}YlE1+ONnT3 z-_{x%I+>c=I=KJp=YJjTUlI0B?)pydc7Pbz$#5}sa5DXK%zmxo|6XDKp*B*cw$`Rj z4(@;qi+@&KSPPh7*MI0a%ipp;{qX#0^5-zKvj6$r@XskT{}0hHLH`p?1ls&j3{r=y|bZ>6V&N{K1yI#u<5~$#BWvoZ-@0)gMXhQ z$$y-p|MpE=2dFvJ#?VUN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7)eY(3>8F@>enkEczSr?CG`MXo_!Xe zqjy+-KgPk7n4*rLmZ~2Pzx!^zAqNV4>>@wHt}-)Fy--yxE|yk(Oz>(Fj^O0!PV}uW p@c(Sw-)GZ33j`h>!Y~g4T(0D&4G2;vJWv8BBcUi>CTj5Z{{og17j^&u literal 0 HcmV?d00001 From 28501a4a6c1df00eac923e87b4d2ff98720702fa Mon Sep 17 00:00:00 2001 From: Brigid Goulem Date: Wed, 1 Apr 2026 12:59:28 -0400 Subject: [PATCH 3/8] parts 2 and 3 completed --- 05_src/sql/assignment1.sql | 153 +++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 05_src/sql/assignment1.sql diff --git a/05_src/sql/assignment1.sql b/05_src/sql/assignment1.sql new file mode 100644 index 000000000..a6070558c --- /dev/null +++ b/05_src/sql/assignment1.sql @@ -0,0 +1,153 @@ + /* ASSIGNMENT 1 */ +--Please write responses between the QUERY # and END QUERY blocks +/* SECTION 2 */ + + +--SELECT +/* 1. Write a query that returns everything in the customer table. */ +--QUERY 1 + + + + +--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 + + + + +--END QUERY + + +--WHERE +/* 1. Write a query that returns all customer purchases of product IDs 4 and 9. +Limit to 25 rows of output. */ + + + +/*2. Write a query that returns all customer purchases and a new calculated column 'price' (quantity * cost_to_customer_per_qty), +filtered by customer IDs between 8 and 10 (inclusive) using either: + 1. two conditions using AND + 2. one condition using BETWEEN +Limit to 25 rows of output. +*/ +--QUERY 3 + + + + +--END QUERY + + +--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.” */ +--QUERY 4 + + + + +--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 + + + + +--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 + + + + +--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 + + + + +--END QUERY + + +/* 2. The Farmer’s Market Customer Appreciation Committee wants to give a bumper +sticker to everyone who has ever spent more than $2000 at the market. Write a query that generates a list +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 + + + + +--END QUERY + + +--Temp Table +/* 1. Insert the original vendor table into a temp.new_vendor and then add a 10th vendor: +Thomass Superfood Store, a Fresh Focused store, owned by Thomas Rosenthal + +HINT: This is two total queries -- first create the table from the original, then insert the new 10th vendor. +When inserting the new vendor, you need to appropriately align the columns to be inserted +(there are five columns to be inserted, I've given you the details, but not the syntax) + +-> To insert the new row use VALUES, specifying the value you want for each column: +VALUES(col1,col2,col3,col4,col5) +*/ +--QUERY 9 + + + + +--END QUERY + + +-- 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 +and year are! +Limit to 25 rows of output. */ +--QUERY 10 + + + + +--END QUERY + + +/* 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. + +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 + + + + +--END QUERY From 3cbd3b159b5f2aeaa153c1ced9967c356004af32 Mon Sep 17 00:00:00 2001 From: Brigid Goulem Date: Wed, 1 Apr 2026 13:01:36 -0400 Subject: [PATCH 4/8] Add Assignment1.md --- 05_src/sql/Assignment1.md | 215 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 05_src/sql/Assignment1.md diff --git a/05_src/sql/Assignment1.md b/05_src/sql/Assignment1.md new file mode 100644 index 000000000..70257f581 --- /dev/null +++ b/05_src/sql/Assignment1.md @@ -0,0 +1,215 @@ +# DC Assignment 1: Meet the farmersmarket.db and Basic SQL + +🚨 **Please review our [Assignment Submission Guide](https://github.com/UofT-DSI/onboarding/blob/main/onboarding_documents/submissions.md)** 🚨 for detailed instructions on how to format, branch, and submit your work. Following these guidelines is crucial for your submissions to be evaluated correctly. + +#### Submission Parameters: +* Submission Due Date: `March 31, 2026` +* Weight: 30% of total grade +* The branch name for your repo should be: `assignment-one` +* What to submit for this assignment: + * This markdown (Assignment1.md) with written responses in Section 4 + * One Entity-Relationship Diagram (preferably in a pdf, jpeg, png format). + * One .sql file +* What the pull request link should look like for this assignment: `https://github.com//sql/pulls/` + * Open a private window in your browser. Copy and paste the link to your pull request into the address bar. Make sure you can see your pull request properly. This helps the technical facilitator and learning support staff review your submission easily. + +Checklist: +- [ ] Create a branch called `assignment-one`. +- [ ] Ensure that the repository is public. +- [ ] 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. + +*** + +## Section 1: +You can start this section following *session 1*. + +Steps to complete this part of the assignment: +- Load the farmersmarket.db and browse its content +- Create a logical data model + +
+If this is your first time in DB Browser for SQLite, the following instructions may help: + +#### 1) Load Database +- Open DB Browser for SQLite +- Go to File > Open Database +- Navigate to your farmersmarket.db + - This will be wherever you cloned the GH Repo (within the **05_src/sql** folder) + - ![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 +- Window 1: Main Window (Centre) + - Stay in the Database Structure tab for now +- Window 2: Edit Database Cell (Top Right) +- Window 3: Remote (Bottom Right) + - Switch this to DB Schema tab (very bottom) + +Your screen should look like this (or very similar) +![db_browser_for_sqlite.png](./images/01_db_browser_for_sqlite.png) + +#### 3) The farmersmarket.db +There are 10 tables in the Main Window: +1) booth +2) customer +3) customer_purchases +4) market_date_info +5) product +6) product_category +7) vendor +8) vendor_booth_assignments +9) vendor_inventory +10) postal_data + +Switch to the Browse Data tab, booth is selected by default + + + + +Using the table drop down at the top left, explore some of the contents of the database + + + +Move on to the Logical Data Model task when you have looked through the tables + + +### Build Logical Data Model + +Recall during session 1: + +I diagramed the following four tables: +- product +- product_category +- vendor +- vendor_inventory + + + + +#### Prompt 1: +Choose two tables and create a logical data model. There are lots of tools you can do this (including drawing this by hand), but I'd recommend [Draw.io](https://www.drawio.com/) or [LucidChart](https://www.lucidchart.com/pages/). + +A logical data model must contain: +- table name +- column names +- relationship type + +Please do not pick the exact same tables that I have already diagrammed. For example, you shouldn't diagram the relationship between `product` and `product_category`, but you could diagram `product` and `customer_purchases`. + +**HINTS**: +- You will need to use the Browse Data tab in the main window to figure out the relationship types. +- You can't diagram tables that don't share a common column + - These are the tables that are connected + - +- 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: +You can start this section following *session 2*. + +Steps to complete this part of the assignment: +- Open the assignment1.sql file in DB Browser for SQLite: + - from [Github](./02_activities/assignments/assignment1.sql) + - or, from your local forked repository +- Complete each question, by writing responses between the QUERY # and END QUERY blocks + +### Write SQL + +#### SELECT +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. + +
-
+ +#### WHERE +1. Write a query that returns all customer purchases of product IDs 4 and 9. Limit to 25 rows of output. +2. Write a query that returns all customer purchases and a new calculated column 'price' (quantity * cost_to_customer_per_qty), filtered by customer IDs between 8 and 10 (inclusive) using either: + 1. two conditions using AND + 2. one condition using BETWEEN +Limit to 25 rows of output. + +
-
+ +#### 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.” + +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. + +
-
+ +#### 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 `market_date` then `vendor_name`. Limit to 24 rows of output. + +*** + +## Section 3: +You can start this section following *session 3*. + +Steps to complete this part of the assignment: +- Open the assignment1.sql file in DB Browser for SQLite: + - from [Github](./02_activities/assignments/assignment1.sql) + - or, from your local forked repository +- Complete each question, by writing responses between the QUERY # and END QUERY blocks + +### Write SQL + +#### 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`. +2. The Farmer’s Market Customer Appreciation Committee wants to give a bumper sticker to everyone who has ever spent more than $2000 at the market. Write a query that generates a list 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. + +
-
+ +#### Temp Table +1. Insert the original vendor table into a temp.new_vendor and then add a 10th vendor: Thomass Superfood Store, a Fresh Focused store, owned by Thomas Rosenthal + +**HINT**: This is two total queries -- first create the table from the original, then insert the new 10th vendor. When inserting the new vendor, you need to appropriately align the columns to be inserted (there are five columns to be inserted, I've given you the details, but not the syntax) + +To insert the new row use VALUES, specifying the value you want for each column: +`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 and year are! + +Limit to 25 rows of output. + +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`. + +**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!! + +*** + +## Section 4: +You can start this section anytime. + +Steps to complete this part of the assignment: +- Read the article +- Write, within this markdown file, between 250 and 1000 words. No additional citations/sources are required. + +### Ethics + +Read: Qadri, R. (2021, November 11). _When Databases Get to Define Family._ Wired.
+ https://www.wired.com/story/pakistan-digital-database-family-design/ + +Link if you encounter a paywall: https://archive.is/srKHV or https://web.archive.org/web/20240422105834/https://www.wired.com/story/pakistan-digital-database-family-design/ + +**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. + +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... +``` From 2aec717d0408830e65d024ebbcacfecbadd712a7 Mon Sep 17 00:00:00 2001 From: "CODE, POTATO" Date: Wed, 25 Mar 2026 11:22:10 -0400 Subject: [PATCH 5/8] QUERY marker missing in question WHERE 1 --- .../assignments/DC_Cohort/assignment1.sql | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/02_activities/assignments/DC_Cohort/assignment1.sql b/02_activities/assignments/DC_Cohort/assignment1.sql index a6070558c..2ec561e2a 100644 --- a/02_activities/assignments/DC_Cohort/assignment1.sql +++ b/02_activities/assignments/DC_Cohort/assignment1.sql @@ -26,6 +26,12 @@ sorted by customer_last_name, then customer_first_ name. */ --WHERE /* 1. Write a query that returns all customer purchases of product IDs 4 and 9. Limit to 25 rows of output. */ +--QUERY 3 + + + + +--END QUERY @@ -35,7 +41,7 @@ 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 @@ -48,7 +54,7 @@ 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 @@ -59,7 +65,7 @@ if the product_qty_type is “unit,” and otherwise displays the word “bulk. /* 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 @@ -71,7 +77,7 @@ contains the word “pepper” (regardless of capitalization), and otherwise out /* 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 @@ -85,7 +91,7 @@ Limit to 24 rows of output. */ -- 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 @@ -98,7 +104,7 @@ 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 @@ -117,7 +123,7 @@ 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 @@ -131,7 +137,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! Limit to 25 rows of output. */ ---QUERY 10 +--QUERY 11 @@ -145,7 +151,7 @@ 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 From aaabf6059ac12a3d015d6bc050adc54c05f46324 Mon Sep 17 00:00:00 2001 From: "CODE, POTATO" Date: Wed, 25 Mar 2026 17:46:09 -0400 Subject: [PATCH 6/8] live code session 2! --- 04_this_cohort/live_code/module_2/CASE.sql | 36 ++++ .../live_code/module_2/DISTINCT.sql | 40 +++++ .../live_code/module_2/INNER JOIN.sql | 39 +++++ .../live_code/module_2/LEFT_JOIN.sql | 64 +++++++ 04_this_cohort/live_code/module_2/SELECT.sql | 29 ++++ 04_this_cohort/live_code/module_2/WHERE.sql | 46 +++++ .../live_code/module_2/module_2.sqbpro | 158 ++++++++++++++---- 7 files changed, 376 insertions(+), 36 deletions(-) create mode 100644 04_this_cohort/live_code/module_2/CASE.sql create mode 100644 04_this_cohort/live_code/module_2/DISTINCT.sql create mode 100644 04_this_cohort/live_code/module_2/INNER JOIN.sql create mode 100644 04_this_cohort/live_code/module_2/LEFT_JOIN.sql create mode 100644 04_this_cohort/live_code/module_2/SELECT.sql create mode 100644 04_this_cohort/live_code/module_2/WHERE.sql diff --git a/04_this_cohort/live_code/module_2/CASE.sql b/04_this_cohort/live_code/module_2/CASE.sql new file mode 100644 index 000000000..fb163f88e --- /dev/null +++ b/04_this_cohort/live_code/module_2/CASE.sql @@ -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 +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_2/DISTINCT.sql b/04_this_cohort/live_code/module_2/DISTINCT.sql new file mode 100644 index 000000000..41e229dbb --- /dev/null +++ b/04_this_cohort/live_code/module_2/DISTINCT.sql @@ -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 + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_2/INNER JOIN.sql b/04_this_cohort/live_code/module_2/INNER JOIN.sql new file mode 100644 index 000000000..03a56d823 --- /dev/null +++ b/04_this_cohort/live_code/module_2/INNER JOIN.sql @@ -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 + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_2/LEFT_JOIN.sql b/04_this_cohort/live_code/module_2/LEFT_JOIN.sql new file mode 100644 index 000000000..9952cdeb2 --- /dev/null +++ b/04_this_cohort/live_code/module_2/LEFT_JOIN.sql @@ -0,0 +1,64 @@ +/* MODULE 2 */ +/* LEFT JOIN */ + + +/* 1. There are products that have been bought +... but are there products that have not been bought? +Use a LEFT JOIN to find out*/ +SELECT DISTINCT +p.product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id; + + +/* 2. Directions of LEFT JOINs matter ...*/ +SELECT DISTINCT +p.product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM customer_purchases as cp +LEFT JOIN product as p + ON p.product_id = cp.product_id; + + + +/* 3. As do which values you filter on ... */ +SELECT DISTINCT +p.product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id + +WHERE p.product_id BETWEEN 1 AND 6 -- if we pick product, 6 rows (1-6) but if we pick cp....only 5 rows because zinnias never existed in customer purchases table + + + +/* 4. Without using a RIGHT JOIN, make this query return the RIGHT JOIN result set +...**Hint, flip the order of the joins** ... + +SELECT * + +FROM product_category AS pc +LEFT JOIN product AS p + ON pc.product_category_id = p.product_category_id + ORDER by pc.product_category_id + +...Note how the row count changed from 24 to 23 +*/ + +SELECT * +FROM product as p +LEFT JOIN product_category as pc + ON pc.product_category_id = p.product_category_id + ORDER by pc.product_category_id + + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_2/SELECT.sql b/04_this_cohort/live_code/module_2/SELECT.sql new file mode 100644 index 000000000..c721bc9b5 --- /dev/null +++ b/04_this_cohort/live_code/module_2/SELECT.sql @@ -0,0 +1,29 @@ +/* MODULE 2 */ +/* SELECT */ + + +/* 1. Select everything in the customer table */ +SELECT * FROM customer; + +/* 2. Use sql as a calculator */ +SELECT 1+1 AS addition, 10*5 as multiplication, pi() as pi; + + +/* 3. Add order by and limit clauses */ +SELECT * +FROM customer +ORDER BY customer_first_name +LIMIT 10; + + +/* 4. Select multiple specific columns */ +SELECT customer_first_name,customer_last_name +FROM customer; + + + +/* 5. Add a static value in a column */ +SELECT 2026 as this_year, 'March' as this_month, customer_id +FROM customer + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_2/WHERE.sql b/04_this_cohort/live_code/module_2/WHERE.sql new file mode 100644 index 000000000..5952dc753 --- /dev/null +++ b/04_this_cohort/live_code/module_2/WHERE.sql @@ -0,0 +1,46 @@ +/* MODULE 2 */ +/* WHERE */ + +/* 1. Select only customer 1 from the customer table */ +SELECT * +FROM customer +WHERE customer_id = 1; + + +/* 2. Differentiate between AND and OR */ +SELECT * +FROM customer +WHERE customer_id = 1 +OR customer_id = 2; -- OR is two rows, AND is 0 rows + + +/* 3. IN */ +SELECT * +FROM customer +WHERE customer_id IN (3,4,5,6); + + +/* 4. LIKE */ +-- all the peppers +SELECT * FROM product +WHERE product_name LIKE '%pepper%'; + + +/* 5. Nulls and Blanks*/ +SELECT * +FROM product +WHERE product_size IS NULL -- null +OR product_size = ''; -- blank, two single quotes not one double quote, different from NULL + + +/* 6. BETWEEN x AND y */ +SELECT * +FROM customer +WHERE customer_id BETWEEN 1 AND 20; +--dates + +SELECT * +FROM market_date_info +WHERE market_date BETWEEN '2022-10-01' AND '2022-10-31' + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_2/module_2.sqbpro b/04_this_cohort/live_code/module_2/module_2.sqbpro index 06850fe25..bea7c751f 100644 --- a/04_this_cohort/live_code/module_2/module_2.sqbpro +++ b/04_this_cohort/live_code/module_2/module_2.sqbpro @@ -1,109 +1,151 @@ -
/* MODULE 2 */ +/* MODULE 2 */ /* SELECT */ /* 1. Select everything in the customer table */ -SELECT +SELECT * FROM customer; /* 2. Use sql as a calculator */ - +SELECT 1+1 AS addition, 10*5 as multiplication, pi() as pi; /* 3. Add order by and limit clauses */ - +SELECT * +FROM customer +ORDER BY customer_first_name +LIMIT 10; /* 4. Select multiple specific columns */ +SELECT customer_first_name,customer_last_name +FROM customer; /* 5. Add a static value in a column */ +SELECT 2026 as this_year, 'March' as this_month, customer_id +FROM customer - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +--------------------------------------------------------------------------------------------------------------------------------------------/* MODULE 2 */ /* WHERE */ /* 1. Select only customer 1 from the customer table */ SELECT * FROM customer -WHERE +WHERE customer_id = 1; /* 2. Differentiate between AND and OR */ - +SELECT * +FROM customer +WHERE customer_id = 1 +OR customer_id = 2; -- OR is two rows, AND is 0 rows /* 3. IN */ - +SELECT * +FROM customer +WHERE customer_id IN (3,4,5,6); /* 4. LIKE */ - +-- all the peppers +SELECT * FROM product +WHERE product_name LIKE '%pepper%'; /* 5. Nulls and Blanks*/ - +SELECT * +FROM product +WHERE product_size IS NULL -- null +OR product_size = ''; -- blank, two single quotes not one double quote, different from NULL /* 6. BETWEEN x AND y */ +SELECT * +FROM customer +WHERE customer_id BETWEEN 1 AND 20; +--dates +SELECT * +FROM market_date_info +WHERE market_date BETWEEN '2022-10-01' AND '2022-10-31' --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +--------------------------------------------------------------------------------------------------------------------------------------------/* 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 vendor - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +FROM customer_purchases +--------------------------------------------------------------------------------------------------------------------------------------------/* 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 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 - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +--------------------------------------------------------------------------------------------------------------------------------------------/* MODULE 2 */ /* INNER JOIN */ @@ -111,36 +153,76 @@ SELECT customer_id FROM 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 #4 from DISTINCT earlier +/* 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 - - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +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 + +--------------------------------------------------------------------------------------------------------------------------------------------/* MODULE 2 */ /* LEFT JOIN */ /* 1. There are products that have been bought ... but are there products that have not been bought? Use a LEFT JOIN to find out*/ +SELECT DISTINCT +p.product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id; /* 2. Directions of LEFT JOINs matter ...*/ +SELECT DISTINCT +p.product_id +,cp.product_id as [cp.product_id] +,product_name +FROM customer_purchases as cp +LEFT JOIN product as p + ON p.product_id = cp.product_id; /* 3. As do which values you filter on ... */ +SELECT DISTINCT +p.product_id +,cp.product_id as [cp.product_id] +,product_name +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id + +WHERE p.product_id BETWEEN 1 AND 6 -- if we pick product, 6 rows (1-6) but if we pick cp....only 5 rows because zinnias never existed in customer purchases table @@ -157,10 +239,14 @@ LEFT JOIN product AS p ...Note how the row count changed from 24 to 23 */ +SELECT * +FROM product as p +LEFT JOIN product_category as pc + ON pc.product_category_id = p.product_category_id + ORDER by pc.product_category_id --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +--------------------------------------------------------------------------------------------------------------------------------------------/* MODULE 2 */ /* Multiple Table JOINs */ @@ -176,4 +262,4 @@ LEFT JOIN product AS p Why do we have more rows now?*/ - + From b57b7b1b4bbaee8d150b6598fe02e642bcb2dee2 Mon Sep 17 00:00:00 2001 From: "CODE, POTATO" Date: Mon, 30 Mar 2026 17:33:19 -0400 Subject: [PATCH 7/8] day 3 live coding! --- .../sqbpro_originals/module_3.sqbpro | 3 +- .../custom_slides/markdown/slides_02.Rmd | 2 +- .../module_2/MULTIPLE_TABLE_JOINS.sql | 45 ++++ .../live_code/module_2/module_2.sqbpro | 30 +++ .../live_code/module_3/Arithmitic.sql | 19 ++ 04_this_cohort/live_code/module_3/COUNT.sql | 28 +++ 04_this_cohort/live_code/module_3/HAVING.sql | 28 +++ 04_this_cohort/live_code/module_3/MIN_MAX.sql | 58 +++++ 04_this_cohort/live_code/module_3/SUM_AVG.sql | 26 +++ .../live_code/module_3/Subquery_FROM.sql | 40 ++++ .../live_code/module_3/Subquery_WHERE.sql | 40 ++++ .../live_code/module_3/Temp_Tables.sql | 38 ++++ .../live_code/module_3/module_3.sqbpro | 199 +++++++++++++++--- 13 files changed, 525 insertions(+), 31 deletions(-) create mode 100644 04_this_cohort/live_code/module_2/MULTIPLE_TABLE_JOINS.sql create mode 100644 04_this_cohort/live_code/module_3/Arithmitic.sql create mode 100644 04_this_cohort/live_code/module_3/COUNT.sql create mode 100644 04_this_cohort/live_code/module_3/HAVING.sql create mode 100644 04_this_cohort/live_code/module_3/MIN_MAX.sql create mode 100644 04_this_cohort/live_code/module_3/SUM_AVG.sql create mode 100644 04_this_cohort/live_code/module_3/Subquery_FROM.sql create mode 100644 04_this_cohort/live_code/module_3/Subquery_WHERE.sql create mode 100644 04_this_cohort/live_code/module_3/Temp_Tables.sql diff --git a/03_instructional_team/sqbpro_originals/module_3.sqbpro b/03_instructional_team/sqbpro_originals/module_3.sqbpro index b580defc7..35cd56eb0 100644 --- a/03_instructional_team/sqbpro_originals/module_3.sqbpro +++ b/03_instructional_team/sqbpro_originals/module_3.sqbpro @@ -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?*/ +-------------------------------------------------------------------------------------------------------------------------------------------- /* MODULE 3 */ /* Subquery WHERE */ @@ -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 diff --git a/04_this_cohort/custom_slides/markdown/slides_02.Rmd b/04_this_cohort/custom_slides/markdown/slides_02.Rmd index ee9110c8d..8448d59d6 100644 --- a/04_this_cohort/custom_slides/markdown/slides_02.Rmd +++ b/04_this_cohort/custom_slides/markdown/slides_02.Rmd @@ -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 diff --git a/04_this_cohort/live_code/module_2/MULTIPLE_TABLE_JOINS.sql b/04_this_cohort/live_code/module_2/MULTIPLE_TABLE_JOINS.sql new file mode 100644 index 000000000..1fd765dc0 --- /dev/null +++ b/04_this_cohort/live_code/module_2/MULTIPLE_TABLE_JOINS.sql @@ -0,0 +1,45 @@ +/* MODULE 2 */ +/* Multiple Table JOINs */ + + +/* 1. Using the Query #4 from DISTINCT earlier + (Which vendor has sold products to a customer AND which product was it AND to whom was it sold) + + Replace all the IDs (customer, vendor, and product) with the names instead*/ +SELECT DISTINCT +--vendor_id +vendor_name +,p.product_id +,product_name +,c.customer_id +,customer_first_name +,customer_last_name +FROM customer_purchases as cp +INNER JOIN vendor as v + ON v.vendor_id = cp.vendor_id +INNER JOIN product as p + ON p.product_id = cp.product_id +INNER JOIN customer as c + ON c.customer_id = cp.customer_id; + + + +/* 2. Select product_category_name, everything from the product table, and then LEFT JOIN the customer_purchases table +... how does this LEFT JOIN affect the number of rows? + +Why do we have more rows now?*/ +SELECT product_category_name, p.* +, cp.product_id as productid_in_cust_purchases_table + +FROM product_category as pc +INNER JOIN product as p -- will give us product_name, product_size, product_qty_type + ON p.product_category_id = pc.product_category_id +LEFT JOIN customer_purchases as cp + ON cp.product_id = p.product_id + + +ORDER by cp.product_id + + + +-------------------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/04_this_cohort/live_code/module_2/module_2.sqbpro b/04_this_cohort/live_code/module_2/module_2.sqbpro index bea7c751f..a9e018190 100644 --- a/04_this_cohort/live_code/module_2/module_2.sqbpro +++ b/04_this_cohort/live_code/module_2/module_2.sqbpro @@ -254,6 +254,21 @@ LEFT JOIN product_category as pc (Which vendor has sold products to a customer AND which product was it AND to whom was it sold) Replace all the IDs (customer, vendor, and product) with the names instead*/ +SELECT DISTINCT +--vendor_id +vendor_name +,p.product_id +,product_name +,c.customer_id +,customer_first_name +,customer_last_name +FROM customer_purchases as cp +INNER JOIN vendor as v + ON v.vendor_id = cp.vendor_id +INNER JOIN product as p + ON p.product_id = cp.product_id +INNER JOIN customer as c + ON c.customer_id = cp.customer_id; @@ -261,5 +276,20 @@ LEFT JOIN product_category as pc ... how does this LEFT JOIN affect the number of rows? Why do we have more rows now?*/ +SELECT product_category_name, p.* +, cp.product_id as productid_in_cust_purchases_table + +FROM product_category as pc +INNER JOIN product as p -- will give us product_name, product_size, product_qty_type + ON p.product_category_id = pc.product_category_id +LEFT JOIN customer_purchases as cp + ON cp.product_id = p.product_id + + +ORDER by cp.product_id + + + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_3/Arithmitic.sql b/04_this_cohort/live_code/module_3/Arithmitic.sql new file mode 100644 index 000000000..c0c6c021c --- /dev/null +++ b/04_this_cohort/live_code/module_3/Arithmitic.sql @@ -0,0 +1,19 @@ +/* MODULE 3 */ +/* Arithmitic */ + + +/* 1. power, pi(), ceiling, division, integer division, etc */ +SELECT power(4,2), pi(); + +SELECT 10.0 / 3.0 as division, +CAST(10.0 as INT) / CAST(3.0 as INT) as integer_division; + +/* 2. Every even vendor_id with modulo */ +SELECT * FROM vendor +WHERE vendor_id % 2 = 0; + +/* 3. What about every third? */ +SELECT * FROM vendor +WHERE vendor_id % 3 = 0; + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_3/COUNT.sql b/04_this_cohort/live_code/module_3/COUNT.sql new file mode 100644 index 000000000..d00237aa1 --- /dev/null +++ b/04_this_cohort/live_code/module_3/COUNT.sql @@ -0,0 +1,28 @@ +/* MODULE 3 */ +/* COUNT */ + + +/* 1. Count the number of products */ + SELECT COUNT(product_id) as num_of_products + FROM product; + + +/* 2. How many products per product_qty_type */ +SELECT product_qty_type, COUNT(product_id) as num_of_products +FROM product +GROUP BY product_qty_type; + + +/* 3. How many products per product_qty_type and per their product_size */ +SELECT product_size +,product_qty_type, +COUNT(product_id) as num_of_products +FROM product +GROUP BY product_size, product_qty_type; + + +/* COUNT DISTINCT + 4. How many unique products were bought */ + SELECT COUNT(DISTINCT product_id) as bought_products + FROM customer_purchases; + \ No newline at end of file diff --git a/04_this_cohort/live_code/module_3/HAVING.sql b/04_this_cohort/live_code/module_3/HAVING.sql new file mode 100644 index 000000000..ba28befc0 --- /dev/null +++ b/04_this_cohort/live_code/module_3/HAVING.sql @@ -0,0 +1,28 @@ +/* MODULE 3 */ +/* HAVING */ + + +/* 1. How much did a customer spend on each day? +Filter to customer_id between 1 and 5 and total_spend > 50 +... What order of execution occurs?*/ +SELECT +market_date +,customer_id +,SUM(quantity*cost_to_customer_per_qty) as total_spend + +FROM customer_purchases +WHERE customer_id BETWEEN 1 AND 5 +GROUP BY market_date, customer_id +HAVING total_spend > 50; + + +/* 2. How many products were bought? +Filter to number of purchases between 300 and 500 */ +SELECT count(product_id) as num_of_prod +,product_id +FROM customer_purchases +GROUP BY product_id +HAVING count(product_id) BETWEEN 300 AND 500 -- the same as putting "num_of_prod" but not all versions accept + + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_3/MIN_MAX.sql b/04_this_cohort/live_code/module_3/MIN_MAX.sql new file mode 100644 index 000000000..f212a66ff --- /dev/null +++ b/04_this_cohort/live_code/module_3/MIN_MAX.sql @@ -0,0 +1,58 @@ +/* MODULE 3 */ +/* MIN & MAX */ + + +/* 1. What is the most expensive product +...pay attention to how it doesn't handle ties very well +*/ +SELECT product_name, max(original_price) as most_expensive +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id; + + +/* 2. Prove that max is working */ +SELECT DISTINCT +product_name, +original_price +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +ORDER BY original_price DESC; + +/* 3. Find the minimum price per each product_qty_type */ +SELECT product_name +,product_qty_type +,MIN(original_price) + +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +GROUP BY product_qty_type + + + +/* 4. Prove that min is working */ +SELECT DISTINCT + product_name +,product_qty_type +--,MIN(original_price); +,original_price + +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +ORDER BY product_qty_type, original_price; + + + +/* 5. Min/max on a string +... not particularly useful? */ +SELECT max(product_name) +FROM product; + + +-------------------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/04_this_cohort/live_code/module_3/SUM_AVG.sql b/04_this_cohort/live_code/module_3/SUM_AVG.sql new file mode 100644 index 000000000..43b8af6ed --- /dev/null +++ b/04_this_cohort/live_code/module_3/SUM_AVG.sql @@ -0,0 +1,26 @@ +/* MODULE 3 */ +/* SUM & AVG */ + + +/* 1. How much did customers spend each (per) day */ +SELECT +market_date +,customer_id +,SUM(quantity*cost_to_customer_per_qty) as total_spend + +FROM customer_purchases +GROUP BY market_date, customer_id; + +/* 2. How much does each customer spend on average */ +SELECT +customer_first_name +,customer_last_name +,ROUND(AVG(quantity*cost_to_customer_per_qty),2) as avg_spend + +FROM customer_purchases as cp +INNER JOIN customer as c + ON c.customer_id = cp.customer_id + +GROUP BY c.customer_id + +-------------------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/04_this_cohort/live_code/module_3/Subquery_FROM.sql b/04_this_cohort/live_code/module_3/Subquery_FROM.sql new file mode 100644 index 000000000..d48d967d5 --- /dev/null +++ b/04_this_cohort/live_code/module_3/Subquery_FROM.sql @@ -0,0 +1,40 @@ +/* MODULE 3 */ +/* Subquery FROM */ + + +/*1. Simple subquery in a FROM statement, e.g. for inflation +...we could imagine joining this to a more complex query perhaps */ +SELECT DISTINCT +product_id +,inflation + +FROM ( + SELECT product_id, cost_to_customer_per_qty, + 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 +); + + +/* 2. What is the single item that has been bought in the greatest quantity?*/ +--outer QUERY +SELECT product_name -- coming from product table +,MAX(quantity_purchased) -- coming from the subquery ("x") + +FROM product AS p +INNER JOIN ( +--inner query + SELECT product_id + ,count(quantity) as quantity_purchased + + FROM customer_purchases + GROUP BY product_id +) AS x ON p.product_id = x.product_id + + + + +-------------------------------------------------------------------------------------------------------------------------------------------- + + diff --git a/04_this_cohort/live_code/module_3/Subquery_WHERE.sql b/04_this_cohort/live_code/module_3/Subquery_WHERE.sql new file mode 100644 index 000000000..596003157 --- /dev/null +++ b/04_this_cohort/live_code/module_3/Subquery_WHERE.sql @@ -0,0 +1,40 @@ +/* MODULE 3 */ +/* Subquery WHERE */ + + +/* 1. How much did each customer spend at each vendor for each day at the market WHEN IT RAINS */ +SELECT market_date +,customer_id +,vendor_id +,SUM(quantity*cost_to_customer_per_qty) as total_spent + +FROM customer_purchases + +-- filter by rain_flag +-- "what dates was it raining?" +WHERE market_date IN +( + SELECT market_date + FROM market_date_info + WHERE market_rain_flag = 1 +) + +GROUP BY market_date,vendor_id, customer_id + + +/* 2. What is the name of the vendor who sells pie */ + +SELECT DISTINCT vendor_name + +FROM customer_purchases as cp +INNER JOIN vendor as v + ON cp.vendor_id = v.vendor_id + +WHERE product_id IN ( + SELECT product_id + FROM product + WHERE product_name LIKE '%pie%' + ) + + +-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/04_this_cohort/live_code/module_3/Temp_Tables.sql b/04_this_cohort/live_code/module_3/Temp_Tables.sql new file mode 100644 index 000000000..248d6a30d --- /dev/null +++ b/04_this_cohort/live_code/module_3/Temp_Tables.sql @@ -0,0 +1,38 @@ +/* MODULE 3 */ +/* Temp Tables */ + + +/* 1. Put our inflation query into a temp table, e.g. as temp.new_vendor_inventory*/ + +/* 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, otherwise do NOTHING +DROP TABLE IF EXISTS temp.new_vendor_inventory; + +--make the table +CREATE TABLE temp.new_vendor_inventory AS + +-- definition of the table +SELECT *, +original_price*5 as inflation +FROM vendor_inventory + + + + + +/* 2. put the previous table into another temp table, e.g. as temp.new_new_vendor_inventory */ + +DROP TABLE IF EXISTS temp.new_new_vendor_inventory; +CREATE TABLE temp.new_new_vendor_inventory AS + +SELECT * +,inflation * 2 as super_inflation +FROM temp.new_vendor_inventory + + + +-------------------------------------------------------------------------------------------------------------------------------------------- + +SELECT * FROM temp.new_new_vendor_inventory diff --git a/04_this_cohort/live_code/module_3/module_3.sqbpro b/04_this_cohort/live_code/module_3/module_3.sqbpro index b580defc7..2e6377e23 100644 --- a/04_this_cohort/live_code/module_3/module_3.sqbpro +++ b/04_this_cohort/live_code/module_3/module_3.sqbpro @@ -1,119 +1,240 @@ -
/* MODULE 3 */ +
/* MODULE 3 */ /* COUNT */ /* 1. Count the number of products */ - + SELECT COUNT(product_id) as num_of_products + FROM product; /* 2. How many products per product_qty_type */ - +SELECT product_qty_type, COUNT(product_id) as num_of_products +FROM product +GROUP BY product_qty_type; /* 3. How many products per product_qty_type and per their product_size */ - +SELECT product_size +,product_qty_type, +COUNT(product_id) as num_of_products +FROM product +GROUP BY product_size, product_qty_type; /* COUNT DISTINCT 4. How many unique products were bought */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ + SELECT COUNT(DISTINCT product_id) as bought_products + FROM customer_purchases; + /* MODULE 3 */ /* SUM & AVG */ -/* 1. How much did customers spend each day */ +/* 1. How much did customers spend each (per) day */ +SELECT +market_date +,customer_id +,SUM(quantity*cost_to_customer_per_qty) as total_spend - +FROM customer_purchases +GROUP BY market_date, customer_id; /* 2. How much does each customer spend on average */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ +SELECT +customer_first_name +,customer_last_name +,ROUND(AVG(quantity*cost_to_customer_per_qty),2) as avg_spend + +FROM customer_purchases as cp +INNER JOIN customer as c + ON c.customer_id = cp.customer_id + +GROUP BY c.customer_id + +--------------------------------------------------------------------------------------------------------------------------------------------/* MODULE 3 */ /* MIN & MAX */ /* 1. What is the most expensive product ...pay attention to how it doesn't handle ties very well */ +SELECT product_name, max(original_price) as most_expensive +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id; /* 2. Prove that max is working */ +SELECT DISTINCT +product_name, +original_price +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id - +ORDER BY original_price DESC; /* 3. Find the minimum price per each product_qty_type */ +SELECT product_name +,product_qty_type +,MIN(original_price) + +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +GROUP BY product_qty_type /* 4. Prove that min is working */ +SELECT DISTINCT + product_name +,product_qty_type +--,MIN(original_price); +,original_price +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +ORDER BY product_qty_type, original_price; + /* 5. Min/max on a string ... not particularly useful? */ +SELECT max(product_name) +FROM product; --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ +--------------------------------------------------------------------------------------------------------------------------------------------/* MODULE 3 */ /* Arithmitic */ /* 1. power, pi(), ceiling, division, integer division, etc */ -SELECT +SELECT power(4,2), pi(); +SELECT 10.0 / 3.0 as division, +CAST(10.0 as INT) / CAST(3.0 as INT) as integer_division; /* 2. Every even vendor_id with modulo */ - - +SELECT * FROM vendor +WHERE vendor_id % 2 = 0; /* 3. What about every third? */ +SELECT * FROM vendor +WHERE vendor_id % 3 = 0; -------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ +/* MODULE 3 */ /* HAVING */ /* 1. How much did a customer spend on each day? -Filter to customer_id between 1 and 5 and total_cost > 50 +Filter to customer_id between 1 and 5 and total_spend > 50 ... What order of execution occurs?*/ - +SELECT +market_date +,customer_id +,SUM(quantity*cost_to_customer_per_qty) as total_spend + +FROM customer_purchases +WHERE customer_id BETWEEN 1 AND 5 +GROUP BY market_date, customer_id +HAVING total_spend > 50; /* 2. How many products were bought? Filter to number of purchases between 300 and 500 */ +SELECT count(product_id) as num_of_prod +,product_id +FROM customer_purchases +GROUP BY product_id +HAVING count(product_id) BETWEEN 300 AND 500 -- the same as putting "num_of_prod" but not all versions accept -------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ +/* MODULE 3 */ /* Subquery FROM */ /*1. Simple subquery in a FROM statement, e.g. for inflation ...we could imagine joining this to a more complex query perhaps */ +SELECT DISTINCT +product_id +,inflation - +FROM ( + SELECT product_id, cost_to_customer_per_qty, + 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 +); /* 2. What is the single item that has been bought in the greatest quantity?*/ +--outer QUERY +SELECT product_name -- coming from product table +,MAX(quantity_purchased) -- coming from the subquery ("x") + +FROM product AS p +INNER JOIN ( +--inner query + SELECT product_id + ,count(quantity) as quantity_purchased + + FROM customer_purchases + GROUP BY product_id +) AS x ON p.product_id = x.product_id + + -/* MODULE 3 */ +-------------------------------------------------------------------------------------------------------------------------------------------- + + +/* MODULE 3 */ /* Subquery WHERE */ /* 1. How much did each customer spend at each vendor for each day at the market WHEN IT RAINS */ +SELECT market_date +,customer_id +,vendor_id +,SUM(quantity*cost_to_customer_per_qty) as total_spent +FROM customer_purchases +-- filter by rain_flag +-- "what dates was it raining?" +WHERE market_date IN +( + SELECT market_date + FROM market_date_info + WHERE market_rain_flag = 1 +) + +GROUP BY market_date,vendor_id, customer_id /* 2. What is the name of the vendor who sells pie */ +SELECT DISTINCT vendor_name + +FROM customer_purchases as cp +INNER JOIN vendor as v + ON cp.vendor_id = v.vendor_id + +WHERE product_id IN ( + SELECT product_id + FROM product + WHERE product_name LIKE '%pie%' + ) + -------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ +/* MODULE 3 */ /* Temp Tables */ @@ -122,13 +243,16 @@ 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 CREATE TABLE temp.new_vendor_inventory AS -- definition of the table +SELECT *, +original_price*5 as inflation +FROM vendor_inventory @@ -136,9 +260,18 @@ CREATE TABLE temp.new_vendor_inventory AS /* 2. put the previous table into another temp table, e.g. as temp.new_new_vendor_inventory */ +DROP TABLE IF EXISTS temp.new_new_vendor_inventory; +CREATE TABLE temp.new_new_vendor_inventory AS + +SELECT * +,inflation * 2 as super_inflation +FROM temp.new_vendor_inventory + -------------------------------------------------------------------------------------------------------------------------------------------- + +SELECT * FROM temp.new_new_vendor_inventory /* MODULE 3 */ /* Common Table Expression (CTE) */ @@ -176,4 +309,12 @@ SELECT b. number of YEARS between now and market_date c. number of HOURS bewtween now and market_date */ -
+
CREATE TABLE temp.new_vendor_inventory AS + +-- definition of the table +SELECT *, +original_price*5 as inflation +FROM vendor_inventory; + + +SELECT * FROM temp.new_new_vendor_inventory
From 7273a82af39c645e2791020aa87e6d660f6bc994 Mon Sep 17 00:00:00 2001 From: Brigid Goulem Date: Wed, 1 Apr 2026 13:21:42 -0400 Subject: [PATCH 8/8] File has the changes with the queries and the md file with the reflection on wired article. --- .../assignments/DC_Cohort/Assignment1.md | 5 +- .../assignments/DC_Cohort/assignment1.sql | 107 ++++++++++++------ 2 files changed, 78 insertions(+), 34 deletions(-) diff --git a/02_activities/assignments/DC_Cohort/Assignment1.md b/02_activities/assignments/DC_Cohort/Assignment1.md index 70257f581..d5a397439 100644 --- a/02_activities/assignments/DC_Cohort/Assignment1.md +++ b/02_activities/assignments/DC_Cohort/Assignment1.md @@ -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) @@ -213,3 +213,6 @@ In this work, I often encounter work that interrogates the use of biometric data ``` 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. + + diff --git a/02_activities/assignments/DC_Cohort/assignment1.sql b/02_activities/assignments/DC_Cohort/assignment1.sql index 2ec561e2a..49d7dcf21 100644 --- a/02_activities/assignments/DC_Cohort/assignment1.sql +++ b/02_activities/assignments/DC_Cohort/assignment1.sql @@ -6,19 +6,17 @@ --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 @@ -27,9 +25,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 @@ -43,8 +42,11 @@ Limit to 25 rows of output. */ --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 @@ -56,45 +58,63 @@ columns and add a column called prod_qty_type_condensed that displays the word 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 - /* 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 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 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 8 - - - +SELECT vendor_id, + COUNT(*) AS booth_rentals +FROM vendor_booth_assignments +GROUP BY vendor_id; --END QUERY @@ -105,9 +125,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(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 @@ -124,9 +151,14 @@ When inserting the new vendor, you need to appropriately align the columns to be VALUES(col1,col2,col3,col4,col5) */ --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 @@ -139,8 +171,12 @@ 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 @@ -153,7 +189,12 @@ 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 +FROM customer_purchases +WHERE strftime('%m', market_date) = '04' + AND strftime('%Y', market_date) = '2022' +GROUP BY customer_id; --END QUERY