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
62 changes: 62 additions & 0 deletions Week3/homework/Exercise1/SQL-Normalization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
### 3.1. Exercise 1 : SQL Normalization

The manager of the dinner club would like to manage the information system that assists him to keep track of the dinners
had by members.
Because the manager is not an expert of Information Systems, (s)he uses the following table to store the information.
Please help the manger by using the knowledge of database normal forms.
Save all answers in a text file / MD file.

1. What columns violate 1NF?
- 1NF - need will be one value, same type, unique names, no dublicated. 1 Box - 1 thing
- dinner_date has many different date formats
- food_code has many values in one cell
- food_description has many values in one cell

2. What entities do you recognize that could be extracted?
- entities - is things or objects. ERP diagram consist with : entities, atributes, relationships.
- atributes is describe entities. relationships: one to many, many to many, many to one.
- We can see these entities:
Member
Dinner
Venue
Food
Member–Dinner (members join dinners)
Dinner–Food (dinners have many foods)
3. Name all the tables and columns that would make a 3NF compliant solution.
- 3NF - Must be 2NF before.
- No transitive dependency: column cannot depend on a non-key column.
- 1.Member
member_id
member_name
member_address
- 2.Dinner
dinner_id
dinner_date
venue_code
- 3.Venue
venue_code
venue_description
- 4.Food
food_code
food_description
- 5.Dinner_Food
dinner_id
food_code
- 6.Member_Dinner
member_id
dinner_id

```
+-----------+---------------+----------------+-----------+-------------+------------+-------------------+-----------+------------------+
| member_id | member_name | member_address | dinner_id | dinner_date | venue_code | venue_description | food_code | food_description |
+-----------+---------------+----------------+-----------+-------------+------------+-------------------+-----------+------------------+
| 1 | Amit | 325 Max park | D00001001 | 2020-03-15 | B01 | Grand Ball Room | C1, C2 | Curry, Cake |
| 2 | Ben | 24 Hudson lane | D00001002 | 2020/03/15 | B02 | Zoku Roof Top | S1, C2 | Soup, Cake |
| 3 | Cristina | 516 6th Ave | D00001002 | 2020/03/15 | B02 | Zoku Roof Top | S1, C2 | Soup, Cake |
| 4 | Dan | 89 John St | D00001003 | 20-03-2020 | B03 | Goat Farm | P1, T1, M1| Pie, Tea, Mousse |
| 1 | Amit | 325 Max park | D00001003 | 20-03-2020 | B03 | Goat Farm | P1, T1, M1| Pie, Tea, Mousse |
| 3 | Cristina | 516 6th Ave | D00001004 | Mar 25 '20 | B04 | Mama's Kitchen | F1, M1 | Falafal, Mousse |
| 5 | Gabor | 54 Vivaldi St | D00001005 | Mar 26 '20 | B05 | Hungry Hungary | G1, P2 | Goulash, Pasca |
| 6 | Hema | 9 Peter St | D00001003 | 01-04-2020 | B03 | Goat Farm | P1, T1, M1| Pie, Tea, Mousse |
+-----------+---------------+----------------+-----------+-------------+------------+-------------------+-----------+------------------+
```
13 changes: 13 additions & 0 deletions Week3/homework/Exercise2/SQL-Transactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### 3.2. Exercise 2 : SQL Transactions

1. Create two tables `account` and `account_changes` (write transactions-create-tables.js file)
2. `account` table should have following fields : `account_number, balance`.
3. `account_changes` table should have the following
fields : `change_number, account_number, amount, changed_date, remark`.
4. Choose the appropriate data types and keys for these tables.
5. Insert some sample data in these tables. (write transactions-insert-values.js file)
6. Transfer the amount of 1000 from account number 101 to account number 102 and log the changes in the
table `account_changes`.
Do this in a _single transaction_ (Write transaction.js file)

Submit all three files (`transactions-create-tables.js`, `transactions-insert-values.js` and `transaction.js`).
Binary file added Week3/homework/Exercise2/account.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 Week3/homework/Exercise2/account_changes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading