Professional Documents
Culture Documents
Mis 275 HW2
Mis 275 HW2
Homework 2
Normalization is a Within a database Unique identifiers are Cardinality pertains to ERDs provide
method utilized in the table, a determinant attributes or the association between visual
design of databases to signifies the combinations of tables within a representations
Technical streamline data attribute(s) attributes that database, outlining the of the
Interviewer organization by responsible for guarantee the quantity of entities relationships and
minimizing uniquely individuality of engaged. data structure
redundancy, identifying a record records within a within a
dependency, and or regulating the database table. database,
inconsistency. values of other facilitating
attributes. comprehension
of the database
schema. They
employ boxes
and arrows to
depict tables and
relationships.
Gomez Fabian Winter-MIS 275 – HW2 3
ERDs function
All types of Comprehending
It is essential for all as a visual
Every type of audience audiences should cardinality is vital for
types of audiences portrayal of
should grasp the understand the audiences of all kinds,
to comprehend the database
Similirity fundamental notion of concept that unique as it aids in delineating
concept of structure and
or removing redundancy identifiers aid in the relationships among
determinants as a relationships, a
Difference and enhancing data singular identification tables.
means of uniquely crucial aspect
across integrity. identifying records of records within a for all types of
Audience within a table. table. audiences.
Second, describe this query in replicable and documentable terms. That is, could someone follow the query you wrote via code
and code annotations?
Third, provide the code and walk the reader through each of your queries.
Criteria for your two queries:
1. The query must have three tables with the appropriate joins.
2. The query must use at least 1 standard SQL function. You can also pick functions that are outside of the learning lab (if
they are supported).
3. The query should have a multi-statement where such as, Where <CONDITION 1...> &, OR, NOT <CONDITION N...>,
Etc...
4. The query must run when it is run by an independent analyst.
Design 1
First, (Business Need)
Business Recommendation: The company may seek to recognize its most valuable customers by analyzing their total purchase
amounts, aiming to customize exclusive offers, loyalty initiatives, or focused marketing strategies. Such insights can significantly
enhance customer retention rates and drive revenue growth.
For this query, I will use the function SUM which is supported by our SQL lab and the multi-statement where that will filter orders on
the shipped orders. The query will be displayed with ascendent results
Second, (code)
SELECT
customers.customer_id,
customers.company_name,
Gomez Fabian Winter-MIS 275 – HW2 5
FROM
Orders
JOIN
JOIN
WHERE
GROUP BY
customers.customer_id, customers.company_name
ORDER BY
TotalAmountOfPurchase asc;
Third (explanation):
The SELECT will Retrieves the customer_id and company_name and in the same time it will calculate the total amount of purchase
using the SUM() function.
Then, FROM will identify the table “orders, customer and order_details, the Join will link the tables relationship and the multi-
statement WHERE will filter the orders already shipped. Finally the GROUP BY clause will group the outcome by customer_id and
the company_id and then in a ascending order, it will arrange the outcomes by total amount of purchases.
Design 2:
Business Recommendation: In order to maintain efficient inventory management, it is essential for the company to identify products
that are either out-of-stock or low in quantity and require replenishment. These insights are critical for preventing stock shortages and
ensuring timely order fulfillment.
Second, (code)
SELECT
products.product_name,
products.product_id,
MIN(products.units_in_stock) AS order_left
FROM
products
Gomez Fabian Winter-MIS 275 – HW2 8
JOIN
GROUP BY
products.product_id, products.product_name
HAVING
MIN(products.units_in_stock) <= 3;
Third, (explanation):
The SELECT will calculate the minimun stock with the selected product_id and product_name. The FROM clause will specify the
table, in this case the product and oreder_details. Then the JOIN will specify the relationship with those table. After that, the GROUP
BY will group the product_id and product_name. Finally the HAVING will filter all products with a minimun stock of 3 or less. In the
screenshot below, we can see that there several products that are zero, and they need to be reorder back to have in stock.