From 6a8aef136ddc04b0a5659f76bc8c38ea6b22642f Mon Sep 17 00:00:00 2001 From: monzchan <166637673+monzchan@users.noreply.github.com> Date: Tue, 14 May 2024 21:36:00 -0400 Subject: [PATCH 1/8] Complete homework_1.md --- 03_homework/homework_1.md | 1 + 1 file changed, 1 insertion(+) diff --git a/03_homework/homework_1.md b/03_homework/homework_1.md index c50fe783c..078588197 100644 --- a/03_homework/homework_1.md +++ b/03_homework/homework_1.md @@ -76,3 +76,4 @@ Please do not pick the exact same tables that I have already diagramed. For exam - ![01_farmers_market_conceptual_model.png](./images/01_farmers_market_conceptual_model.png) - 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) +![image](https://github.com/monzchan/SQL/assets/166637673/863d31cf-46f9-4d5e-85ff-a4a6128e3680) From 966a3f6444ba0e4a00f9fda11f54c177bcb149f2 Mon Sep 17 00:00:00 2001 From: Moniz Chan Date: Sat, 18 May 2024 22:39:18 -0400 Subject: [PATCH 2/8] Complete homework_2 --- 03_homework/homework_2.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/03_homework/homework_2.md b/03_homework/homework_2.md index bd3055227..90a258b84 100644 --- a/03_homework/homework_2.md +++ b/03_homework/homework_2.md @@ -6,18 +6,49 @@ # SELECT 1. Write a query that returns everything in the customer table. +SELECT * FROM customer + + 2. Write a query that displays all of the columns and 10 rows from the customer table, sorted by customer_last_name, then customer_first_ name. +SELECT * FROM customer ORDER BY customer_last_name, customer_first_name LIMIT 10 + # WHERE 1. Write a query that returns all customer purchases of product IDs 4 and 9. -2. Write a query that returns all customer purchases and a new calculated column 'price' (quantity * cost_to_customer_per_qty), filtered by vendor IDs between 8 and 10 (inclusive) using either: +SELECT * FROM customer_purchases +WHERE product_id BETWEEN 4 AND 9 + +2. Write a query that returns all customer purchases and a new calculated column 'price' +(quantity * cost_to_customer_per_qty), filtered by vendor IDs between 8 and 10 (inclusive) using either: 1. two conditions using AND 2. one condition using BETWEEN +SELECT *, (quantity * cost_to_customer_per_qty) AS price +FROM customer_purchases +WHERE vendor_id BETWEEN 8 AND 10 + # 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.” +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 *, +CASE WHEN product_name LIKE '%pepper%' THEN 1 ELSE 0 END AS pepper_flag +FROM product + + # 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 `vendor_name`, then `market_date`. +SELECT * +FROM vendor +JOIN vendor_booth_assignments +ON vendor.vendor_id=vendor_booth_assignments.vendor_id +ORDER BY vendor_name, market_date + + From 87a2c2ab54526e2ac850ecedf9faab7a4fc3746a Mon Sep 17 00:00:00 2001 From: Moniz Chan Date: Sat, 18 May 2024 22:39:56 -0400 Subject: [PATCH 3/8] Complete homework_3 --- 03_homework/homework_3.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/03_homework/homework_3.md b/03_homework/homework_3.md index 3f089c3f9..60aeed71e 100644 --- a/03_homework/homework_3.md +++ b/03_homework/homework_3.md @@ -6,9 +6,26 @@ # 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`. + +SELECT vendor_id, COUNT(booth_number) +FROM vendor_booth_assignments +GROUP BY 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. +SELECT c.customer_id, c.customer_first_name, c.customer_last_name, sum(cp.quantity* cp.cost_to_customer_per_qty) AS totalpurchase +FROM customer c +INNER JOIN customer_purchases cp +ON c.customer_id = cp.customer_id +GROUP BY customer_last_name, customer_first_name +HAVING totalpurchase>2000 +ORDER BY customer_last_name, customer_first_name + + + + + # 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) @@ -16,9 +33,26 @@ To insert the new row use VALUES, specifying the value you want for each column: `VALUES(col1,col2,col3,col4,col5)` +DROP TABLE IF EXISTS temp.new_vendor; +CREATE TEMP TABLE temp.new_vendor AS +SELECT * FROM vendor; +INSERT INTO temp.new_vendor VALUES (10, 'Thomass Superfood', 'Fresh Focused', 'Rosenthal', 'Thomas'); + + + + # 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('%Y', market_date), STRFTIME('%m', market_date) +FROM customer_purchases + 2. Using the previous query as a base, determine how much money each customer spent in April 2019. 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, STRFTIME('%Y', market_date) AS market_year, STRFTIME('%m', market_date) AS market_month +, SUM(quantity * cost_to_customer_per_qty) AS totalpurchase +FROM customer_purchases +GROUP BY market_year, market_month, customer_id +HAVING market_year LIKE '2019' AND market_month LIKE '04' From fac5f1f2d03056272c02835664b8ab1fb2c48eaa Mon Sep 17 00:00:00 2001 From: Moniz Chan Date: Sun, 26 May 2024 00:03:33 -0400 Subject: [PATCH 4/8] complete homework 4,5 --- 03_homework/homework_4.md | 49 +++++++++++++++++++++++++++++++++++++ 03_homework/homework_5.md | 51 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/03_homework/homework_4.md b/03_homework/homework_4.md index 945cc4fac..023c1f39b 100644 --- a/03_homework/homework_4.md +++ b/03_homework/homework_4.md @@ -19,16 +19,43 @@ Find the NULLs and then using COALESCE, replace the NULL with a blank for the fi **HINT**: keep the syntax the same, but edited the correct components with the string. The `||` values concatenate the columns into strings. Edit the appropriate columns -- you're making two edits -- and the NULL rows will be fixed. All the other rows will remain the same. +SELECT +product_name || ',' || COALESCE(product_size,' ') || '(' || COALESCE(product_qty_type, 'unit') ||')' +FROM product + + # Windowed Functions 1. Write a query that selects from the customer_purchases table and numbers each customer’s visits to the farmer’s market (labeling each market date with a different number). Each customer’s first visit is labeled 1, second visit is labeled 2, etc. You can either display all rows in the customer_purchases table, with the counter changing on each new market date for each customer, or select only the unique market dates per customer (without purchase details) and number those visits. **HINT**: One of these approaches uses ROW_NUMBER() and one uses DENSE_RANK(). +SELECT customer_id, +Max(x.visit) as total_visit +FROM( +SELECT customer_id, +DENSE_RANK() OVER (PARTITION BY customer_id ORDER BY market_date)AS visit +FROM customer_purchases)x +GROUP BY customer_id + 2. Reverse the numbering of the query from a part so each customer’s most recent visit is labeled 1, then write another query that uses this one as a subquery (or temp table) and filters the results to only the customer’s most recent visit. +SELECT DISTINCT customer_id, market_date +FROM(SELECT customer_id, market_date, +DENSE_RANK() OVER (PARTITION BY customer_id ORDER BY market_date DESC) AS recent_visit +FROM customer_purchases)x +WHERE x.recent_visit=1 + + 3. Using a COUNT() window function, include a value along with each row of the customer_purchases table that indicates how many different times that customer has purchased that product_id. +Select * +FROM +(select product_id, customer_id, +COUNT()OVER(PARTITION BY product_id ORDER BY customer_id ) AS no_of_times_of_purchases +from customer_purchases +ORDER BY customer_id)x +GROUP BY customer_id # String manipulations 1. Some product names in the product table have descriptions like "Jar" or "Organic". These are separated from the product name with a hyphen. Create a column using SUBSTR (and a couple of other commands) that captures these, but is otherwise NULL. Remove any trailing or leading whitespaces. Don't just use a case statement for each product! @@ -39,7 +66,29 @@ You can either display all rows in the customer_purchases table, with the counte **HINT**: you might need to use INSTR(product_name,'-') to find the hyphens. INSTR will help split the column. +SELECT product_name, +CASE WHEN product_name LIKE '%-%' THEN +substr(product_name, INSTR(product_name, '-')+2)Else NULL +END as description +FROM product + # UNION 1. Using a UNION, write a query that displays the market dates with the highest and lowest total sales. **HINT**: There are a possibly a few ways to do this query, but if you're struggling, try the following: 1) Create a CTE/Temp Table to find sales values grouped dates; 2) Create another CTE/Temp table with a rank windowed function on the previous query to create "best day" and "worst day"; 3) Query the second temp table twice, once for the best day, once for the worst day, with a UNION binding them. + +SELECT * +FROM( +SELECT market_date, +(quantity * cost_to_customer_per_qty) as total_sales, +dense_rank()OVER (ORDER BY (quantity * cost_to_customer_per_qty) DESC) as sale_rank +FROM customer_purchases)x +WHERE x.sale_rank=1 +UNION +SELECT * +FROM( +SELECT market_date, +(quantity * cost_to_customer_per_qty) as total_sales, +dense_rank()OVER (ORDER BY (quantity * cost_to_customer_per_qty) DESC) as sale_rank +FROM customer_purchases)x +WHERE x.sale_rank=419 \ No newline at end of file diff --git a/03_homework/homework_5.md b/03_homework/homework_5.md index fb78fddbf..c1430dc99 100644 --- a/03_homework/homework_5.md +++ b/03_homework/homework_5.md @@ -9,18 +9,41 @@ **HINT**: Be sure you select only relevant columns and rows. Remember, CROSS JOIN will explode your table rows, so CROSS JOIN should likely be a subquery. Think a bit about the row counts: how many distinct vendors, product names are there (x)? How many customers are there (y). Before your final group by you should have the product of those two queries (x\*y). +SELECT DISTINCT vendor_name, product_name, cost_to_customer_per_qty, +cost_to_customer_per_qty *5 *28 AS total_sale +FROM vendor v +JOIN vendor_inventory vi +ON v. vendor_id = vi.vendor_id +JOIN product p +ON vi.product_id = p.product_id +JOIN customer_purchases cp +ON p.product_id = cp.product_id # INSERT 1. Create a new table "product_units". This table will contain only products where the `product_qty_type = 'unit'`. It should use all of the columns from the product table, as well as a new column for the `CURRENT_TIMESTAMP`. Name the timestamp column `snapshot_timestamp`. +DROP TABLE IF EXISTS temp.product_units; +CREATE TEMP TABLE product_units AS +SELECT *, CURRENT_TIMESTAMP AS snapshot_timestamp +FROM product +WHERE product_qty_type = 'unit' + + + + 2. Using `INSERT`, add a new row to the table (with an updated timestamp). This can be any product you desire (e.g. add another record for Apple Pie). +INSERT INTO product_units +VALUES(50,'Apple pie', '300lb', 3,'unit', CURRENT_TIMESTAMP) + # DELETE 1. Delete the older record for the whatever product you added. **HINT**: If you don't specify a WHERE clause, [you are going to have a bad time](https://imgflip.com/i/8iq872). +DELETE FROM product_units +WHERE product_id=50 # UPDATE 1. We want to add the current_quantity to the product_units table. First, add a new column, `current_quantity` to the table using the following syntax. @@ -33,5 +56,31 @@ Then, using `UPDATE`, change the current_quantity equal to the **last** `quantit **HINT**: This one is pretty hard. First, determine how to get the "last" quantity per product. Second, coalesce null values to 0 (if you don't have null values, figure out how to rearrange your query so you do.) Third, `SET current_quantity = (...your select statement...)`, remembering that WHERE can only accommodate one column. Finally, make sure you have a WHERE statement to update the right row, you'll need to use `product_units.product_id` to refer to the correct row within the product_units table. When you have all of these components, you can run the update statement. +ALTER TABLE product_units +ADD current_quantity INT; - +----------------------------- + +DROP TABLE IF EXISTS temp.product_quantity; +CREATE TEMP TABLE product_quantity AS +SELECT product_id AS product_id, +COALESCE(quantity, 0) AS quantity +FROM +(SELECT p.product_id, m.quantity +FROM product AS p +LEFT JOIN +(SELECT x.product_id, x.quantity +FROM ( +SELECT *, +RANK() OVER(PARTITION BY product_id ORDER BY market_date DESC) as current_transaction +FROM vendor_inventory)x +WHERE x.current_transaction=1) as m +ON p.product_id = m.product_id) + + +UPDATE product_units +SET current_quantity = ( +SELECT quantity +FROM product_quantity +WHERE product_units.product_id = product_quantity.product_id +) \ No newline at end of file From e402f3a50b018e3f60e1437e728eaec2b176fc85 Mon Sep 17 00:00:00 2001 From: monzchan <166637673+monzchan@users.noreply.github.com> Date: Mon, 27 May 2024 17:12:50 -0400 Subject: [PATCH 5/8] Update homework_4.md Correction --- 03_homework/homework_4.md | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/03_homework/homework_4.md b/03_homework/homework_4.md index 023c1f39b..9104cdb36 100644 --- a/03_homework/homework_4.md +++ b/03_homework/homework_4.md @@ -40,12 +40,9 @@ GROUP BY customer_id 2. Reverse the numbering of the query from a part so each customer’s most recent visit is labeled 1, then write another query that uses this one as a subquery (or temp table) and filters the results to only the customer’s most recent visit. -SELECT DISTINCT customer_id, market_date -FROM(SELECT customer_id, market_date, -DENSE_RANK() OVER (PARTITION BY customer_id ORDER BY market_date DESC) AS recent_visit -FROM customer_purchases)x -WHERE x.recent_visit=1 - +SELECT cp.*, +DENSE_RANK() OVER (PARTITION BY customer_id ORDER BY market_date) AS visit_number +FROM customer_purchases AS cp 3. Using a COUNT() window function, include a value along with each row of the customer_purchases table that indicates how many different times that customer has purchased that product_id. @@ -77,18 +74,31 @@ FROM product **HINT**: There are a possibly a few ways to do this query, but if you're struggling, try the following: 1) Create a CTE/Temp Table to find sales values grouped dates; 2) Create another CTE/Temp table with a rank windowed function on the previous query to create "best day" and "worst day"; 3) Query the second temp table twice, once for the best day, once for the worst day, with a UNION binding them. -SELECT * -FROM( -SELECT market_date, -(quantity * cost_to_customer_per_qty) as total_sales, -dense_rank()OVER (ORDER BY (quantity * cost_to_customer_per_qty) DESC) as sale_rank -FROM customer_purchases)x -WHERE x.sale_rank=1 +;WITH sales_per_market AS ( +SELECT +market_date, +ROUND(SUM(quantity * cost_to_customer_per_qty),2) AS sales + +FROM customer_purchases +GROUP BY market_date +) + +,market_dates_ranked_by_sales AS ( +SELECT +market_date, +sales, +RANK() OVER (ORDER BY sales) AS sales_rank_asc, +RANK() OVER (ORDER BY sales DESC) AS sales_rank_desc + +FROM sales_per_market +) + +SELECT market_date, sales, sales_rank_desc AS sales_rank +FROM market_dates_ranked_by_sales +WHERE sales_rank_asc = 1 + UNION -SELECT * -FROM( -SELECT market_date, -(quantity * cost_to_customer_per_qty) as total_sales, -dense_rank()OVER (ORDER BY (quantity * cost_to_customer_per_qty) DESC) as sale_rank -FROM customer_purchases)x -WHERE x.sale_rank=419 \ No newline at end of file + +SELECT market_date, sales, sales_rank_desc AS sales_rank +FROM market_dates_ranked_by_sales +WHERE sales_rank_desc = 1 From b14a007a5586d323e80ab487e17643ce674bbc51 Mon Sep 17 00:00:00 2001 From: monzchan <166637673+monzchan@users.noreply.github.com> Date: Mon, 27 May 2024 17:35:29 -0400 Subject: [PATCH 6/8] Update homework_6.md --- 03_homework/homework_6.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/03_homework/homework_6.md b/03_homework/homework_6.md index f16c02202..a17cf16ad 100644 --- a/03_homework/homework_6.md +++ b/03_homework/homework_6.md @@ -6,3 +6,9 @@
**Write**: Reflect on your previous work and how you would adjust to include ethics and inequity components. Total length should be a few paragraphs, no more than one page. + +I have been working in the hospital as a nurse for over 6 years and I have encounted quite a lot of ethical dilema. + +For example, there was a patient approaching me to ask about the update on her lab report regrading a specimen sent at the date of operation. As a nurse working in the specialty clinic, I was able to access to all patient's information as long as the patient was an active out-patient at our clinic. However, I was not the nurse in charge of that patient and I was not involved in the operation that day, so it might not be ethical to retrieve data from a patient out of my scope of care. Therefore, I only explained to her about the situation and the ethical issues, and direct her to ask about information from her family doctor. + +Another example would be my co-worker being admitted for an operation, and I was a nurse involved in the care that day. As a case nurse, I was authorized to retrieve patient's data about the patient's conditions such as her medical history, family backgrund, current medical conditions, and current medication etc, so as to provide patient-centered care. However, there was always an issue abut how much a nurse should know about that patient. As this patient was admitted for a minor procedure, namely the suturing of a laceration. Retrieving data about whether or not she has medication allergy, diabetic condition for wound healing should be enough to determine the care to be provided. Other data such as her family history, marital status, psychological consultation etc may not be significant. This example is brought up to stress on the importance of defining the boundary of data retrieval for the purpose of action. From f7176849ddc63e30376ada8cc67740fe4e42e0d1 Mon Sep 17 00:00:00 2001 From: monzchan <166637673+monzchan@users.noreply.github.com> Date: Mon, 27 May 2024 20:39:04 -0400 Subject: [PATCH 7/8] Complete model design assignment --- 02_assignments/design_a_logical_model.md | 32 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/02_assignments/design_a_logical_model.md b/02_assignments/design_a_logical_model.md index 054ea5c41..15af40e35 100644 --- a/02_assignments/design_a_logical_model.md +++ b/02_assignments/design_a_logical_model.md @@ -5,26 +5,36 @@ Create a logical model for a small bookstore. 📚 At the minimum it should have employee, order, sales, customer, and book entities (tables). Determine sensible column and table design based on what you know about these concepts. Keep it simple, but work out sensible relationships to keep tables reasonably sized. Include a date table. There are several tools online you can use, I'd recommend [_Draw.io_](https://www.drawio.com/) or [_LucidChart_](https://www.lucidchart.com/pages/). +![image](https://github.com/monzchan/SQL/assets/166637673/58d3bfe0-593a-41f6-a013-e500e0f7ace1) + ## Question 2 We want to create employee shifts, splitting up the day into morning and evening. Add this to the ERD. +![image](https://github.com/monzchan/SQL/assets/166637673/f895c06b-c7c0-4d4a-9d9a-654f32519e21) + ## Question 3 The store wants to keep customer addresses. Propose two architectures for the CUSTOMER_ADDRESS table, one that will retain changes, and another that will overwrite. Which is type 1, which is type 2? _Hint, search type 1 vs type 2 slowly changing dimensions._ -Bonus: Are there privacy implications to this, why or why not? -``` -Your answer... -``` +Type 1 + ![image](https://github.com/monzchan/SQL/assets/166637673/5a755a5a-1705-4b22-808f-e00bc37fe8d8) + +Type 2 + ![image](https://github.com/monzchan/SQL/assets/166637673/0b1a0ced-c5d7-4367-8318-8c14d15b72d0) + + +For type 2 architecture, privacy issue raised since customer data will be retained in the data bank forever. It enables data scientist to track historically significant attributes. But for type 1 slowly changing dimension, the data about customer’s information will be overwritten by updated data. So, only the recent data will be kept. + ## Question 4 Review the AdventureWorks Schema [here](https://i.stack.imgur.com/LMu4W.gif) Highlight at least two differences between it and your ERD. Would you change anything in yours? -``` -Your answer... -``` + +The AdventureWorks Schema categorizes data into different schemas. In each schemas, it contains a set of tables. As for my ERD, data is not categorized. As the data set of my ERD is simple, categorization with schemas may not be needed. But if there is more information to be included in my ERD, I would categorize the data into Human Resources (include Emplyee, Employee shift etc.), Sales (include Sales, Custmer, Order etc.), Inventory (include book entitles etc.), and ther categories related to the book administration + +Another difference is that the AdventureWrks Schema include ‘Modified Date’ at almost all table. This allow historical entry to be kept instead of being overwritten by updated data entry. My ERD utilize type 1 slowly changing dimension architecture. So, whenever I modify the book information using the same book_id, or modifying the customer information using the same customer_id, the previous data will be deleted and replaced by new data. In order to allow historical data to be kept, I may assign each edition of data an ID and ensure each entry will be record with the ‘Modified Date’. # Criteria @@ -44,9 +54,9 @@ Your answer... * 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 `model-design`. -- [ ] 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. -- [ ] Verify that the link is accessible in a private browser window. +- [V ] Create a branch called `model-design`. +- [V ] Ensure that the repository is public. +- [V ] 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. +- [V ] 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 at `#cohort-3-help`. Our Technical Facilitators and Learning Support staff are here to help you navigate any challenges. From 5b54028916f73557633ede4f5ebee6fb9ee83714 Mon Sep 17 00:00:00 2001 From: monzchan <166637673+monzchan@users.noreply.github.com> Date: Mon, 27 May 2024 20:40:59 -0400 Subject: [PATCH 8/8] Update question 3 answer --- 02_assignments/design_a_logical_model.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/02_assignments/design_a_logical_model.md b/02_assignments/design_a_logical_model.md index 15af40e35..0abf05f2e 100644 --- a/02_assignments/design_a_logical_model.md +++ b/02_assignments/design_a_logical_model.md @@ -18,10 +18,12 @@ The store wants to keep customer addresses. Propose two architectures for the CU _Hint, search type 1 vs type 2 slowly changing dimensions._ Type 1 - ![image](https://github.com/monzchan/SQL/assets/166637673/5a755a5a-1705-4b22-808f-e00bc37fe8d8) +![image](https://github.com/monzchan/SQL/assets/166637673/7b275804-09bb-4439-9695-4ab2b8393348) + Type 2 - ![image](https://github.com/monzchan/SQL/assets/166637673/0b1a0ced-c5d7-4367-8318-8c14d15b72d0) +![image](https://github.com/monzchan/SQL/assets/166637673/a06d2c21-2778-4364-af2e-28c869a6171d) + For type 2 architecture, privacy issue raised since customer data will be retained in the data bank forever. It enables data scientist to track historically significant attributes. But for type 1 slowly changing dimension, the data about customer’s information will be overwritten by updated data. So, only the recent data will be kept.