From 11ad21770739625e099dfba3aeff8ce87686fa78 Mon Sep 17 00:00:00 2001 From: HadikaMalik Date: Sun, 26 May 2024 00:43:30 +0100 Subject: [PATCH] ecommerce done --- E-Commerce/readme.md | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/E-Commerce/readme.md b/E-Commerce/readme.md index 37580cce..cca9a097 100644 --- a/E-Commerce/readme.md +++ b/E-Commerce/readme.md @@ -46,16 +46,51 @@ erDiagram Write SQL queries to complete the following tasks: - [ ] List all the products whose name contains the word "socks" + select * from products where product_name ilike '%socks%'; - [ ] List all the products which cost more than 100 showing product id, name, unit price, and supplier id + select p.id, p.product_name, pa.unit_price, s.supplier_name + from products p + join product_availability pa on p.id = pa.prod_id + join suppliers s on s.id = pa.supp_id + where pa.unit_price > 100; - [ ] List the 5 most expensive products + select p.product_name, pa.unit_price + from products p + join product_availability pa on p.id = pa.prod_id + order by pa.unit_price desc limit 5; - [ ] 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 p.product_name, s.supplier_name + from products p + join product_availability pa on p.id = pa.prod_id + join suppliers s on s.id = pa.supp_id + where s.country = 'United Kingdom'; - [ ] List all orders, including order items, from customer named Hope Crosby + select o.id, o.order_date, o.order_reference, p.product_name, oi.quantity + from orders o + join order_items oi on o.id = oi.order_id + join products p on oi.product_id = p.id + join customers c on o.customer_id = c.id + where c.name = 'Hope Crosby'; - [ ] List all the products in the order ORD006. The result should only contain the columns product_name, unit_price, and quantity + select p.product_name, pa.unit_price, oi.quantity + from orders o + join order_items oi on o.id = oi.order_id + join products p on oi.product_id = p.id + join product_availability pa on oi.product_id = pa.prod_id and oi.supplier_id = pa.supp_id + where o.order_reference = 'ORD006'; - [ ] 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 + select c.name, o.order_reference, o.order_date, p.product_name, s.supplier_name, oi.quantity + from orders o + join customers c on o.customer_id = c.id + join order_items oi on o.id = oi.order_id + join products p on oi.product_id = p.id + join product_availability pa on oi.product_id = pa.prod_id and oi.supplier_id = pa.supp_id + join suppliers s on oi.supplier_id = s.id + order by c.name, o.order_reference, p.product_name; ## Acceptance Criteria -- [ ] The `cyf_ecommerce` database is imported and set up correctly -- [ ] The database schema is drawn correctly to visualize relationships between tables -- [ ] The SQL queries retrieve the correct data according to the tasks listed above -- [ ] The pull request with the answers to the tasks is opened on the `main` branch of the `E-Commerce` repository +- [x] The `cyf_ecommerce` database is imported and set up correctly +- [x] The database schema is drawn correctly to visualize relationships between tables +- [x] The SQL queries retrieve the correct data according to the tasks listed above +- [x] The pull request with the answers to the tasks is opened on the `main` branch of the `E-Commerce` repository