Create 2 sql schemas for PostgreSQL and Amazon Redshift based on models below.
supplier (1-many) act_of_delivery (1-many) shipment_log (many-1) item
supplier |
---|
id |
name |
act_of_delivery |
---|
id |
warehouse_id |
supplier_id |
datetime_utc |
package |
---|
act_id |
item_id |
count |
item |
---|
id |
title |
cost |
height |
length |
depth |
weight |
is_vertical_stackable |
Optimize tables for the queries below and leave description what and why you used.
-
warehouse_id, supplier_id, sum(cost * count), sum(count), sum(cost), day(datetime_utc)
-
warehouse_id, supplier_id, sum(cost * count), sum(count), sum(cost), month(datetime_utc)
-
warehouse_id, supplier_id, sum(cost * count), sum(count), sum(cost), year(datetime_utc)
-
warehouse_id, sum(count), sum(cost), day(datetime_utc), order by day
-
warehouse_id, sum(count), sum(cost), month(datetime_utc), order by month
-
warehouse_id, sum(count), sum(cost), year(datetime_utc), order by year
-
warehouse_id, sum(height * length * depth), count(act_id)
-
item_id, supplier_id, sum(cost * count), sum(count), sum(cost)