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
59 changes: 58 additions & 1 deletion 02_activities/assignments/Assignment1.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,66 @@ Link if you encounter a paywall: https://web.archive.org/web/20240422105834/http

**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.
Consider, for example, concepts of fairness, inequality, social structures, marginalization, intersection of technology and society, etc.


```
Your thoughts...
Introduction

Databases might seem like neutral tools, but in reality, they carry the values and biases of the societies that create them. The article When Databases Get to Define Family by Qadri R. (2021) explores how Pakistan's digital family registration system enforces a rigid definition of family, excluding marginalized groups and reinforcing social norms. This issue isn’t unique to Pakistan—it’s a global concern that raises questions about fairness, inequality, and how technology shapes our lives.

How Databases Reflect Societal Values

Every day, we interact with databases that influence our opportunities and experiences. From government records to financial systems, these databases shape our access to essential services. But who gets included, and who is left out?

1. Fairness and Inequality

A well-designed database should aim to be inclusive, but many systems reflect existing social biases. For example:

Government databases often fail to recognize non-traditional families, like single-parent households or LGBTQ+ couples, making it harder for them to access rights and benefits.

Credit scoring systems tend to favour wealthier individuals, making it difficult for low-income people to secure loans or mortgages.

Healthcare databases may not fully represent diverse racial and genetic backgrounds, leading to misdiagnoses and inadequate treatment for marginalized communities.

In Pakistan, the National Database and Registration Authority (NADRA) requires women to rely on male guardians for family verification, reinforcing patriarchal structures. This isn’t just a Pakistani issue—many legal and financial systems worldwide fail to recognize relationships that don’t fit traditional norms, creating unnecessary barriers.

2. Social Structures and Marginalization

Data systems tend to mirror existing power structures, often sidelining marginalized groups:

Caste and Ethnicity Bias: Some databases categorize people by race or caste in ways that reinforce discrimination, affecting access to jobs and education.

Gender and Identity: Many systems still use binary gender classifications, making it difficult for non-binary and transgender individuals to have their identities recognized.

Algorithmic Discrimination: AI-driven hiring or law enforcement tools often inherit biases from historical data, leading to unfair treatment, particularly for people of colour.

3. The Intersection of Technology and Society

We often think of technology as neutral, but databases are shaped by human decisions. This raises major ethical concerns:

Surveillance and Privacy: Governments use digital databases for national security, but this can lead to overreach and violations of personal privacy.

Data Ownership and Consent: Most people don’t control their own digital data, allowing corporations and governments to exploit their personal information.

Historical Data Bias: Predictive policing databases, for example, rely on past crime records—but if law enforcement has historically targeted specific racial groups, these databases reinforce discrimination.

Building More Ethical Data Systems

To create fairer, more inclusive data systems, we need to:

-Acknowledge Bias: Database architects and policymakers must actively identify and address biases in data collection and categorization.

-Design for Inclusivity: Systems should recognize diverse identities and family structures, rather than imposing rigid definitions.

-Strengthen Data Protection Laws: Individuals should have control over how their data is collected and used.

-Encourage Public Oversight: Independent organizations should have a role in reviewing and regulating database practices.

Conclusion

Databases influence our lives in ways we often don’t realize. They decide who gets access to resources, how we are identified, and even how we move through the world. But they are not neutral—they reflect the priorities and prejudices of those who build and maintain them. The case of Pakistan’s family database serves as a reminder that we need to actively question and improve the systems we rely on. As we become more dependent on digital systems, ethical considerations must guide database design to ensure fairness and inclusivity for all.


```
77 changes: 75 additions & 2 deletions 02_activities/assignments/Assignment2.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,49 @@ 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...
To store customer addresses, we propose two different architectures:

Type 1: Overwriting Changes

A simple structure where the latest address replaces the previous one:

Table: CUSTOMER_ADDRESS

customer_id (Primary Key, Foreign Key from Customer)

address

city

state

zip

In this model, whenever a customer updates their address, the old data is overwritten.

Type 2: Retaining History

A more complex structure that maintains historical address changes:

Table: CUSTOMER_ADDRESS_HISTORY

customer_id (Foreign Key from Customer)

address

city

state

zip

start_date

end_date

With this approach, whenever a customer changes their address, a new record is created with the start_date, and the previous record is updated with an end_date, preserving history.

Type 1 is best when historical data is not needed, whereas Type 2 is essential when tracking address changes over time.
```

***
Expand Down Expand Up @@ -182,5 +224,36 @@ Consider, for example, concepts of labour, bias, LLM proliferation, moderating c


```
Your thoughts...
Section 4: Ethics in AI and Data Processing

Ethical Issues in "Neural Nets are Just People All the Way Down"

The article by Vicki Boykis explores the ethical complexities surrounding AI, specifically Large Language Models (LLMs). Key ethical concerns include:

Bias in AI Models

AI systems inherit biases from their training data, which reflects societal prejudices.

This perpetuates discrimination in automated decision-making.

Labor and Automation

LLMs rely on vast amounts of data labeled by underpaid human workers.

The ethical issue of exploiting global labor for AI development raises concerns.

Challenges in Moderating AI-Generated Content

AI-generated content can be harmful or misleading.

There is no perfect moderation system, as AI models lack human context and ethics.

AI in Society & Ethical Dilemmas

The rapid growth of LLMs creates a monopoly where only a few corporations control AI development.

Ethical concerns arise about transparency, accessibility, and misinformation.

Conclusion
While AI provides immense benefits, its ethical implications cannot be ignored. To mitigate bias, labor exploitation, and misinformation, there must be continuous oversight, regulation, and a commitment to ethical AI development. AI is ultimately shaped by human values, and ensuring fairness and accountability remains a shared responsibility
```
Binary file added 02_activities/assignments/BOOKSTORE ERD.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 02_activities/assignments/Logical model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 70 additions & 10 deletions 02_activities/assignments/assignment1.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
/* ASSIGNMENT 1 */
/* SECTION 2 */
--/* ASSIGNMENT 1 */
--/* SECTION 2 */


--SELECT
/* 1. Write a query that returns everything in the customer table. */

--SELECT
--/* 1. Write a query that returns everything in the customer table. */

--1. Select everything from the customer table
SELECT * FROM customer;

/* 2. Write a query that displays all of the columns and 10 rows from the cus- tomer table,
sorted by customer_last_name, then customer_first_ name. */
--/* 2. Write a query that displays all of the columns and 10 rows from the cus- tomer table,
--sorted by customer_last_name, then customer_first_ name. */

--2. Select all columns, 10 rows from customer table, sorted by last name then first name
SELECT * FROM customer
ORDER BY customer_last_name, customer_first_name
LIMIT 10;


--WHERE
/* 1. Write a query that returns all customer purchases of product IDs 4 and 9. */
--/* 1. Write a query that returns all customer purchases of product IDs 4 and 9. */
-- option 1

SELECT * FROM customer_purchases
WHERE product_id IN (4, 9);

-- option 2
SELECT * FROM customer_purchases
WHERE product_id = 4 OR product_id = 9;



Expand All @@ -27,7 +36,10 @@ filtered by vendor IDs between 8 and 10 (inclusive) using either:
2. one condition using BETWEEN
*/
-- option 1

-- 4. Select customer purchases with a calculated 'price' column, filtered by vendor IDs between 8 and 10
SELECT *, (quantity * cost_to_customer_per_qty) AS price
FROM customer_purchases
WHERE vendor_id BETWEEN 8 AND 10;

-- option 2

Expand All @@ -39,17 +51,37 @@ Using the product table, write a query that outputs the product_id and product_n
columns and add a column called prod_qty_type_condensed that displays the word “unit”
if the product_qty_type is “unit,” and otherwise displays the word “bulk.” */


-- 5. Select product_id, product_name, and create prod_qty_type_condensed column using CASE
SELECT product_id, product_name,
CASE
WHEN product_qty_type = 'unit' THEN 'unit'
ELSE 'bulk'
END AS prod_qty_type_condensed
FROM product;

/* 2. We want to flag all of the different types of pepper products that are sold at the market.
add a column to the previous query called pepper_flag that outputs a 1 if the product_name
contains the word “pepper” (regardless of capitalization), and otherwise outputs 0. */

SELECT product_id, product_name,
CASE
WHEN product_qty_type = 'unit' THEN 'unit'
ELSE 'bulk'
END AS prod_qty_type_condensed,
CASE
WHEN LOWER(product_name) LIKE '%pepper%' THEN 1
ELSE 0
END AS pepper_flag
FROM product;


--JOIN
/* 1. Write a query that INNER JOINs the vendor table to the vendor_booth_assignments table on the
vendor_id field they both have in common, and sorts the result by vendor_name, then market_date. */
SELECT vendor.*, vendor_booth_assignments.*
FROM vendor
INNER JOIN vendor_booth_assignments ON vendor.vendor_id = vendor_booth_assignments.vendor_id
ORDER BY vendor.vendor_name, vendor_booth_assignments.market_date;



Expand All @@ -60,6 +92,9 @@ vendor_id field they both have in common, and sorts the result by vendor_name, t
/* 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. */

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


/* 2. The Farmer’s Market Customer Appreciation Committee wants to give a bumper
Expand All @@ -68,6 +103,13 @@ of customers for them to give stickers to, sorted by last name, then first name.

HINT: This query requires you to join two tables, use an aggregate function, and use the HAVING keyword. */

SELECT c.customer_id, c.customer_first_name, c.customer_last_name,
SUM(cp.quantity * cp.cost_to_customer_per_qty) AS total_spent
FROM customer_purchases cp
JOIN customer c ON cp.customer_id = c.customer_id
GROUP BY c.customer_id
HAVING total_spent > 2000
ORDER BY c.customer_last_name, c.customer_first_name;


--Temp Table
Expand All @@ -81,14 +123,27 @@ 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)
*/
-- Drop the temp table if it already exists
DROP TABLE IF EXISTS new_vendor;

-- Create a temporary table from the vendor table
CREATE TEMP TABLE new_vendor AS
SELECT * FROM vendor;

-- Insert a new vendor into the temporary table
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');


-- 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! */
SELECT customer_id,
STRFTIME('%m', market_date) AS month,
STRFTIME('%Y', market_date) AS year
FROM customer_purchases;



Expand All @@ -98,3 +153,8 @@ 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!! */

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;

Loading