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

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
13 changes: 10 additions & 3 deletions 02_activities/assignments/DC_Cohort/Assignment1.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,14 @@ 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.

There are a lot of value systems that are in databases/data systems that I encounter in my day-to-day life. Often, I do not think of these systems but after reading this article, these systems are so important in how databases are created and how society functions.

```
Your thoughts...
```
The most immediate example I can think of is for any government id or identity/account creation. Most databases include only legal names and binary gender fields (although this has now changed to X for example on passports to include everyone who does not fit into this binary system). This is still stringent as there could be more flexibility for chosen names or even within in the non-binary category, X does not encompass all of the differences within this category.

Similarly, for a lot of surveys I complete. Often race/ethnicity options have an 'Other' category, income brackets are centered around middle-class assumptions, marital status does not account for common law or other non-traditional relationships etc. These are all categories, while improving, could be expanded on instead of provided binary options.

Another example I really thought about was banking. Historically, until the late 70s, women could not open a credit card in their own name unless there was a male cosign. This would have impacted databases and significant reform would have had to happen to ensure the system would allow me to bank as I do today.

Lastly for healthcare. A lot of diagnostic tools and symptoms are predominantly based on biological male research data. If medical records and past databases are used to train machine learning tools for improving future healthcare systems, this could be grossly misinterpreting the biological female category or any other non-binary category.

This article has made me realize that all of these value systems and databases are originally designed around a "normal" or "default" user. When the user differs from this default, it can have large consequences on how the database functions. As technology advances, we need to be aware that not everyone and not every database can assume a default user.
39 changes: 31 additions & 8 deletions 02_activities/assignments/DC_Cohort/Assignment2.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,30 @@ The store wants to keep customer addresses. Propose two architectures for the CU

**HINT:** search type 1 vs type 2 slowly changing dimensions.

```
Your answer...
```

***
Type 1 will overwrite existing data with new data whereas Type 2 will retain changes by creating a new row for changes and will keep the full history.

For example for Type 1 under customer address you could have the following rows

address_id
customer_id
street
city
province
postal_code
country

But, for Type 2 you could have the following rows under customer address.

address_id
customer_id
street
city
province
postal_code
country
start_date
end_date
is_current

## Section 2:
You can start this section following *session 4*.
Expand Down Expand Up @@ -189,7 +208,11 @@ Read: Boykis, V. (2019, October 16). _Neural nets are just people all the way do

Consider, for example, concepts of labour, bias, LLM proliferation, moderating content, intersection of technology and society, ect.

There are a lot of ethical concepts touched upon in this story. As discussed, briefly in the slides (Slides #6 in the DSI course), human labour is one of the largest contributors to the development of any machine learning or large database. Much of the labour (for example in the article discussing humans selecting through thousands of images for training ImageNet) is the labour that is often invisible. We hear about the codes that are developed or the way developers are making the AI systems smarter and working faster, but this is often due to human input helping train the models. The individuals training the models are probably not paid as high as the developers themselves.

In addition, the development of machine learning or databases are built on human biases. Much like the reflection from Assignment 1, humans have pre-conceptions and the choices/labels/determinations they have can influence how the model functions or how the databases are setup (for example databases only allowing options of male vs female). This is critical because for a system that is supposed to be "smarter" and allow us to save time seems to be built on a system that is already prone to unfairness and biases that may inform classifications that are unfair. Unless this is addressed fully, we cannot depend on machine learning and AI as an all-knowing entity.

Furthermore, one of my concerns is how anonymous AI models can be. If there is a clear bias or problem in the program and if the system is built on human-inputted information where does the blame go? How can companies moderate content and ensure it is safe/reliable without bias. Specifically, the example of ImageNET having unsafe or socially inappropriate categories that were labelled. My concern with this is how to ensure the models we are training currently account for that potential issue. Another ethical concern is regarding data privacy and consent. Any image or content can be put into these models. How is it controlled and how is consent provided/revoked? Does digital consent exist at this stage with the training of these models? Especially in the example of ImageNet where they were pulling images from the internet to train their model.

Lastly, reading this article I was struck about how robots struggled to fold laundry and how what we think are menial tasks are incredibly difficult for these models. At the end of the day, the brains behind these processes are not AI, but rather humans themselves. For something that is seen as such a gold standard, this article really highlighted and brough to awareness for me that a lot of these advances are built on the work of many who may not be adequately recognized.

```
Your thoughts...
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36" version="29.6.6">
<diagram name="Page-1" id="E-oH3G7A4SgckM9fV9Jp">
<mxGraphModel dx="784" dy="1136" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="2gDZxn3HT3ftujqXDELD-3" connectable="0" parent="1" style="group" value="" vertex="1">
<mxGeometry height="170" width="150" x="480" y="120" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-1" parent="2gDZxn3HT3ftujqXDELD-3" style="rounded=0;whiteSpace=wrap;html=1;align=left;" value="&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;&amp;nbsp;product_id&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;product_name&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;product_size&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;product_category_id&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;product_qty_type&lt;/div&gt;" vertex="1">
<mxGeometry height="150" width="150" y="20" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-2" parent="2gDZxn3HT3ftujqXDELD-3" style="rounded=0;whiteSpace=wrap;html=1;" value="product" vertex="1">
<mxGeometry height="20" width="150" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-7" parent="1" style="shape=partialRectangle;whiteSpace=wrap;html=1;bottom=0;right=0;fillColor=none;" value="" vertex="1">
<mxGeometry height="120" width="200" x="280" y="200" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-10" connectable="0" parent="1" style="group" value="" vertex="1">
<mxGeometry height="240" width="170" x="210" y="320" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-11" parent="2gDZxn3HT3ftujqXDELD-10" style="rounded=0;whiteSpace=wrap;html=1;align=left;" value="&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;&amp;nbsp;product_id&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;vendor_id&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;market_date&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;customer_id&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;quantity&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;cost_to_customer_per_qty&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&amp;nbsp;transaction_time&lt;/div&gt;" vertex="1">
<mxGeometry height="211.76470588235296" width="170" y="28.23529411764706" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-12" parent="2gDZxn3HT3ftujqXDELD-10" style="rounded=0;whiteSpace=wrap;html=1;" value="customer_purchases" vertex="1">
<mxGeometry height="28.23529411764706" width="170" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-13" parent="1" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" value="1" vertex="1">
<mxGeometry height="30" width="30" x="450" y="170" as="geometry" />
</mxCell>
<mxCell id="2gDZxn3HT3ftujqXDELD-29" parent="1" style="shape=image;html=1;verticalAlign=top;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;imageAspect=0;aspect=fixed;image=https://icons.diagrams.net/icon-cache1/CSS_Vol_2-2665/infinity-569.svg" value="" vertex="1">
<mxGeometry height="24" width="24" x="210" y="296" as="geometry" />
</mxCell>
<mxCell id="T7FpVxOjFvGkZqPOFmhY-2" parent="1" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" value="Farmers Market Logical Model (Partial)&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;One-to-Many Relationship&lt;/div&gt;" vertex="1">
<mxGeometry height="30" width="220" x="190" y="130" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file not shown.
101 changes: 62 additions & 39 deletions 02_activities/assignments/DC_Cohort/assignment1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,38 @@
--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



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 = 4 OR product_id = 9
LIMIT 25;

--END QUERY



/*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
Expand All @@ -43,75 +42,99 @@ 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


--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 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
INNER JOIN vendor_booth_assignments
ON vendor.vendor_id = vendor_booth_assignments.vendor_id
ORDER BY market_date, 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_count
FROM vendor_booth_assignments
GROUP BY vendor_id;

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

SELECT
customer_first_name
,customer_last_name
, SUM(quantity*cost_to_customer_per_qty) as total_spend


FROM customer_purchases as cp
INNER JOIN customer as c
ON c.customer_id = cp.customer_id
GROUP BY cp.customer_id
HAVING total_spend > 2000
ORDER BY customer_last_name, customer_first_name;

--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
Expand All @@ -125,26 +148,29 @@ VALUES(col1,col2,col3,col4,col5)
*/
--QUERY 10

-- Created table from the original
CREATE TABLE temp.new_vendor AS
SELECT *
FROM vendor;


-- Add the 10th vendor
INSERT INTO temp.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


-- Date
-- Date DO NOT COMPLETE
/*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 11




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

Expand All @@ -153,7 +179,4 @@ but remember, STRFTIME returns a STRING for your WHERE statement...
AND be sure you remove the LIMIT from the previous query before aggregating!! */
--QUERY 12




--END QUERY
Loading
Loading