summaryrefslogtreecommitdiff
path: root/assignments/2
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-01-31 11:45:03 -0700
committermo khan <mo.khan@gmail.com>2020-01-31 11:45:03 -0700
commit7b7d20db4eda3de03400b1bfd3ad73c4b8aad00f (patch)
tree99f89f3e6fd95eb214310b2753bae7123698c05c /assignments/2
parent8b55e7d51cf0cc9c93902899dd92f02ffde3a503 (diff)
Add example for denormalization
Diffstat (limited to 'assignments/2')
-rw-r--r--assignments/2/README.md21
1 files changed, 20 insertions, 1 deletions
diff --git a/assignments/2/README.md b/assignments/2/README.md
index 82494f9..f54f3ec 100644
--- a/assignments/2/README.md
+++ b/assignments/2/README.md
@@ -54,7 +54,26 @@ Answer the following questions (250 words max/question).
```
2. A many-to-many relationship with nonkey attributes
- * E.g.
+ ```text
+ Order(id: integer, customer_id: integer)
+ LineItem(id: integer, product_id: integer, order_id: integer, quantity: integer, purchase_price: decimal)
+ Product(id: integer, name: string, description: text, current_price: decimal)
+ ```
+
+ In order to display a customers order history it might make sense to denormalize the
+ relationships to make it easy to see the product name and description to capture these fields
+ as they were at the time of purchase.
+
+ This would ensure that the order history can display the name and description of the product
+ at the time of purchase rather than the current product name and description. The current
+ product name and description can change and may include or exclude information that was
+ available at the time of purchase.
+
+ ```text
+ Order(id: integer, customer_id: integer)
+ LineItem(id: integer, product_id: integer, order_id: integer, quantity: integer, purchase_price: decimal, name: string, description: text)
+ ```
+
3. Reference data
* E.g.