Skip to content

UofT-DSI | SQL Module – Assignment 2 (Sections 1–3)#2

Merged
val-poon merged 5 commits intomainfrom
assignment-two
May 7, 2025
Merged

UofT-DSI | SQL Module – Assignment 2 (Sections 1–3)#2
val-poon merged 5 commits intomainfrom
assignment-two

Conversation

@val-poon
Copy link
Copy Markdown
Owner

@val-poon val-poon commented May 2, 2025

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

This pull request submits the completed work for Assignment 2 of the SQL module. It includes:

  • Section 1: Logical Data Model (ERD) for a bookstore and extended model
  • Section 2: SQL queries using COALESCE, ROW_NUMBER, DENSE_RANK, COUNT, SUBSTR, INSTR, and UNION
  • Section 3: SQL queries for CROSS JOIN, INSERT, DELETE, and UPDATE operations using temporary and permanent tables
  • Added and modified assignment2.sql
  • Inserted new records and schema changes in farmersmarket.db (for Section 3)

What did you learn from the changes you have made?

  • How to normalize data into logical models using ER diagrams
  • How to apply string manipulation and window functions in SQL
  • How to simulate transactional updates using SQL’s INSERT, DELETE, and UPDATE
  • How to use COALESCE to handle NULLs and maintain clean outputs
  • How to manage GitHub version control across multiple steps

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

For updating current_quantity in Section 3, I explored using RANK() but chose to filter by ORDER BY market_date DESC LIMIT 1 for simplicity and clarity.


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

  • Initially misunderstood original_price as vendor cost instead of a historical price — corrected this after re-reading the schema and verifying use cases
  • Faced challenges updating a dynamic column from a subquery — resolved using COALESCE and a filtered UPDATE with EXISTS
  • Had to recreate the product_units table after realizing temporary tables aren’t saved in DB Browser

How were these changes tested?

  • Ran all queries locally using DB Browser
  • Verified results visually in the database and query output
  • Ensured PR diff reflects only intended additions
  • Saved .db changes and committed them using Git

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

N/A


✅ Checklist

  • ✅ I confirm that all queries run correctly in DB Browser
  • ✅ My ERD diagrams were included and committed correctly
  • ✅ I’ve followed the file structure and naming conventions
  • ✅ I’ve pushed changes to the correct assignment-two branch
  • ✅ This PR contains completed Assignment 2, Sections 1–3

Copy link
Copy Markdown

@niyazmnazari niyazmnazari left a comment

Choose a reason for hiding this comment

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

Thank you for submitting assignment 2. You didn't submit section1-propmpt3, section2, and section3.

Point: 40/70

@val-poon
Copy link
Copy Markdown
Owner Author

val-poon commented May 2, 2025

@niyazmnazari thank you for your PR! Working on the complete assignment EoW.

@val-poon val-poon changed the title UofT DSI SQL Module – Assignment 2: Section 1 (Logical Model + ERDs) UofT-DSI | SQL Module – Assignment 2 (Sections 1–3) May 5, 2025
Copy link
Copy Markdown

@niyazmnazari niyazmnazari left a comment

Choose a reason for hiding this comment

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

Good job, thank you. I did not find the answer of prompt 3 of section 1.
60/70

@val-poon
Copy link
Copy Markdown
Owner Author

val-poon commented May 6, 2025

@niyazmnazari Are you referring this section?
Screenshot 2025-05-06 at 1 44 08 PM

Copy link
Copy Markdown
Owner Author

@val-poon val-poon left a comment

Choose a reason for hiding this comment

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

✅ Section 3 now includes queries to calculate the number of vendor-product combinations (x) and customers (y), as outlined in the rubric.

@val-poon val-poon merged commit 9500e7e into main May 7, 2025
1 check passed
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