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
Binary file added 02_assignments/Assignment_Question1.png
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_assignments/Assignment_Question2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions 02_assignments/design_a_logical_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ 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/).

![Bookstore](./Assignment_Question1.png)

## Question 2
We want to create employee shifts, splitting up the day into morning and evening. Add this to the ERD.
![Bookstore](./Assignment_Question2.png)

## 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?
Expand All @@ -16,14 +19,53 @@ _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:
In this approach, every time a customer's address changes, the old address is overwritten with the new one. This means that the database only retains the most recent address for each customer.

CREATE TABLE CUSTOMER_ADDRESS (
Customer_ID INT PRIMARY KEY,
Address VARCHAR(255) NOT NULL,
City VARCHAR(100) NOT NULL,
State VARCHAR(100) NOT NULL,
Zip_Code VARCHAR(20) NOT NULL,
Country VARCHAR(100) NOT NULL
);

Type 2:
In this approach, every time a customer's address changes, a new record is created, and the old record is marked as historical. This way, the database retains all previous addresses along with the current one.
CREATE TABLE CUSTOMER_ADDRESS (
Customer_Address_ID INT PRIMARY KEY,
Customer_ID INT NOT NULL,
Address VARCHAR(255) NOT NULL,
City VARCHAR(100) NOT NULL,
State VARCHAR(100) NOT NULL,
Zip_Code VARCHAR(20) NOT NULL,
Country VARCHAR(100) NOT NULL,
Start_Date DATE NOT NULL,
End_Date DATE NULL
);

Privacy Implications: Type 1 is less sensitive because only the current address is stored. The historical addresses are not saved. If there were any breaches in the past, the old data is not valid.

```


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

1 - Address
I save Address as string in Customer and Employee table. The example keeps Address in a separated table, and then connect other tables via the Address ID.

2 - Sales Order
I keep orders in just Order table. The example saves orders in Header and Detail table. Both have a one-to-many relationship.

The two approaches are mush better than mine. They have better relationship logically and structurally. I would change mine.

```

# Criteria
Expand Down