Exercise 6.3 - Products:
In pg-admin, create a SQL script that does the following:
Tables:
Products
. Alias aspr
Sales_Detail
. Alias assd
Attributes:
product_item
. Alias asproduct_item
product_variety
. Alias asproduct_variety
pack_size
. Alias aspack_size
unit_sales_price
. Alias asunit_price
- Total number of
items_sold
. Alias asitems_sold
inventory
. Alias asin inventory
Other considerations:
- Order by total number of
items_sold
with the highest value first - Limit the output to the first 10 rows only
-
Test this script in PostgreSQL
- The names and data should match the screenshot
-
Convert this SQL script into a
VIEW
calledv_Top_Products
-
Append SQL to
SELECT * FROM
thisVIEW
into the space provided in line 13 of backend/routes/products.js -
Save and close backend/routes/products.js
You may need to close and re-run your Docker session for this to take effect
- In a new browser tab, preview the transactions route (http://localhost:5001/products)
- This should be populated with an array of 10 objects for each product
- This is the data that our front-end will use to populate the Products table on the web page
- In the main Sequel-Mark website (http://localhost:5001), check the Products table has been populated