Skip to content

Assignment two#4

Open
eceyucer wants to merge 6 commits intomainfrom
assignment-two
Open

Assignment two#4
eceyucer wants to merge 6 commits intomainfrom
assignment-two

Conversation

@eceyucer
Copy link
Owner

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

Added code to assignment2.sql to complete the assignment, familiarizing myself with coalesce, window functions such as row_number and rank, string manipulations, and updating data tables. Completed sections 1 and 4.

What did you learn from the changes you have made?

Designing a database from scratch in Section 1, practicing new SQL knowledge on coalesce, window functions such as row_number and rank, string manipulations, updating data tables in Sections 2 and 3, and considering the nuances of ethics of automatization models.

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

No.

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

I did not realize that I was in the assignment-one branch when I created my assignment-two branch on the terminal. I opened a pull request and noticed that all my commits for assignment-one were also appearing. As a result, I first renamed the original assignment-two branch, accidentally committed assignment-one related changes once again, deleted the first branch and renamed the second attempt as assignment-two-archieve. The current branch only has assignment-two related commits.

How were these changes tested?

By running the SQL code on SQLite.

A reference to a related issue in your repository (if applicable)

N/A

Checklist

  • I can confirm that my changes are working as intended

Copy link

@kelichiu kelichiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total Point: 60/70

Section 1: 44/46

  • TYPE 1 & TYPE 2: A table can not contain both type 1 & type 2 records at the same time. Type 1 / Type 2 refer to the design of a Table, not addresses.

Section 2: 6/8

  • WINDOW FUNCTION Q1: When use ROW_NUMBER, the data of customer_id and market_date is not unique. We need to use GROUP BY to get the unique combination of customer_id and market_date in data.

Section 3: 2/8

  • INSERT: snapshot_timestamp column should be created when creating the product_units table. Having it created with ALTER statement afterwards resulted in NULLs for existing records.
  • DELETE: It’s correct to use both product_id and snapshot_timestamp to delete the record. However, the condition “snapshot_timestamp IS NULL” is not correct, as you shouldn’t have NULL values in this column in the first place.
  • UPDATE: The subquery inside COALESCE is not correctly written. This resulted in NULL values not being handled in the final result.

Section 4: 8/8

@eceyucer
Copy link
Owner Author

eceyucer commented Feb 2, 2025

Total Point: 60/70

Section 1: 44/46

  • TYPE 1 & TYPE 2: A table can not contain both type 1 & type 2 records at the same time. Type 1 / Type 2 refer to the design of a Table, not addresses.

Section 2: 6/8

  • WINDOW FUNCTION Q1: When use ROW_NUMBER, the data of customer_id and market_date is not unique. We need to use GROUP BY to get the unique combination of customer_id and market_date in data.

Section 3: 2/8

  • INSERT: snapshot_timestamp column should be created when creating the product_units table. Having it created with ALTER statement afterwards resulted in NULLs for existing records.
  • DELETE: It’s correct to use both product_id and snapshot_timestamp to delete the record. However, the condition “snapshot_timestamp IS NULL” is not correct, as you shouldn’t have NULL values in this column in the first place.
  • UPDATE: The subquery inside COALESCE is not correctly written. This resulted in NULL values not being handled in the final result.

Section 4: 8/8

Hi Keli,

Hope you are doing well! Can I ask for the outputs on your end to see what’s actually wrong? Especially for the update statement since it is working perfectly fine on my end — thanks!

@kelichiu
Copy link

kelichiu commented Feb 2, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants