Skip to content

London 9 _Sana Asaf _Module-Databases_Week 2 - #32

Closed
SanaAsaf wants to merge 1 commit into
CodeYourFuture:mainfrom
SanaAsaf:main
Closed

London 9 _Sana Asaf _Module-Databases_Week 2#32
SanaAsaf wants to merge 1 commit into
CodeYourFuture:mainfrom
SanaAsaf:main

Conversation

@SanaAsaf

Copy link
Copy Markdown

ER- Diagram
(https://github.com/CodeYourFuture/Module-Databases/assets/85436780/5d1025c6-450e-4168-91c6-36cce474c210)

Learners, PR Template

Self checklist

  • [ *] I have committed my files one by one, on purpose, and for a reason
  • [ *] I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • [* ] I have tested my changes
  • [ *] My changes follow the style guide
  • [* ] My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@Alexander-Rennie Alexander-Rennie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great answers (some minor observations included below)

Comment thread E-Commerce/readme.md
- [ ] List all the products in the order ORD006. The result should only contain the columns product_name, unit_price, and quantity
- [ ] List all the products with their supplier for all orders of all customers. The result should only contain the columns name (from customer), order_reference, order_date, product_name, supplier_name, and quantity
- [*] List all the products whose name contains the word "socks"
SELECT * FROM products WHERE product_name LIKE ‘%socks%’;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CORRECT

Comment thread E-Commerce/readme.md
SELECT prod_id, product_name, unit_price, supp_id
FROM product_availability pa INNER JOIN products p on (pa.prod_id=p.id)
INNER JOIN suppliers s on (pa.supp_id=s.id)
WHERE unit_price > 100;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CORRECT - Whilst this is not wrong, there is no need to join in the suppliers table, as you are only returning no details from it (only the supp_id which is in product_availability)

Comment thread E-Commerce/readme.md
WHERE unit_price > 100;

- [*] List the 5 most expensive products
select product_name , unit_price FROM product_availability pa INNER JOIN products p on (pa.prod_id=p.id) by unit_price desc Limit 5;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CORRECT

Comment thread E-Commerce/readme.md
- [*] List all the products sold by suppliers based in the United Kingdom. The result should only contain the columns product_name and supplier_name
SELECT product_name , supplier_name
FROM product_availability pa INNER JOIN products p on (pa.prod_id=p.id)
INNER JOIN suppliers s on (pa.supp_id=s.id) where s.country='United Kingdom';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CORRECT

Comment thread E-Commerce/readme.md
SELECT order_id,product_id,supplier_id,quantity
FROM order_items oi INNER JOIN orders o ON (oi.order_id=o.id)
INNER JOIN customers c ON (o.customer_id=c.id)
where c.name = 'Hope Crosby';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CORRECT

Comment thread E-Commerce/readme.md
FROM order_items oi INNER JOIN orders o ON (oi.order_id=o.id)
INNER JOIN products p ON (p.id=oi.product_id)
INNER JOIN product_availability pa ON (p.id=pa.prod_id)
WHERE o.order_reference = 'ORD006';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CORRECT

Comment thread E-Commerce/readme.md
INNER JOIN order_items oi ON (oi.order_id=o.id)
INNER JOIN products p ON (p.id=oi.product_id)
INNER JOIN product_availability pa ON (p.id=pa.prod_id)
INNER JOIN suppliers s ON (pa.supp_id=s.id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CORRECT - Whilst this is not wrong, there is no need to join in the product_availability table, as you are returning no details from it, and could link to suppliers via oi.supplier_id

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.

3 participants