Proposals for Fixing the table Data
The table data organization has two main problems:
- It repeats information about catalogue items in multiple rows of the orders table
- It has multiple rows for each person, even though the tasks mostly process orders for a single person.
Here are two concrete proposals for organizing the data which address one or both of these problems:
Proposal 1: Linking the Tables
The current orders table repeats the price and weight columns from the catalogue. Instead, it would be better to leave that information in the catalogue table, and have a way to reference into particular rows of the catalogue table from the orders table.
Concretely: replace the description
, price
, andweight
columns in the orders table with an item-id
column. Then, when a program needs the price of an item, the item-id
can be used to find the appropriate row in the catalogue.
New order table:
name |
item-id |
count |
Anne |
7 |
1 |
John |
6 |
5 |
(these Item-IDs match the contents in the first column of the catalogue as show in the Google Sheet.)
Proposal 2: Create Datatypes
Dispense with the tables entirely, and instead use three datatypes:
-
A datatype called ItemData
for data about catalogue items and giftcards. For catalogue items, the components are the description, price, weight, and dimensions. For gift-cards, the only component is the amount stored on the card.
-
A datatype called Order
which has two components: an ItemData
and the count of that item that someone wants to order (there would be one Order
value for each row of the original orders table)
-
A datatype called UserOrder
which has two components: the customer’s name, and a list of their Order
.
Proposals for Fixing the table Data
The table data organization has two main problems:
Here are two concrete proposals for organizing the data which address one or both of these problems:
Proposal 1: Linking the Tables
The current orders table repeats the price and weight columns from the catalogue. Instead, it would be better to leave that information in the catalogue table, and have a way to reference into particular rows of the catalogue table from the orders table.
Concretely: replace the
description
,price
, andweight
columns in the orders table with anitem-id
column. Then, when a program needs the price of an item, theitem-id
can be used to find the appropriate row in the catalogue.New order table:
(these Item-IDs match the contents in the first column of the catalogue as show in the Google Sheet.)
Proposal 2: Create Datatypes
Dispense with the tables entirely, and instead use three datatypes:
A datatype called
ItemData
for data about catalogue items and giftcards. For catalogue items, the components are the description, price, weight, and dimensions. For gift-cards, the only component is the amount stored on the card.A datatype called
Order
which has two components: anItemData
and the count of that item that someone wants to order (there would be oneOrder
value for each row of the original orders table)A datatype called
UserOrder
which has two components: the customer’s name, and a list of theirOrder
.