Exercise 6.1 - Transactions:
In pg-admin, create a SQL script that does the following:
Tables:
Customers
. Alias ascu
Sales_Header
. Alias assh
Sales_Detail
. Alias assd
Attributes:
sale_id
. Alias asTransaction
customer_name
. Alias asCustomer
date_sale
. Alias asDate
feedback_score
. Alias asFeedback
- The total
revenue
for this transaction. Alias asAmount
- The total number of
items_sold
. Alias asItems
Other considerations:
- Order by
date_sale
with the most recent date 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_Transactions
-
Append SQL to
SELECT * FROM
thisVIEW
into the space provided in line 13 of backend/routes/transactions.js -
Save and close backend/routes/transactions.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/transactions)
- This should be populated with an array of 10 objects for each transaction
- This is the data that our front-end will use to populate the Transactions table on the web page
- In the main Sequel-Mark website (http://localhost:5001), check the Transactions table has been populated