Conversation
rearrange of 05 content
matching the markdown
matching the markdown
amanda-ng518
approved these changes
May 26, 2024
amanda-ng518
suggested changes
May 26, 2024
amanda-ng518
approved these changes
May 26, 2024
amanda-ng518
approved these changes
May 26, 2024
There was a problem hiding this comment.
HW5: 8/8
INSERT Q2 missing SELECT, FROM and WHERE statements
DELETE Q1 product_id = 7 not 33333
UPDATE Q1
ALTER TABLE product_units
ADD current_quantity INT;
UPDATE product_units
SET current_quantity = (
SELECT current_quantity
FROM (
SELECT p.product_id, COALESCE(quantity,0) as current_quantity
FROM product_units p
LEFT JOIN (
SELECT *
,ROW_NUMBER() OVER( PARTITION BY vi.product_id ORDER BY market_date DESC) AS rn
FROM vendor_inventory vi
) vi ON p.product_id = vi.product_id
WHERE rn = 1
OR rn IS NULL
) p
WHERE product_units.product_id = p.product_id);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
Establish relationship between 2 tables of the database. A crash course on SQL commands.
What did you learn from the changes you have made?
Learnt logical design of DB tables. learnt many SQL commands I didn't know existed.
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
well to store similar data, once could use a non-relational Database. I would use graph DBS these days as they offer a good balance between design complexity and performance.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
None so far
How were these changes tested?
used draw.io to reference the relationship between tables. used DB Browser for SQLite to explore the tables and write queries.
A reference to a related issue in your repository (if applicable)
Checklist
@kaylielau
@dwz92