Skip to content

Uploading Assignment 2 for proper repo pr#2

Open
elioc1341 wants to merge 1 commit intomainfrom
assignment-two
Open

Uploading Assignment 2 for proper repo pr#2
elioc1341 wants to merge 1 commit intomainfrom
assignment-two

Conversation

@elioc1341
Copy link
Owner

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

Completed Assignment 2. Has the following files:

  • assignment2.SQL
  • Assignment.md
  • SQL Assignment 2 Section 1 - Prompt 1.png
  • SQL Assignment 2 Section 1 - Prompt 2.png

What did you learn from the changes you have made?

Biggest takeaways were:

  1. I understand how cross joins work, but have never actually used it in practice in my jobs. Instinctively I would try to join on fields and was surprised by the results, but after class and seeing it in the assignment I understood how it works better now.
  2. I've actually never been exposed to window functions, so it was really great to learn how to use them in practice. It's very useful to be able to split out the data in the requested sections/partitions.
  3. My entire career has been mostly working with financial or insurance data, so it was actually really fun to be able to practice with new types of data/databases. Really enjoyed learning how this was set up

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

  • For Section 1 Prompt 3, I was thinking that the TYPE 2 could also use a start/end date fields instead of effective date and current flag indicators. I ended up settling on mine since I thought it would be the simplest to query all current customer address just by going "WHERE current_flag = 'Y'" instead of doing a MAX on the end date.
  • For Section 2 INSERT portion, I was thinking of doing "Insert into" to copy the field setup into the new table. I actually got curious what the equivalent for sp_help was for SQLite, so I ended up looking up that it was achievable with PRAGMA table_info.

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

It was my first time working with partitions, but I think what helped was to revisit the lecture section, and break down the problem into steps, and tackling one at a time. For example, for question 1, I would need to:

  1. Get all the dates for each customer
  2. Get the distinct dates (since customers can do multiple purchases on same date for duplicate entries)
  3. Set them up using partition by the customer
  4. Make sure they're ordered properly

How were these changes tested?

The changes were tested in SQLite, and observing the results (using select queries at each step).

It's very tedious, but for some questions I would export table data into Excel and used pivot tables to confirm if the results were partitioning at the right numbers just to do some sanity checks.

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

N/A

Checklist

  • I can confirm that my changes are working as intended

@elioc1341
Copy link
Owner Author

elioc1341 commented Apr 28, 2025

Recreated pull request - previous attempt went to improper repo.

@mrpotatocode - my apologies for the wrong initial pull request.

Copy link

@JzfL JzfL left a comment

Choose a reason for hiding this comment

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

Well done! 70/70

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