Thursday, May 2, 2024

CST 363: Week 2 Report

 1. One case in which an SQL join would be used on columns on non keys are in this given example: lets say we have two tables named "Products" and "Orders". If we were to require the total sales amount for each type of product, then we would have to join the two tables by the product type column, which may not necessarily be the primary or foreign key. This means that we would write in SQL as such:

 select a.product_type, sum(b.total_amount) as total_sales_amount from orders b

join products a on b.product_type = a.product_type

group by a.product_category;

2.  SQL as a language is actually very straightforward, the only confusing parts are the terms one has to learn in order to accomplish data manipulation. For example, it is tricky to remember when to use the term "on" and "as" when writing prompts. It is easy to forget what each term does, ultimately. However, with enough practice I am certain it will become far easier.

No comments:

Post a Comment