From c20b4475c7f970631005d2097115cf3e9fde9a02 Mon Sep 17 00:00:00 2001 From: oscar-lopez-projects Date: Thu, 6 Aug 2020 15:01:29 -0700 Subject: [PATCH 1/2] finished the PostgreSQL, now working on normalizing data --- README.md | 65 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index a24715b..3e92e54 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same ### Answer the following data queries. Keep track of the SQL you write by pasting it into this document under its appropriate header below in the provided SQL code block. You will be submitting that through the regular fork, change, pull process -* [ ] ***find all customers that live in London. Returns 6 records*** +* [x] ***find all customers that live in London. Returns 6 records***
hint @@ -37,10 +37,12 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + SELECT city, contact_name, address, contact_title + FROM customers + WHERE city = 'London' ``` -* [ ] ***find all customers with postal code 1010. Returns 3 customers*** +* [x] ***find all customers with postal code 1010. Returns 3 customers***
hint @@ -48,10 +50,13 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL + SELECT city, contact_name, address, contact_title, postal_code + FROM customers + WHERE postal_code = '1010' ``` -* [ ] ***find the phone number for the supplier with the id 11. Should be (010) 9984510*** +* [x] ***find the phone number for the supplier with the id 11. Should be (010) 9984510***
hint @@ -59,10 +64,12 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + SELECT supplier_id, company_name, contact_name, phone, country + FROM suppliers + WHERE supplier_id = '11' ``` -* [ ] ***list orders descending by the order date. The order with date 1998-05-06 should be at the top*** +* [x] ***list orders descending by the order date. The order with date 1998-05-06 should be at the top***
hint @@ -70,10 +77,12 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + SELECT order_id, customer_id, order_date + FROM orders + ORDER BY order_id DESC ``` -* [ ] ***find all suppliers who have names longer than 20 characters. Returns 11 records*** +* [ x ***find all suppliers who have names longer than 20 characters. Returns 11 records***
hint @@ -82,10 +91,12 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + SELECT supplier_id, company_name, contact_name + FROM suppliers + WHERE length(company_name)> 20 ``` -* [ ] ***find all customers that include the word 'MARKET' in the contact title. Should return 19 records*** +* [x] ***find all customers that include the word 'MARKET' in the contact title. Should return 19 records***
hint @@ -95,10 +106,13 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL + SELECT contact_title + FROM customers + WHERE contact_title LIKE 'M%' ``` -* [ ] ***add a customer record for*** +* [x] ***add a customer record for*** * customer id is 'SHIRE' * company name is 'The Shire' * contact name is 'Bilbo Baggins' @@ -112,10 +126,11 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same ```SQL - + INSERT INTO customers(customer_id, company_name, contact_name, address, city, postal_code, country) + Values('SHIRE', 'The Shire','Bilbo Baggins','1 Hobbit-Hole','Bag End','111','Middle Earth') ``` -* [ ] ***update _Bilbo Baggins_ record so that the postal code changes to _"11122"_*** +* [x] ***update _Bilbo Baggins_ record so that the postal code changes to _"11122"_***
hint @@ -123,10 +138,12 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + UPDATE CUSTOMERS + SET POSTAL_CODE = '11122' + WHERE POSTAL_CODE = '111' ``` -* [ ] ***list orders grouped and ordered by customer company name showing the number of orders per customer company name. _Rattlesnake Canyon Grocery_ should have 18 orders*** +* [x] ***list orders grouped and ordered by customer company name showing the number of orders per customer company name. _Rattlesnake Canyon Grocery_ should have 18 orders***
hint @@ -135,10 +152,12 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + Select count(o.customer_id), c.company_name + From orders o JOIN customers c on o.customer_id = c.customer_id + Group By c.company_name ``` -* [ ] ***list customers by contact name and the number of orders per contact name. Sort the list by the number of orders in descending order. _Jose Pavarotti_ should be at the top with 31 orders followed by _Roland Mendal_ with 30 orders. Last should be _Francisco Chang_ with 1 order*** +* [x] ***list customers by contact name and the number of orders per contact name. Sort the list by the number of orders in descending order. _Jose Pavarotti_ should be at the top with 31 orders followed by _Roland Mendal_ with 30 orders. Last should be _Francisco Chang_ with 1 order***
hint @@ -146,10 +165,13 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + Select count (o.customer_id), c.contact_name + From orders o JOIN customers c on o.customer_id = c.customer_id + Group by c.contact_name + Order by count (o.customer_id) desc ``` -* [ ] ***list orders grouped by customer's city showing the number of orders per city. Returns 69 Records with _Aachen_ showing 6 orders and _Albuquerque_ showing 18 orders*** +* [x] ***list orders grouped by customer's city showing the number of orders per city. Returns 69 Records with _Aachen_ showing 6 orders and _Albuquerque_ showing 18 orders***
hint @@ -157,7 +179,10 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same
```SQL - + Select count(o.customer_id), c.city + From orders o JOIN customers c on o.customer_id = c.customer_id + Group By c.city + Order By count (o.customer_id) ``` ## Data Normalization From 3554d271d107b251a899c6d8f26c7a57da2110e1 Mon Sep 17 00:00:00 2001 From: oscar-lopez-projects Date: Thu, 6 Aug 2020 15:44:08 -0700 Subject: [PATCH 2/2] mvp --- README.md | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 3e92e54..43fb2e8 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Reimport the Northwind database into PostgreSQL using pgAdmin. This is the same ```SQL SELECT contact_title FROM customers - WHERE contact_title LIKE 'M%' + WHERE upper(contact_title) LIKE '%MARKET%' ``` @@ -202,41 +202,41 @@ Below are some empty tables to be used to normalize the database * Not all of the cells will contain data in the final solution * Feel free to edit these tables as necessary -Table Name: +Table Name: Person data -| | | | | | | | | | +| person_id | person_name|city_dweller|fenced_yard | | | | | |------------|------------|------------|------------|------------|------------|------------|------------|------------| -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | +| 1 |jane | yes | no | | | | | +| 2 |bob | no | no | | | | | +| 3 |sam | no | yes | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -Table Name: +Table Name: Pets data -| | | | | | | | | | -|------------|------------|------------|------------|------------|------------|------------|------------|------------| -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | +| pet_id | pet_name | type | person_id | | | | | | +|------------ |----------------|------------ |------------ |------------|------------|------------|------------|------------| +| 1 | ellie | DOG | 1 | | | | | | +| 2 | joe | HORSE | 2 | | | | | | +| 3 | ginger | DOG | 3 | | | | | | +| 4 | tiger | CAT | 1 | | | | | | +| 5 | miss kitty | CAT | 3 | | | | | | +| 6 | toby | TURTLE | 1 | | | | | | +| 7 | bubble | FISH | 3 | | | | | | -Table Name: +Table Name: type of pet data -| | | | | | | | | | -|------------|------------|------------|------------|------------|------------|------------|------------|------------| -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | -| | | | | | | | | | +| pet_id | species | | | | | | | | +|-------------|------------|------------|------------|------------|------------|------------|------------|------------| +| 1 | | | | | | | | | +| 2 | | | | | | | | | +| 3 | | | | | | | | | +| 4 | | | | | | | | | +| 5 | | | | | | | | | +| 6 | | | | | | | | | +| | | | | | | | | | Table Name: