You are on page 1of 9

Gomez Fabian Winter-MIS 275 – HW2 1

Homework 2

Part 1: Concept Check-In


Normalization, Determinants, Unique Identifiers, Cardinality, Entity Relationship Diagrams, Entities, Columns & Attributes,
Rows, Non-Redundancy, Primary Keys, Foreign Keys,
Pick 5 concepts from above and make a table. In row 1, describe how you would explain this concept to a total stranger. In
row 2, describe how you would explain this concept to a database instructor. In row three, describe how you would explain
this concept to a technical interviewer. In row four, describe what might be similar or different across your audience types.

Normalization Determinants Unique Identifiers Cardinality ERD

Cardinality indicates Entity


Normalization refers to Determinants are Unique identifiers are
the quantity of Relationship
the systematic characteristics that attributes or
associated records Diagrams
arrangement of data distinctly identify a combinations of
between two tables (ERDs) depict
within a database to record within a attributes that
within a database the structure and
eradicate redundancy database table. singularly identify a
relationship. relationships of
and enhance data record within a data within a
Total integrity. This method database table. database.
Stranger entails decomposing a
table into smaller, more
manageable tables.
Gomez Fabian Winter-MIS 275 – HW2 2

Unique identifiers, Cardinality defines the (ERDs)


Normalization serves In the realm of commonly referred to quantity of occurrences visually depict
as a method employed database design, a as primary keys, are within an entity the
in the design of determinant denotes attributes or relationship, relationships
databases to avert the either a single combinations of delineating the and
Instructor duplication of data and attribute or a attributes that connection between
mitigate update combination of singularly identify a interactions
records across two
anomalies. It adheres attributes that record within a among tables
tables.
to a prescribed set of dictate the values of database table. within a
guidelines to organize additional attributes database.
data effectively. within a table.

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.

Part 2: Design 2 Very Challenging Queries from the NorthWind Database


First, describe the business need for the query you are selecting. What would motivate a business leader to want that kind of
information?
Gomez Fabian Winter-MIS 275 – HW2 4

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

SUM(order_details.quantity * order_details.order_id) AS TotalAmountOfPurchase

FROM

Orders

JOIN

Customers ON orders.customer_id = customers.customer_id

JOIN

order_details ON orders.order_id = order_details.order_id

WHERE

orders.shipped_date IS NOT NULL

GROUP BY

customers.customer_id, customers.company_name

ORDER BY

TotalAmountOfPurchase asc;

I ran the code in the sql-lab:


Gomez Fabian Winter-MIS 275 – HW2 6
Gomez Fabian Winter-MIS 275 – HW2 7

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:

Frist (Business Need)

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

order_details ON products.product_id = order_details.product_id

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.

I ran the code in the sql-lab.


Gomez Fabian Winter-MIS 275 – HW2 9

You might also like